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

compile_search_actions()

Description

Compiles a list of actions based on the provided top actions and search parameters.

This function generates an array of options for various actions that can be performed
on search results, such as saving searches to collections, saving to dashboards,
exporting results, editing resources, and running reports. The available actions depend
on user permissions and specific conditions.

category, and order for sorting.

Parameters

ColumnTypeDefaultDescription
$top_actions bool Indicates whether to include top actions in the options.

Return

array An array of action options, each containing value, label, data attributes,

Location

include/search_functions.php lines 648 to 846

Definition

 
function compile_search_actions($top_actions)
    {
    
$options = array();
    
$o=0;

    global 
$baseurl,$baseurl_short$lang$k$search$restypes$order_by$archive$sort$daylimit$home_dash$url,
           
$allow_smart_collections$resources_count$show_searchitemsdiskusage$offset,
           
$collection$usercollection$internal_share_access$system_read_only$search_access;

    if(!isset(
$internal_share_access)){$internal_share_access=false;}

    
$urlparams = array(
        
"search"        =>  $search,
        
"collection"    =>  $collection,
        
"restypes"      =>  $restypes,
        
"order_by"      =>  $order_by,
        
"archive"       =>  $archive,
        
"access"        =>  $search_access,
        
"sort"          =>  $sort,
        
"daylimit"      =>  $daylimit,
        
"offset"        =>  $offset,
        
"k"             =>  $k
        
);

    
$omit_edit_all false;

    
#This is to stop duplicate "Edit all resources" caused on a collection search
    
if(isset($search) && substr($search011) == '!collection')
        {
        
$omit_edit_all true;
        }

    if(!
checkperm('b') && ($k == '' || $internal_share_access))
        {
        if(
$top_actions && $usercollection != $collection)
            {
            
$options[$o]['value']='save_search_to_collection';
            
$options[$o]['label']=$lang['savethissearchtocollection'];
            
$data_attribute['url'] = generateURL($baseurl_short "pages/collections.php"$urlparams, array("addsearch" => $search));
            
$options[$o]['data_attr']=$data_attribute;
            
$options[$o]['category']  = ACTIONGROUP_ADVANCED;
            
$options[$o]['order_by']  = 70;
            
$o++;
            }

        
#Home_dash is on, AND NOT Anonymous use, AND (Dash tile user (NOT with a managed dash) || Dash Tile Admin)
        
if($top_actions && $home_dash && checkPermission_dashcreate())
            {
            
$option_name 'save_search_to_dash';
            
$extraparams = array();
            
$extraparams["create"] = "true";
            
$extraparams["tltype"] = "srch";
            
$extraparams["freetext"] = "true";

            
$data_attribute = array(
                
'url'  => generateURL($baseurl_short "pages/dash_tile.php"$urlparams$extraparams),
                
'link' => str_replace($baseurl'', (string) $url)
            );

            if(
substr($search011) == '!collection')
                {
                
$option_name 'save_collection_to_dash';
                
$extraparams["promoted_resource"] = "true";
                
$extraparams["all_users"] = "1";
                
$extraparams["link"] = $baseurl_short "pages/search.php?search=!collection" $collection;
                
$data_attribute['url'] = generateURL($baseurl_short "pages/dash_tile.php"$urlparams$extraparams);
                }

            
$options[$o]['value'] = $option_name;
            
$options[$o]['label'] = $lang['savethissearchtodash'];
            
$options[$o]['data_attr'] = $data_attribute;
            
$options[$o]['category']  = ACTIONGROUP_SHARE;
            
$options[$o]['order_by']  = 170;
            
$o++;
            }

        
// Save search as Smart Collections
        
if($top_actions && $allow_smart_collections && substr($search011) != '!collection')
            {
            
$extra_tag_attributes sprintf('
                    data-url="%spages/collections.php?addsmartcollection=%s&restypes=%s&archive=%s"
                '
,
                
$baseurl_short,
                
urlencode((string) $search),
                
urlencode((string) $restypes),
                
urlencode((string) $archive)
            );

            
$options[$o]['value']='save_search_smart_collection';
            
$options[$o]['label']=$lang['savesearchassmartcollection'];
            
$options[$o]['data_attr']=array();
            
$options[$o]['extra_tag_attributes']=$extra_tag_attributes;
            
$options[$o]['category']  = ACTIONGROUP_COLLECTION;
            
$options[$o]['order_by']  = 170;
            
$o++;
            }

        if(
$resources_count != && !$system_read_only)
            {
                
$extra_tag_attributes sprintf('
                        data-url="%spages/collections.php?addsearch=%s&restypes=%s&order_by=%s&sort=%s&archive=%s&mode=resources&daylimit=%s"
                    '
,
                    
$baseurl_short,
                    
urlencode((string) $search),
                    
urlencode((string) $restypes),
                    
urlencode((string) $order_by),
                    
urlencode((string) $sort),
                    
urlencode((string) $archive),
                    
urlencode((string) $daylimit)
                );

                
$options[$o]['value']='save_search_items_to_collection';
                
$options[$o]['label']=$lang['savesearchitemstocollection'];
                
$options[$o]['data_attr']=array();
                
$options[$o]['extra_tag_attributes']=$extra_tag_attributes;
                
$options[$o]['category']  = ACTIONGROUP_COLLECTION;
                
$options[$o]['order_by']  = 170;
                
$o++;


            if(
!= $resources_count && $show_searchitemsdiskusage)
                {
                
$extra_tag_attributes sprintf('
                        data-url="%spages/search_disk_usage.php?search=%s&restypes=%s&offset=%s&order_by=%s&sort=%s&archive=%s&daylimit=%s&k=%s"
                    '
,
                    
$baseurl_short,
                    
urlencode((string) $search),
                    
urlencode((string) $restypes),
                    
urlencode((string) $offset),
                    
urlencode((string) $order_by),
                    
urlencode((string) $sort),
                    
urlencode((string) $archive),
                    
urlencode((string) $daylimit),
                    
urlencode((string) $k)
                );

                
$options[$o]['value']='search_items_disk_usage';
                
$options[$o]['label']=$lang['searchitemsdiskusage'];
                
$options[$o]['data_attr']=array();
                
$options[$o]['extra_tag_attributes']=$extra_tag_attributes;
                
$options[$o]['category']  = ACTIONGROUP_ADVANCED;
                
$options[$o]['order_by']  = 300;
                
$o++;
                }
            }
        }

    
// If all resources are editable, display an edit all link
    
if($top_actions && !$omit_edit_all)
        {
        
$data_attribute['url'] = generateURL($baseurl_short "pages/edit.php"$urlparams, array("editsearchresults" => "true""search_access" => $search_access));
        
$options[$o]['value']='editsearchresults';
        
$options[$o]['label']=$lang['edit_all_resources'];
        
$options[$o]['data_attr']=$data_attribute;
        
$options[$o]['category'] = ACTIONGROUP_EDIT;
        
$options[$o]['order_by']  = 130;
        
$o++;
        }

    if(
$top_actions && ($k == '' || $internal_share_access))
        {
        
$options[$o]['value']            = 'csv_export_results_metadata';
        
$options[$o]['label']            = $lang['csvExportResultsMetadata'];
        
$options[$o]['data_attr']['url'] = sprintf('%spages/csv_export_results_metadata.php?search=%s&restypes=%s&order_by=%s&archive=%s&sort=%s&access=%s',
            
$baseurl_short,
            
urlencode((string) $search),
            
urlencode((string) $restypes),
            
urlencode((string) $order_by),
            
urlencode((string) $archive),
            
urlencode((string) $sort),
            
urlencode((string) $search_access)
        );
        
$options[$o]['category'] = ACTIONGROUP_ADVANCED;
        
$options[$o]['order_by']  = 290;
        
$o++;
        }

    
// Run report on search results
    
if($top_actions && checkperm('t'))
        {
        
$backurl_to_search generateURL("{$baseurl_short}pages/search.php"get_search_params(), $urlparams);

        
$options[$o]['value'] = 'run_report_on_search_results';
        
$options[$o]['label'] = $lang['run_report_on_search_results'];
        
$options[$o]['data_attr']['url'] = generateURL("{$baseurl_short}pages/team/team_report.php", ['backurl' => $backurl_to_search]);
        
$options[$o]['category'] = ACTIONGROUP_ADVANCED;
        
$options[$o]['order_by']  = 280;
        
$o++;
        }

    
// Add extra search actions or modify existing options through plugins
    
$modified_options hook('render_search_actions_add_option','',array($options$urlparams));
    if(
$top_actions && !empty($modified_options))
        {
        
$options=$modified_options;
        }

    return 
$options;
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 27th November 2024 09:40 Europe/London time.