Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

notify_user_resources_approved()

Parameters

ColumnTypeDefaultDescription
$refs

Location

include/resource_functions.php lines 5873 to 5933

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 26th January 2022 11:05 Europe/London time based on the source file dated 25th January 2022 13:30 Europe/London time.