Collections functions
General functions
Render functions
Theme permission 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 2406 to 2430

Definition

 
function add_smart_collection()
     {
    global 
$userref;

    
$search=getval("addsmartcollection","");
    
$restypes=getval("restypes","");
    if(
$restypes=="Global"){$restypes="";}
    
$archive getval('archive'0true);
    
    
// 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,"i",$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 2nd October 2022 17:35 Europe/London time based on the source file dated 22nd September 2022 11:00 Europe/London time.