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_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|array

Location

include/render_functions.php lines 3176 to 3291

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_batch.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 (isset(
$search_params['advsearch']) && $search_params['advsearch'] == 'true')
        {
        
$upload_here_params['advsearch'] = 'true';
        }

    
// 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']);
    
$use_default false;

    if (
count($search_archive) == && $search_archive[0] == "")
        {
        
$search_archive = array();
        
$use_default true;
        }

    
// Check access to Active state
    
if(in_array(0$search_archive) && checkperm("e0"))
        {
        
$upload_here_params['status'] = 0;
        
$search_archive = array();
        }
    
// Check remaining states
    
foreach($search_archive as $archive)
        {
        if(
$archive == '' || !is_numeric($archive))
            {
            continue;
            }

        if(
checkperm("e{$archive}"))
            {
            
$upload_here_params['status'] = $archive;
            
$search_archive = array();
            break;
            }
        }

    if (
count($search_archive) != || $use_default)
        {
        
// None of the supplied archive states were accessible with e permission so use default.
        
$upload_here_params['status'] = get_default_archive_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}');\"";

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

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.