Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

annotationEditable()

Description

Check if an annotation can be editable (add/ edit/ remove) by the user

Parameters

ColumnTypeDefaultDescription
$annotation array

Return

boolean

Location

include/annotation_functions.php lines 214 to 235

Definition

 
function annotationEditable(array $annotation)
    {
    
debug(sprintf('[annotations][fct=annotationEditable] $annotation = %s'json_encode($annotation)));
    global 
$userref;

    
$add_operation = !isset($annotation['user']);
    
$field_edit_access metadata_field_edit_access($annotation['resource_type_field']);

    
/* Non-admin edit authorisation is valid when:
        - user is just adding a new annotation
        - when editing/removing an existing annotation, the annotation was created by the user itself
    */
    
$non_admin_athz = ($add_operation || $userref == $annotation['user']);

    
// Anonymous users cannot edit by default. They can only edit if they are allowed CRUD operations
    
if(checkPermission_anonymoususer())
        {
        return 
$non_admin_athz && $field_edit_access;
        }

    return (
checkperm('a') || $non_admin_athz) && $field_edit_access;
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 6th March 2024 14:45 Europe/London time.