Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

allow_multi_edit()

Description

Returns true or false, can all resources in this collection be edited by the user?

Parameters

ColumnTypeDefaultDescription
$collection array|int Collection IDs
$collectionid array 0

Return

boolean

Location

include/collections_functions.php lines 1966 to 2009

Definition

 
function allow_multi_edit($collection,$collectionid 0)
    {
    global 
$resource;

    if (
is_array($collection) && $collectionid == 0)
        {
        
// Do this the hard way by checking every resource for edit access
        
for ($n=0;$n<count($collection);$n++)
            {
            
$resource $collection[$n];
            if (!
get_edit_access($collection[$n]["ref"],$collection[$n]["archive"],false,$collection[$n]))
                {
                return 
false;
                }
            }    
        }
    else
        {            
        
// Instead of checking each resource we can do a comparison between a search for all resources in collection and a search for editable resources
        
$resultcount 0;
        if(!
is_array($collection))
            {
            
// Need the collection resources so need to run the search
            
$collectionid $collection;
            
$collection do_search("!collection{$collectionid}"''''0, -1''false0falsefalse''falsetruetrue,false);
            }
        if(
is_array($collection))
            {
            
$resultcount count($collection);
            }
        
$editcount 0;
        
$editresults =     do_search("!collection{$collectionid}"''''0, -1''false0falsefalse''falsetruetrue,true);
        if(
is_array($editresults))
            {
            
$editcount count($editresults);
            }
        if(
$resultcount != $editcount){return false;}
        }
    
            
    if(
hook('denyaftermultiedit''', array($collection))) { return false; }

    return 
true;
    }

This article was last updated 30th November 2020 11:05 Europe/London time based on the source file dated 25th November 2020 10:35 Europe/London time.