Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

save_collection_resource_comment()

Description

Save a comment and/or rating for the instance of a resource in a collection.

Parameters

ColumnTypeDefaultDescription
$resource integer
$collection integer
$comment string
$rating integer

Return

boolean

Location

include/collections_functions.php lines 3254 to 3286

Definition

 
function save_collection_resource_comment($resource,$collection,$comment,$rating)
    {
    
# get data before update so that changes can be logged. 
    
$dataps_query("select comment,rating from collection_resource where resource= ? and collection= ?",
        [
        
'i'$resource,
        
'i'$collection
        
]
    );
    
$params = [];
    if(
$rating  != "")
        {
        
$sql '?';
        
$params = ['i'$rating];
        }
    else{
$sql 'null';}
    
ps_query("update collection_resource set rating= {$sql},comment= ?,use_as_theme_thumbnail= ? where resource= ? and collection= ?",
        
array_merge(
            
$params,
            [
            
's'$comment,
            
'i', (getval("use_as_theme_thumbnail","")==""?0:1),
            
'i'$resource,
            
'i'$collection
            
]
        )
    );
    
    
# log changes
    
if ($comment!=$data[0]['comment']){collection_log($collection,LOG_CODE_COLLECTION_ADDED_RESOURCE_COMMENT,$resource);}
    if (
$rating!=$data[0]['rating']){collection_log($collection,LOG_CODE_COLLECTION_ADDED_RESOURCE_RATING,$resource);}
    return 
true;
    }

This article was last updated 19th March 2024 03:05 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.