Collections functions
General functions
Render functions
Theme permission functions
Resource functions

notify_resource_change()

Parameters

ColumnTypeDefaultDescription
$resource

Location

include/resource_functions.php lines 7846 to 7870

Definition

 
function notify_resource_change($resource)
    {
    
debug("notify_resource_change " $resource);
    global 
$notify_on_resource_change_days$baseurl;
    
// Check to see if we need to notify users of this change
    
if($notify_on_resource_change_days==|| !is_int($notify_on_resource_change_days))
        {
        return 
false;
        }

    
debug("notify_resource_change - checking for users that have downloaded this resource " $resource);
    
$download_users=ps_query("SELECT DISTINCT u.ref, u.email FROM resource_log rl LEFT JOIN user u ON rl.user=u.ref WHERE rl.type='d' AND rl.resource=? AND DATEDIFF(NOW(),date)<?",["i",$resource,"i",$notify_on_resource_change_days],"");
    
$message_users=array();
    if(
count($download_users)>0)
        {
        
$notifymessage = new ResourceSpaceUserNotification();
        
$notifymessage->set_subject("lang_notify_resource_change_email_subject");
        
$notifymessage->set_text("lang_notify_resource_change_email",["[days]","[url]"],[$notify_on_resource_change_days,$baseurl "/?r=" $resource]);
        
$notifymessage->preference "user_pref_resource_notifications";
        
$notifymessage->url $baseurl "/?r=" $resource;
        
$notifymessage->template 'notify_resource_change_email';
        
$notifymessage->templatevars = ["days"=>$notify_on_resource_change_days,"url"=>$baseurl "/?r=" $resource];
        
send_user_notification($download_users,$notifymessage);
        }
    }

This article was last updated 30th September 2022 17:35 Europe/London time based on the source file dated 30th September 2022 14:20 Europe/London time.