Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video 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

void

Location

include/collections_functions.php lines 2452 to 2530

Definition

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

    
$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 ($feedback_email_required && !preg_match ("/${regex_email}/"getvalescaped("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);
        }

    if(!
$send_email)
        {
        
// Add a system notification message as well if the user has not 'opted out'
        
global $userref;
        
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 30th November 2020 13:35 Europe/London time based on the source file dated 25th November 2020 10:35 Europe/London time.