Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 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 19th March 2024 06:35 Europe/London time based on the source file dated 6th March 2024 14:45 Europe/London time.