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 3040 to 3078

Definition

 
function save_collection_resource_comment($resource$collection$comment$rating)
{
    
# get data before update so that changes can be logged.
    
$data ps_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""") == "" 1),
            
'i'$resource,
            
'i'$collection
            
]
        )
    );

    
# log changes
    
if ($comment != $data[0]['comment']) {
        
collection_log($collectionLOG_CODE_COLLECTION_ADDED_RESOURCE_COMMENT$resource);
    }
    if (
$rating != $data[0]['rating']) {
        
collection_log($collectionLOG_CODE_COLLECTION_ADDED_RESOURCE_RATING$resource);
    }
    return 
true;
}

This article was last updated 14th July 2025 16:35 Europe/London time based on the source file dated 7th July 2025 14:35 Europe/London time.