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

render_upload_here_button()

Description

Render "Upload here" button.

This applies to search results that are either a special search "!collection" and/or consist of purely the following:
- Nodes
- Resource type
- Workflow (archive) state

For free text searches this SHOULD NOT work!

Parameters

ColumnTypeDefaultDescription
$search_params array
$return_params_only boolean false Exception to the rule! Rather than render, return the upload here params

Return

void

Location

include/render_functions.php lines 2767 to 2869

Definition

 
function render_upload_here_button(array $search_params$return_params_only false)
    {
    if(!(
checkperm('c') || checkperm('d')))
        {
        return;
        }

    if(!isset(
$search_params['search']) || !isset($search_params['restypes']) || !isset($search_params['archive']))
        {
        return;
        }

    if(
        isset(
$search_params['search'])
        && (
            
mb_substr($search_params['search'], 011) != '!collection'
            
&& empty(resolve_nodes_from_string($search_params['search']))
        )
    )
        {
        return;
        }

    
$upload_here_params = array();

    
$upload_endpoint 'pages/upload_plupload.php';
    if(!
$GLOBALS['upload_then_edit'])
        {
        
$upload_endpoint 'pages/edit.php';
        
$upload_here_params['ref'] = $GLOBALS['userref'];
        
$upload_here_params['uploader'] = $GLOBALS['top_nav_upload_type'];
        }

    
$upload_here_params['upload_here'] = true;
    
$upload_here_params['search'] = $search_params['search'];

    
// Special search !collection
    
if(mb_substr($search_params['search'], 011) == '!collection')
        {
        
$collection explode(' '$search_params['search']);
        
$collection str_replace('!collection'''$collection[0]);
        
$collection explode(','$collection);
        
$collection = (int) $collection[0];

        
//Check the user is able to upload to this collection before continuing
        
if(!collection_writeable($collection)) {return;}

        
$upload_here_params['collection_add'] = $collection;
        }

    
// If resource types is a list then always select the first resource type the user has access to
    
$resource_types explode(','$search_params['restypes']);
    foreach(
$resource_types as $resource_type)
        {
        if(!
checkperm("XU{$resource_type}"))
            {
            
$upload_here_params['resource_type'] = $resource_type;
            break;
            }
        }

    
// Archive can be a list (e.g from advanced search) so always select the first archive state user access to, 
    // favouring the Active one
    
$search_archive explode(','$search_params['archive']);
    
$default_workflow_state get_default_archive_state(0);
    if(
$default_workflow_state == 0)
        {
        
$upload_here_params['status'] = $default_workflow_state;
        
$search_archive = array();
        }
    
// Check remaining states
    
foreach($search_archive as $archive)
        {
        if(
$archive == '' || !is_numeric($archive))
            {
            continue;
            }

        if(
get_default_archive_state($archive) != $archive)
            {
            continue;
            }
        
        
$upload_here_params['status'] = $archive;
        break;
        }
    
// Last attempt to set the archive state
    
if(!isset($upload_here_params['status']))
        {
        
$upload_here_params['status'] = $default_workflow_state;
        }

    
// Option to return out just the upload params
    
if ($return_params_only)
        {
        return 
$upload_here_params;
        }
        
    
$upload_here_url generateURL("{$GLOBALS['baseurl']}/{$upload_endpoint}"$upload_here_params);
    
$attributes "onclick=\"CentralSpaceLoad('{$upload_here_url}');\"";

    return 
render_filter_bar_button($GLOBALS['lang']['upload_here'], $attributesUPLOAD_ICON);
    }

This article was last updated 23rd November 2020 19:05 Europe/London time based on the source file dated 13th November 2020 15:00 Europe/London time.