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

add_smart_collection()

Description

Greate a new smart collection using submitted values

Parameters

This function accepts no parameters.

Return

void

Location

include/collections_functions.php lines 2266 to 2311

Definition

 
function add_smart_collection()
{
    global 
$userref$search_all_workflow_states$lang;

    
$search getval("addsmartcollection""");
    
$restypes getval("restypes""");
    if (
$restypes == "Global") {
        
$restypes "";
    }
    
# archive can be a string of values
    
$archive getval('archive'0false);
    if (
$search_all_workflow_states && $archive == "") {
        
$archive 'all';
    }

    if (
$archive == "") {
        
$archive 0;
    }

    
// more compact search strings should work with get_search_title
    
$searchstring = array();
    if (
$search != "") {
        
$searchstring[] = "search=$search";
    }
    if (
$restypes != "") {
        
$searchstring[] = "restypes=$restypes";
    }
    if (
$archive !== 0) {
        if (
$archive === 'all') {
            
$archive_label $lang['all_workflow_states'];
        } else {
            
$archive_label $archive;
        }
        
$searchstring[] = "archive=$archive_label";
    }
    
$searchstring implode("&"$searchstring);

    
$newcollection create_collection($userrefget_search_title($searchstring), 1);

    
ps_query("insert into collection_savedsearch(collection,search,restypes,archive,starsearch) 
        values (?,?,?,?,?)"
, array("i",$newcollection,"s",$search,"s",$restypes,"s",$archive,"i",DEPRECATED_STARSEARCH));
    
$savedsearch sql_insert_id();
    
ps_query("update collection set savedsearch=? where ref=?", array("i",$savedsearch,"i",$newcollection));
    
set_user_collection($userref$newcollection);
    
refresh_collection_frame($newcollection);
}

This article was last updated 14th March 2025 12:35 Europe/London time based on the source file dated 11th March 2025 11:35 Europe/London time.