Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

deleteAnnotation()

Description

Delete annotation

@see getAnnotation()

Parameters

ColumnTypeDefaultDescription
$annotation array Annotation array as returned by getAnnotation()

Return

boolean

Location

include/annotation_functions.php lines 276 to 305

Definition

 
function deleteAnnotation(array $annotation)
    {
    if(!
annotationEditable($annotation))
        {
        return 
false;
        }

    
$annotation_ref $annotation['ref'];
    
$parameters=array("i",$annotation_ref);

    
$nodes_to_remove = array();
    foreach(
getAnnotationTags($annotation) as $tag)
        {
        
$nodes_to_remove[] = $tag['ref'];
        }

    
db_begin_transaction("deleteAnnotation");

    if(
count($nodes_to_remove))
        {
        
delete_resource_nodes($annotation['resource'], $nodes_to_remove);
        }

    
ps_query("DELETE FROM annotation_node WHERE annotation = ?"$parameters);
    
ps_query("DELETE FROM annotation WHERE ref = ?"$parameters);
        
    
db_end_transaction("deleteAnnotation");

    return 
true;
    }

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