Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

notify_user_resources_approved()

Parameters

ColumnTypeDefaultDescription
$refs

Location

include/resource_functions.php lines 5320 to 5380

Definition

 
function notify_user_resources_approved($refs)
    {
    
// Send a notification mail to the user when resources have been approved
    
global $applicationname,$baseurl,$lang;    
    
debug("Emailing user notifications of resource approvals");    
    
$htmlbreak="\r\n";
    global 
$use_phpmailer,$userref,$templatevars;
    if (
$use_phpmailer){$htmlbreak="<br /><br />";}
    
$notifyusers=array();
    
    if(!
is_array($refs))
        {
        
$refs=array($refs);    
        }
    for (
$n=0;$n<count($refs);$n++)
        {
        
$ref=$refs[$n];
        
$contributed=sql_value("select created_by value from resource where ref='$ref'",0);
        if(
$contributed!=&& $contributed!=$userref)
            {
            if(!isset(
$notifyusers[$contributed])) // Add new array entry if not already present
                
{
                
$notifyusers[$contributed]=array();
                
$notifyusers[$contributed]["list"]="";
                
$notifyusers[$contributed]["resources"]=array();
                
$notifyusers[$contributed]["url"]=$baseurl "/pages/search.php?search=!contributions" $contributed "&archive=0";
                }        
            
$notifyusers[$contributed]["resources"][]=$ref;
            
$url=$baseurl "/?r=" $refs[$n];        
            if (
$use_phpmailer){$url="<a href=\"$url\">$url</a>";}
            
$notifyusers[$contributed]["list"].=$htmlbreak $url "\n\n";
            }        
        }
    foreach(
$notifyusers as $key=>$notifyuser)    
        {
        
$templatevars['list']=$notifyuser["list"];
        
$templatevars['url']=$notifyuser["url"];            
        
$message=$lang["userresourcesapproved"] . "\n\n"$templatevars['list'] . "\n\n" $lang["viewcontributedsubittedl"] . "\n\n" $notifyuser["url"];
        
$notificationmessage=$lang["userresourcesapproved"];
        
        
// Does the user want these messages?
        
get_config_option($key,'user_pref_resource_notifications'$send_message);          
        if(
$send_message==false){continue;}        
       
        
// Does the user want an email or notification?
        
get_config_option($key,'email_user_notifications'$send_email);    
        if(
$send_email)
            {
            
$notify_user=sql_value("select email value from user where ref='$key'","");
            if(
$notify_user!='')
                {
                
send_mail($notify_user,$applicationname ": " $lang["approved"],$message,"","","emailnotifyresourcesapproved",$templatevars);
                }
            }        
        else
            {
            global 
$userref;
            
message_add($key,$notificationmessage,$notifyuser["url"]);
            }
        }
    }

This article was last updated 16th July 2020 02:05 Europe/London time based on the source file dated 15th July 2020 16:26 Europe/London time.