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

get_last_resource_edit()

Description

Obtain details of the last resource edited in the given collection.

Parameters

ColumnTypeDefaultDescription
$collection int Collection ID

Return

array | false Array containing details of last edit (resource ID, timestamp and username of user who performed edit)

Location

include/collections_functions.php lines 3423 to 3444

Definition

 
function get_last_resource_edit($collection)
    {
    if(!
is_numeric($collection))
        {
        return 
false;
        }
    
$plugin_last_resource_edit=hook('override_last_resource_edit');
    if(
$plugin_last_resource_edit===true){
        return 
false;
    }
    
$lastmodified  sql_query("SELECT r.ref, r.modified FROM collection_resource cr LEFT JOIN resource r ON cr.resource=r.ref WHERE cr.collection='" $collection "' ORDER BY r.modified DESC");
    
$lastuserdetails sql_query("SELECT u.username, u.fullname, rl.date FROM resource_log rl LEFT JOIN user u on u.ref=rl.user WHERE rl.resource ='" $lastmodified[0]["ref"] . "' AND rl.type='e'");
    if(
count($lastuserdetails) == 0)
        {
        return 
false;
        }
        
    
$timestamp max($lastuserdetails[0]["date"],$lastmodified[0]["modified"]);
        
    
$lastusername = (trim($lastuserdetails[0]["fullname"]) != "") ? $lastuserdetails[0]["fullname"] : $lastuserdetails[0]["username"];
    return array(
"ref" => $lastmodified[0]["ref"],"time" => $timestamp"user" => $lastusername);
    }

This article was last updated 8th July 2020 11:35 Europe/London time based on the source file dated 8th July 2020 10:09 Europe/London time.