コード例 #1
0
function email_resource_request($ref,$details)
	{
	# E-mails a basic resource request for a single resource (posted) to the team
	# (not a managed request)
	
	global $applicationname,$email_from,$baseurl,$email_notify,$username,$useremail,$lang,$request_senduserupdates;
	
	$templatevars['username']=$username . " (" . $useremail . ")";
	$templatevars['url']=$baseurl."/?r=".$ref;
	
	$htmlbreak="";
	global $use_phpmailer;
	if ($use_phpmailer){$htmlbreak="<br><br>";}
	
	$list="";
	reset ($_POST);
	foreach ($_POST as $key=>$value)
		{
		if (strpos($key,"_label")!==false)
			{
			# Add custom field	
			$data="";
			$data=$_POST[str_replace("_label","",$key)];
			$list.=$htmlbreak. $value . ": " . $data."\n";
			}
		}
	$list.=$htmlbreak;		
	$templatevars['list']=$list;

	$templatevars['details']=stripslashes($details);
	if ($templatevars['details']!=""){$adddetails=$lang["requestreason"] . ": " . newlines($templatevars['details'])."\n\n";} else {return false;}
	
	# Add custom fields
	$c="";
	global $custom_request_fields,$custom_request_required;
	if (isset($custom_request_fields))
		{
		$custom=explode(",",$custom_request_fields);
	
		# Required fields?
		if (isset($custom_request_required)) {$required=explode(",",$custom_request_required);}
	
		for ($n=0;$n<count($custom);$n++)
			{
			if (isset($required) && in_array($custom[$n],$required) && getval("custom" . $n,"")=="")
				{
				return false; # Required field was not set.
				}
			
			$c.=i18n_get_translated($custom[$n]) . ": " . getval("custom" . $n,"") . "\n\n";
			}
		}
	
	$message=$lang["username"] . ": " . $username . " (" . $useremail . ")\n".$templatevars['list']."\n".$adddetails. $c . $lang["clicktoviewresource"] . "\n\n". $templatevars['url'];

	$userconfirmmessage = $lang["requestsenttext"];
	send_mail($email_notify,$applicationname . ": " . $lang["requestresource"] . " - $ref",$message,$useremail,$useremail,"emailresourcerequest",$templatevars);
	if ($request_senduserupdates){send_mail($useremail,$applicationname . ": " . $lang["requestsent"] . " - $ref",$userconfirmmessage,$email_from);}	
	
	# Increment the request counter
	sql_query("update resource set request_count=request_count+1 where ref='$ref'");
	}
コード例 #2
0
function email_resource_request($ref, $details)
{
    # E-mails a basic resource request for a single resource (posted) to the team
    # (not a managed request)
    global $applicationname, $email_from, $baseurl, $email_notify, $username, $useremail, $userref, $lang, $request_senduserupdates, $watermark, $filename_field, $view_title_field, $access, $resource_type_request_emails;
    $resourcedata = get_resource_data($ref);
    $templatevars['thumbnail'] = get_resource_path($ref, true, "thm", false, "jpg", $scramble = -1, $page = 1, $watermark ? $access == 1 ? true : false : false);
    if (!file_exists($templatevars['thumbnail'])) {
        $templatevars['thumbnail'] = "../gfx/" . get_nopreview_icon($resourcedata["resource_type"], $resourcedata["file_extension"], false);
    }
    if (isset($filename_field)) {
        $templatevars["filename"] = $lang["fieldtitle-original_filename"] . ": " . get_data_by_field($ref, $filename_field);
    }
    if (isset($resourcedata["field" . $view_title_field])) {
        $templatevars["title"] = $resourcedata["field" . $view_title_field];
    }
    $templatevars['username'] = $username . " (" . $useremail . ")";
    $templatevars['formemail'] = getval("email", "");
    $templatevars['url'] = $baseurl . "/?r=" . $ref;
    $templatevars["requesturl"] = $templatevars['url'];
    $userdata = get_user($userref);
    $templatevars["fullname"] = $userdata["fullname"];
    $htmlbreak = "";
    global $use_phpmailer;
    if ($use_phpmailer) {
        $htmlbreak = "<br><br>";
    }
    $list = "";
    reset($_POST);
    foreach ($_POST as $key => $value) {
        if (strpos($key, "_label") !== false) {
            # Add custom field
            $data = "";
            $data = $_POST[str_replace("_label", "", $key)];
            $list .= $htmlbreak . $value . ": " . $data . "\n";
        }
    }
    $list .= $htmlbreak;
    $templatevars['list'] = $list;
    $templatevars['details'] = stripslashes($details);
    if ($templatevars['details'] != "") {
        $adddetails = $lang["requestreason"] . ": " . newlines($templatevars['details']) . "\n\n";
    } else {
        return false;
    }
    # Add custom fields
    $c = "";
    global $custom_request_fields, $custom_request_required;
    if (isset($custom_request_fields)) {
        $custom = explode(",", $custom_request_fields);
        # Required fields?
        if (isset($custom_request_required)) {
            $required = explode(",", $custom_request_required);
        }
        for ($n = 0; $n < count($custom); $n++) {
            if (isset($required) && in_array($custom[$n], $required) && getval("custom" . $n, "") == "") {
                return false;
                # Required field was not set.
            }
            $c .= i18n_get_translated($custom[$n]) . ": " . getval("custom" . $n, "") . "\n\n";
        }
    }
    $templatevars["requestreason"] = $lang["requestreason"] . ": " . $templatevars['details'] . $c . "";
    $message = $lang["user_made_request"] . "<br /><br />";
    $message .= isset($username) ? $lang["username"] . ": " . $username . " (" . $useremail . ")<br />" : "";
    $message .= !empty($templatevars["formemail"]) ? $lang["email"] . ":" . $templatevars["formemail"] . "<br />" : "";
    $message .= $adddetails . $c . "<br /><br />" . $lang["clicktoviewresource"] . "<br />" . $templatevars['url'];
    # Check if alternative request email notification address is set
    $admin_notify_email = $email_notify;
    if (isset($resource_type_request_emails)) {
        if (isset($resource_type_request_emails[$resourcedata["resource_type"]])) {
            $admin_notify_email = $resource_type_request_emails[$resourcedata["resource_type"]];
        }
    }
    send_mail($admin_notify_email, $applicationname . ": " . $lang["requestresource"] . " - {$ref}", $message, $useremail, $useremail, "emailresourcerequest", $templatevars);
    if ($request_senduserupdates) {
        $sender = !empty($useremail) ? $useremail : !empty($templatevars["formemail"]) ? $templatevars["formemail"] : "";
        $k = getval("k", "") != "" ? "&k=" . getval("k", "") : "";
        $userconfirmmessage = $lang["requestsenttext"] . "<br /><br />" . $lang["requestreason"] . ": " . $templatevars['details'] . $c . "<br /><br />" . $lang["clicktoviewresource"] . "\n{$baseurl}/?r={$ref}" . $k;
        if ($sender != "") {
            send_mail($sender, $applicationname . ": " . $lang["requestsent"] . " - {$ref}", $userconfirmmessage, $email_from, $email_notify, "emailuserresourcerequest", $templatevars);
        }
    }
    # Increment the request counter
    sql_query("update resource set request_count=request_count+1 where ref='{$ref}'");
}