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

send_collection_feedback()

Description

Sends the feedback to the owner of the collection

Parameters

ColumnTypeDefaultDescription
$collection integer Collection ID
$comment string Comment text

Return

array|void

Location

include/collections_functions.php lines 3330 to 3405

Definition

 
function send_collection_feedback($collection,$comment)
    {
    global 
$applicationname,$lang,$userfullname,$userref,$k,$feedback_resource_select,$regex_email;
    global 
$userref;

    
$cinfo=get_collection($collection);    
    if(
$cinfo===false)
        {
        
error_alert($lang["error-collectionnotfound"]);
        exit();
        }
    
$user=get_user($cinfo["user"]);
    
$body=$lang["collectionfeedbackemail"] . "\n\n";

    if (isset(
$userfullname))
        {
        
$body.=$lang["user"] . ": " $userfullname "\n";
        }
    else
        {
        
# External user.
        
if (!preg_match ("/{$regex_email}/"getval("email",""))) {$errors[]=$lang["youremailaddress"] . ": " $lang["requiredfield"];return $errors;}
        
$body.=$lang["fullname"] . ": " getval("name","") . "\n";
        
$body.=$lang["email"] . ": " getval("email","") . "\n";
        }
    
$body.=$lang["message"] . ": " stripslashes(str_replace("\\r\\n","\n",trim($comment)));

    
$f=get_collection_comments($collection);
    for (
$n=0;$n<count($f);$n++)
        {
        
$body.="\n\n" $lang["resourceid"] . ": " $f[$n]["resource"];
        
$body.="\n" $lang["comment"] . ": " trim($f[$n]["comment"]);
        if (
is_numeric($f[$n]["rating"]))
            {
            
$body.="\n" $lang["rating"] . ": " substr("**********",0,$f[$n]["rating"]);
            }
        }

    if (
$feedback_resource_select)
        {
        
$body.="\n\n" $lang["selectedresources"] . ": ";
        
$file_list="";
        
$result=do_search("!collection" $collection);
        for (
$n=0;$n<count($result);$n++)
            {
            
$ref=$result[$n]["ref"];
            if (
getval("select_" $ref,"")!="")
                {
                global 
$filename_field;
                
$filename=get_data_by_field($ref,$filename_field);
                
$body.="\n" $ref " : " $filename;

                
# Append to a file list that is compatible with Adobe Lightroom
                
if ($file_list!="") {$file_list.=", ";}
                
$s=explode(".",$filename);
                
$file_list.=$s[0];
                }
            }
        
# Append Lightroom compatible summary.
        
$body.="\n\n" $lang["selectedresourceslightroom"] . "\n" $file_list;
        }
    
$cc=getval("email","");
    
get_config_option($user['ref'],'email_user_notifications'$send_email);
    
// Always send a mail for the feedback whatever the user preference, since the  feedback may be very long so can then refer to the CC'd email
    
if (filter_var($ccFILTER_VALIDATE_EMAIL))
        {
        
send_mail($user["email"],$applicationname ": " $lang["collectionfeedback"] . " - " $cinfo["name"],$body,"","","",null,"",$cc);
        }
    else
        {
        
send_mail($user["email"],$applicationname ": " $lang["collectionfeedback"] . " - " $cinfo["name"],$body);
        }

    
// Add a system notification message as well
    
message_add($user["ref"],$lang["collectionfeedback"] . " - " $cinfo["name"] . "<br />" $body,"",(isset($userref))?$userref:$user['ref'],MESSAGE_ENUM_NOTIFICATION_TYPE_SCREEN,60 60 *24 30);
    }

This article was last updated 19th March 2024 06:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.