Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video 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 6683 to 6707

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;
        }
        
    
$lastmodified  sql_query("SELECT r.ref, r.modified FROM resource r WHERE r.ref IN ('" implode("','",$resources). "') 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 30th November 2020 17:35 Europe/London time based on the source file dated 30th November 2020 11:55 Europe/London time.