Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 3572 to 3642

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);
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 13th November 2024 14:05 Europe/London time.