Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

notify_resource_change()

Parameters

ColumnTypeDefaultDescription
$resource

Location

include/resource_functions.php lines 7824 to 7870

Definition

 
    
function notify_resource_change($resource)
    {
    
debug("notify_resource_change " $resource);
    global 
$notify_on_resource_change_days;
    
// 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=sql_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=$resource and datediff(now(),date)<'$notify_on_resource_change_days'","");
    
$message_users=array();
    if(
count($download_users)>0)
        {
        global 
$applicationname$lang$baseurl;
        foreach (
$download_users as $download_user)
            {
            if(
$download_user['ref']==""){continue;}
            
get_config_option($download_user['ref'],'user_pref_resource_notifications'$send_message);       
            if(
$send_message==false){continue;}     
            
            
get_config_option($download_user['ref'],'email_user_notifications'$send_email);
            
get_config_option($download_user['ref'],'email_and_user_notifications'$send_email_and_notify);
            if(
$send_email_and_notify)
                {
                
$message_users[]=$download_user["ref"];
                if(
$download_user["email"]!="")
                    {
                    
send_mail($download_user['email'],$applicationname ": " $lang["notify_resource_change_email_subject"],str_replace(array("[days]","[url]"),array($notify_on_resource_change_days,$baseurl "/?r=" $resource),$lang["notify_resource_change_email"]),"","",'notify_resource_change_email',array("days"=>$notify_on_resource_change_days,"url"=>$baseurl "/?r=" $resource));
                    }
                }
            else if(
$send_email && $download_user["email"]!="")
                {
                
send_mail($download_user['email'],$applicationname ": " $lang["notify_resource_change_email_subject"],str_replace(array("[days]","[url]"),array($notify_on_resource_change_days,$baseurl "/?r=" $resource),$lang["notify_resource_change_email"]),"","",'notify_resource_change_email',array("days"=>$notify_on_resource_change_days,"url"=>$baseurl "/?r=" $resource));
                }
            else
                {
                
$message_users[]=$download_user["ref"];
                }
            }
        if (
count($message_users)>0)
            {
            
message_add($message_users,str_replace(array("[days]","[url]"),array($notify_on_resource_change_days,$baseurl "/?r=" $resource),$lang["notify_resource_change_notification"]),$baseurl "/?r=" $resource);
            }
        }
    }

This article was last updated 30th November 2020 11:05 Europe/London time based on the source file dated 27th November 2020 14:50 Europe/London time.