Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 3026 to 3064

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 15th February 2025 20:35 Europe/London time based on the source file dated 13th February 2025 10:30 Europe/London time.