Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource 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 2479 to 2505

Definition

 
function add_smart_collection()
    {
    global 
$userref;

    
$search=getval("addsmartcollection","");
    
$restypes=getval("restypes","");
    if(
$restypes=="Global"){$restypes="";}
    
# archive can be a string of values
    
$archive getval('archive'0false);
    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){$searchstring[]="archive=$archive";}
    
$searchstring=implode("&",$searchstring);
    
    
$newcollection=create_collection($userref,get_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 19th March 2024 10:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.