Collections functions
General functions
Render functions
Theme permission 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 6653 to 6677

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  ps_query("SELECT r.ref, r.modified FROM resource r WHERE r.ref IN (" ps_param_insert(count($resources)) . ") ORDER BY r.modified DESC",ps_param_fill($resources,"i"));
    
$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'",array("i",$lastmodified[0]["ref"]));
    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 2nd October 2022 17:35 Europe/London time based on the source file dated 30th September 2022 14:20 Europe/London time.