Collections functions
Encryption functions
General 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 1665 to 1690

Definition

 
function add_smart_collection()
     {
    global 
$userref;

    
$search=getvalescaped("addsmartcollection","");
    
$restypes=getvalescaped("restypes","");
    if(
$restypes=="Global"){$restypes="";}
    
$archive getvalescaped('archive'0true);
    
$starsearch=getvalescaped("starsearch",0);
    
    
// more compact search strings should work with get_search_title
    
$searchstring=array();
    if (
$search!=""){$searchstring[]="search=$search";}
    if (
$restypes!=""){$searchstring[]="restypes=$restypes";}
    if (
$starsearch!=""){$searchstring[]="starsearch=$starsearch";}
    if (
$archive!=0){$searchstring[]="archive=$archive";}
    
$searchstring=implode("&",$searchstring);
    
    if (
$starsearch==""){$starsearch=0;}
    
$newcollection=create_collection($userref,get_search_title($searchstring),1);    

    
sql_query("insert into collection_savedsearch(collection,search,restypes,archive,starsearch) values ('$newcollection','" $search "','" $restypes "','" $archive "','".$starsearch."')");
    
$savedsearch=sql_insert_id();
    
sql_query("update collection set savedsearch='$savedsearch' where ref='$newcollection'"); 
    
set_user_collection($userref,$newcollection);
    }

This article was last updated 12th July 2020 01:35 Europe/London time based on the source file dated 9th July 2020 17:22 Europe/London time.