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

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 7404 to 7439

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 4th December 2024 09:05 Europe/London time based on the source file dated 28th November 2024 12:10 Europe/London time.