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

get_last_resource_edit_array()

Description

Obtain details of the last resource edited in the given array of resource ids

Parameters

ColumnTypeDefaultDescription
$resources array array Array of resource IDs

Return

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

Location

include/resource_functions.php lines 7163 to 7198

Definition

 
function get_last_resource_edit_array($resources = array())
    {
    if(
count($resources) == 0)
        {
        return 
false;
        }

    
$plugin_last_resource_edit hook('override_last_resource_edit_array');
    if(
$plugin_last_resource_edit === true)
        {
        return 
false;
        }

    
$chunks array_chunk($resources,SYSTEM_DATABASE_IDS_CHUNK_SIZE);
    foreach(
$chunks as $chunk)
        {
        
$rows  ps_query(
            
"SELECT r.ref, r.modified 
                FROM resource r 
            WHERE r.ref IN (" 
ps_param_insert(count($chunk)) . ") 
            ORDER BY r.modified DESC"
,
            
ps_param_fill($chunk,"i")
        );
        if (!isset(
$lastmodified) || $rows[0]["modified"]>$lastmodified["modified"]){$lastmodified=$rows[0];}
        }
    
$lastuserdetails ps_query("SELECT u.username, u.fullname, rl.date FROM resource_log rl LEFT JOIN user u on u.ref=rl.user WHERE rl.resource = ? AND rl.type='e' ORDER BY rl.date DESC",array("i",$lastmodified["ref"]));
    if(
count($lastuserdetails) == 0)
        {
        return 
false;
        }

    
$timestamp max($lastuserdetails[0]["date"],$lastmodified["modified"]);

    
$lastusername = (trim((string)$lastuserdetails[0]["fullname"]) != "") ? $lastuserdetails[0]["fullname"] : $lastuserdetails[0]["username"];
    return array(
"ref" => $lastmodified["ref"],"time" => $timestamp"user" => $lastusername);
    }

This article was last updated 19th March 2024 07:35 Europe/London time based on the source file dated 11th March 2024 14:25 Europe/London time.