Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource 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 215 to 242

Definition

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

    if(
$annotate_read_only)
        {
        
debug('[annotations][fct=annotationEditable][info] read-only annotation! Reason: the system is configured with annotate_read_only = true');
        return 
false;
        }

    
$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 
$annotate_crud_anonymous && $non_admin_athz && $field_edit_access;
        }

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

This article was last updated 7th March 2021 18:05 Europe/London time based on the source file dated 5th March 2021 16:05 Europe/London time.