Collections functions
General functions
Render functions
Theme permission functions
Resource functions

render_edit_selected_btn()

Description

Renders the "Edit selected" button. This is using the special 'COLLECTION_TYPE_SELECTION' collection

Parameters

This function accepts no parameters.

Return

void

Location

include/render_functions.php lines 3500 to 3572

Definition

 
function render_edit_selected_btn()
    {
    global 
$baseurl_short$lang$USER_SELECTION_COLLECTION$restypes$archive;

    
$search "!collection{$USER_SELECTION_COLLECTION}";
    
# Editable_only=true (so returns editable resources only)
    
$editable_resources do_search($search$restypes"resourceid"$archive, -1"desc"false0falsefalse""falsefalsetruetrue);
    
# Editable_only=false (so returns resources whether editable or not)
    
$all_resources do_search($search$restypes"resourceid"$archive, -1"desc"false0falsefalse""falsefalsetruefalse);

    
# If there are no editable resources then don't render the edit selected button

    # Setup count of editable resources
    
$editable_resources_count 0;
    
$editable_resource_refs=array();
    if(
is_array($editable_resources))
        {
        
$editable_resources_count count($editable_resources);
        
$editable_resource_refs=array_column($editable_resources,"ref");
        }

    
# Setup count of editable and non-editable resources
    
$all_resources_count 0;
    
$all_resource_refs=array();
    if(
is_array($all_resources))
        {
        
$all_resources_count count($all_resources);
        
$all_resource_refs=array_column($all_resources,"ref");
        }

    
# If both counts are zero then there cannot be any editable resources, so no edit selected button
    
if($editable_resources_count == && $all_resources_count == 0)
        {
        return;
        }

    
# If not all selected resources are editable then the edit selected button may be inappropriate
    
if($editable_resources_count != $all_resources_count)
        {
        
# Counts differ meaning there are non-editable resources
        
$non_editable_resource_refs=array_diff($all_resource_refs,$editable_resource_refs);

        
# Is grant edit present for all non-editables?
        
foreach($non_editable_resource_refs as $non_editable_ref
            {
            if ( !
hook('customediteaccess','',array($non_editable_ref)) ) { return; }
            }

        
# All non_editables have grant edit
        # Don't return as edit button can be rendered
        
}

    
$batch_edit_url generateURL(
        
"{$baseurl_short}pages/edit.php",
        array(
            
"search"            =>  $search,
            
"collection"        =>  $USER_SELECTION_COLLECTION,
            
"restypes"          =>  $restypes,
            
"order_by"          =>  "resourceid",
            
"archive"           =>  $archive,
            
"sort"              =>  "desc",
            
"daylimit"          =>  "",
            
"editsearchresults" => "true",
            
"modal"             => "true",
        ));

    
$attributes  " id=\"EditSelectedResourcesBtn\"";
    
$attributes .= " onclick=\"ModalLoad('{$batch_edit_url}', true);\"";

    
render_filter_bar_button($lang["edit_selected"], $attributesICON_EDIT);

    return;
    }

This article was last updated 5th October 2022 04:35 Europe/London time based on the source file dated 22nd September 2022 16:20 Europe/London time.