Collections functions
General functions
Render functions
Theme permission 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 3138 to 3170

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 4th October 2022 12:05 Europe/London time based on the source file dated 4th October 2022 09:50 Europe/London time.