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

compile_collection_actions()

Description

Helper function for render_actions(). Compiles actions that are normally valid for collections

Parameters

ColumnTypeDefaultDescription
$collection_data array Collection data
$top_actions boolean Set to true if actions are to be rendered in the search filter bar (above results)
$resource_data array array Resource data

Return

array

Location

include/collections_functions.php lines 2986 to 3519

Definition

 
function compile_collection_actions(array $collection_data$top_actions$resource_data=array())
    {
    global 
$baseurl_short$lang$k$userrequestmode$zipcommand$collection_download$use_zip_extension$archiver_path,
           
$manage_collections_contact_sheet_link$manage_collections_share_link$allow_share$enable_collection_copy,
           
$manage_collections_remove_link$userref$collection_purge$show_edit_all_link$result,
           
$edit_all_checkperms$preview_all$order_by$sort$archive$contact_sheet_link_on_collection_bar,
           
$show_searchitemsdiskusage$emptycollection$remove_resources_link_on_collection_bar$count_result,
           
$download_usage$home_dash$top_nav_upload_type$pagename$offset$col_order_by$find$default_sort,
           
$default_collection_sort$starsearch$restricted_share$hidden_collections$internal_share_access$search,
           
$usercollection$disable_geocoding$geo_locate_collection$collection_download_settings$contact_sheet,
           
$allow_resource_deletion$pagename,$upload_then_edit$enable_related_resources,$list$enable_themes;
               
    
#This is to properly render the actions drop down in the themes page    
    
if ( isset($collection_data['ref']) && $pagename!="collections" )
        {
        if(!
is_array($result))
            {
            
$result get_collection_resources_with_data($collection_data['ref']);
            }

        if((
'' == $k || $internal_share_access) && is_null($list))
            {
            
$list get_user_collections($userref);
            }

        
$count_result count($result);
        }
    
    if(isset(
$search) && substr($search011) == '!collection' && ($k == '' || $internal_share_access))
        { 
        
# Extract the collection number - this bit of code might be useful as a function
        
$search_collection explode(' '$search);
        
$search_collection str_replace('!collection'''$search_collection[0]);
        
$search_collection explode(','$search_collection); // just get the number
        
$search_collection escape_check($search_collection[0]);
        }

    
// Collection bar actions should always be a special search !collection[ID] (exceptions might arise but most of the 
    // time it should be handled using the special search). If top actions then search may include additional refinement inside the collection

    
if(isset($collection_data['ref']) && !$top_actions)
        {
        
$search "!collection{$collection_data['ref']}";
        }

    
$urlparams = array(
        
"search"      =>  $search,
        
"collection"  =>  (isset($collection_data['ref']) ? $collection_data['ref'] : ""),
        
"ref"         =>  (isset($collection_data['ref']) ? $collection_data['ref'] : ""),
        
"restypes"    =>  isset($_COOKIE['restypes']) ? $_COOKIE['restypes'] : "",
        
"starsearch"  =>  $starsearch,
        
"order_by"    =>  $order_by,
        
"col_order_by"=>  $col_order_by,
        
"sort"        =>  $sort,
        
"offset"      =>  $offset,
        
"find"        =>  $find,
        
"k"           =>  $k);
    
    
$options = array();
    
$o=0;

    if(empty(
$collection_data))
        {
        return 
$options;
        }
    
    if(empty(
$order_by))
        {
        
$order_by $default_collection_sort;
        }
    
    if(
$pagename == 'collection_manage'
        {
        
$min_access collection_min_access($collection_data['ref']);
        }
    else
        {
        
$min_access collection_min_access(empty($resource_data) ? $result $resource_data);
        }

    
// If resourceconnect plugin activated, need to consider if resource connect resources exist in the collection - if yes display view all resources link    
    
$count_resourceconnect_resources hook("countresult","", array($urlparams["collection"],0));
    
$count_resourceconnect_resources is_numeric($count_resourceconnect_resources) ? $count_resourceconnect_resources 0;

    
// View all resources
    
if(
        !
$top_actions // View all resources makes sense only from collection bar context
        
&& (
            (
$k=="" || $internal_share_access)
            && (isset(
$collection_data["c"]) && $collection_data["c"] > 0)
            || (
is_array($result) && count($result) > 0) || ($count_resourceconnect_resources 0)
        )
    )
        {
        
$tempurlparams = array(
            
'sort' => 'ASC',
            
'search' => (isset($collection_data['ref']) ? "!collection{$collection_data['ref']}$search),
        );

        
$data_attribute['url'] = generateURL($baseurl_short "pages/search.php",$urlparams,$tempurlparams);
        
$options[$o]['value']='view_all_resources_in_collection';
        
$options[$o]['label']=$lang['view_all_resources'];
        
$options[$o]['data_attr']=$data_attribute;
        
$options[$o]['category'] = ACTIONGROUP_RESOURCE;
        
$options[$o]['order_by'] = 10;
        
$o++;
        }
    
    
// Download option
    
if($min_access == )
        {
        if( 
$download_usage && ( isset($zipcommand) || $use_zip_extension || ( isset($archiver_path) && isset($collection_download_settings) ) ) && $collection_download && $count_result 0)
            {
            
$download_url generateURL($baseurl_short "pages/download_usage.php",$urlparams);
            
$data_attribute['url'] = generateURL($baseurl_short "pages/terms.php",$urlparams,array("url"=>$download_url));
            
$options[$o]['value']='download_collection';
            
$options[$o]['label']=$lang['action-download'];
            
$options[$o]['data_attr']=$data_attribute;
            
$options[$o]['category'] = ACTIONGROUP_RESOURCE;
            
$options[$o]['order_by'] = 20;
            
$o++;
            }
        else if( (isset(
$zipcommand) || $use_zip_extension || ( isset($archiver_path) && isset($collection_download_settings) ) ) && $collection_download && $count_result 0)
            {
            
$download_url generateURL($baseurl_short "pages/collection_download.php",$urlparams);
            
$data_attribute['url'] = generateURL($baseurl_short "pages/terms.php",$urlparams,array("url"=>$download_url));
            
$options[$o]['value']='download_collection';
            
$options[$o]['label']=$lang['action-download'];
            
$options[$o]['data_attr']=$data_attribute;
            
$options[$o]['category'] = ACTIONGROUP_RESOURCE;
            
$options[$o]['order_by'] = 20;
            
$o++;
            }
        }

    
// Upload to collection
    
if(allow_upload_to_collection($collection_data))
        {
        if(
$upload_then_edit)
            {
            
$data_attribute['url'] = generateURL($baseurl_short "pages/upload_plupload.php",array(),array("collection_add"=>$collection_data['ref']));
            }
        else
            {
            
$data_attribute['url'] = generateURL($baseurl_short "pages/edit.php",array(),array("uploader"=>$top_nav_upload_type,"ref"=>-$userref"collection_add"=>$collection_data['ref']));
            }

        
$options[$o]['value']='upload_collection';
        
$options[$o]['label']=$lang['action-upload-to-collection'];
        
$options[$o]['data_attr']=$data_attribute;
        
$options[$o]['category'] = ACTIONGROUP_RESOURCE;
        
$options[$o]['order_by'] = 30;
        
$o++;
        }
    

    
// Preview all
    
if((is_array($result) && count($result) != 0) && ($k=="" || $internal_share_access) && $preview_all)
        {
        
$data_attribute['url'] = generateURL($baseurl_short "pages/preview_all.php",$urlparams);
        
$options[$o]['value']='preview_all';
        
$options[$o]['label']=$lang['preview_all'];
        
$options[$o]['data_attr']=$data_attribute;
        
$options[$o]['category'] = ACTIONGROUP_RESOURCE;
        
$options[$o]['order_by'] = 40;
        
$o++;
        }

     
// Remove all resources from collection
     
if(!checkperm("b") && $count_result && ($k=="" || $internal_share_access) && isset($emptycollection) && $remove_resources_link_on_collection_bar && collection_writeable($collection_data['ref']))
     {
     
$data_attribute['url'] = generateURL($baseurl_short "pages/collections.php",$urlparams,array("emptycollection"=>$collection_data['ref'],"removeall"=>"true","ajax"=>"true","submitted"=>"removeall"));
     
$options[$o]['value']     = 'empty_collection';
     
$options[$o]['label']     = $lang['emptycollection'];
     
$options[$o]['data_attr'] = $data_attribute;
    
$options[$o]['category']  = ACTIONGROUP_RESOURCE;
    
$options[$o]['order_by'] = 50;
     
$o++;
     }
 
    if(!
collection_is_research_request($collection_data['ref']) || !checkperm('r'))
        {
        if(!
$top_actions && checkperm('s') && $pagename === 'collections')
            {
            
// Manage My Collections
            
$data_attribute['url'] = $baseurl_short 'pages/collection_manage.php';
            
$options[$o]['value']='manage_collections';
            
$options[$o]['label']=$lang['managemycollections'];
            
$options[$o]['data_attr']=$data_attribute;
            
$options[$o]['category'] = ACTIONGROUP_COLLECTION;
            
$options[$o]['order_by'] = 60;
            
$o++;

            
// Collection feedback
            
if(isset($collection_data['request_feedback']) && $collection_data['request_feedback'])
                {
                
$data_attribute['url'] = sprintf('%spages/collection_feedback.php?collection=%s&k=%s',
                    
$baseurl_short,
                    
urlencode($collection_data['ref']),
                    
urlencode($k)
                );
                
$options[$o]['value']='collection_feedback';
                
$options[$o]['label']=$lang['sendfeedback'];
                
$options[$o]['data_attr']=$data_attribute;
                
$options[$o]['category'] = ACTIONGROUP_RESOURCE;
                
$options[$o]['order_by'] = 70;
                
$o++;
                }
            }
        }
    else
        {
        
$research sql_value('SELECT ref value FROM research_request WHERE collection="' escape_check($collection_data['ref']) . '";'0);

        
// Manage research requests
        
$data_attribute['url'] = generateURL($baseurl_short "pages/team/team_research.php",$urlparams);
        
$options[$o]['value']='manage_research_requests';
        
$options[$o]['label']=$lang['manageresearchrequests'];
        
$options[$o]['data_attr']=$data_attribute;
        
$options[$o]['category'] = ACTIONGROUP_RESEARCH;
        
$options[$o]['order_by'] = 80;
        
$o Need help? Talk to our expert team     Book a call