Ver Fonte

! Moved the personal message notification email to EmailTemplates
added few more options (with and without body, with and without the list of members that will receive the PM)

emanuele há 13 anos atrás
pai
commit
06694cecc6

+ 29 - 8
Sources/Subs-Post.php

@@ -1092,9 +1092,12 @@ function sendpm($recipients, $subject, $message, $store_outbox = false, $from =
 		);
 
 		$insertRows = array();
+		$to_list = array();
 		foreach ($all_to as $to)
 		{
 			$insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1);
+			if (!in_array($to, $recipients['bcc']))
+				$to_list[] = $to;
 		}
 
 		$smcFunc['db_insert']('insert',
@@ -1116,18 +1119,36 @@ function sendpm($recipients, $subject, $message, $store_outbox = false, $from =
 	else
 		$message = '';
 
-	foreach ($notifications as $lang => $notification_list)
+	$to_names = array();
+	if (count($to_list) > 1)
 	{
-		// Make sure to use the right language.
-		loadLanguage('index+PersonalMessage', $lang, false);
+		$request = $smcFunc['db_query']('', '
+			SELECT real_name
+			FROM {db_prefix}members
+			WHERE id_member IN ({array_int:to_members})',
+			array(
+				'to_members' => $to_list,
+			)
+		);
+		while ($row = $smcFunc['db_fetch_assoc']($request))
+			$to_names[] = un_htmlspecialchars($row['real_name']);
+		$smcFunc['db_free_result']($request);
+	}
+	$replacements = array(
+		'SUBJECT' => $subject,
+		'MESSAGE' => $message,
+		'SENDER' => un_htmlspecialchars($from['name']),
+		'REPLYLINK' => $scripturl . '?action=pm;sa=send;f=inbox;pmsg=' . $id_pm . ';quote;u=' . $from['id'],
+		'TOLIST' => implode(', ', $to_names),
+	);
+	$email_template = 'new_pm' . (empty($modSettings['disallow_sendBody']) ? '_body' : '') . (!empty($to_names) ? '_tolist' : '');
 
-		// Replace the right things in the message strings.
-		$mailsubject = str_replace(array('SUBJECT', 'SENDER'), array($subject, un_htmlspecialchars($from['name'])), $txt['new_pm_subject']);
-		$mailmessage = str_replace(array('SUBJECT', 'MESSAGE', 'SENDER'), array($subject, $message, un_htmlspecialchars($from['name'])), $txt['pm_email'] . (empty($modSettings['disallow_sendBody']) ? $txt['pm_email_body'] : ''));
-		$mailmessage .= "\n\n" . $txt['instant_reply'] . ' ' . $scripturl . '?action=pm;sa=send;f=inbox;pmsg=' . $id_pm . ';quote;u=' . $from['id'];
+	foreach ($notifications as $lang => $notification_list)
+	{
+		$mail = loadEmailTemplate($email_template, $replacements, $lang);
 
 		// Off the notification email goes!
-		sendmail($notification_list, $mailsubject, $mailmessage, null, 'p' . $id_pm, false, 2, null, true);
+		sendmail($notification_list, $mail['subject'], $mail['body'], null, 'p' . $id_pm, false, 2, null, true);
 	}
 
 	// Back to what we were on before!

+ 68 - 0
Themes/default/languages/EmailTemplates.english.php

@@ -922,6 +922,74 @@ The following error occurred when processing a paid subscription
 
 {REGARDS}';
 
+/**
+	@additional_params: new_pm
+		SUBJECT: The personal message subject.
+		SENDER:  The user name for the member sending the personal message.
+		REPLYLINK:  The link to directly access the reply page.
+	@description: A notification email sent to the receivers of a personal message
+*/
+$txt['new_pm_subject'] = 'New Personal Message: {SUBJECT}';
+$txt['new_pm_body'] = 'You have just been sent a personal message by {SENDER} on {FORUMNAME}
+
+IMPORTANT: Remember, this is just a notification. Please do not reply to this email.
+
+Reply to this Personal Message here: {REPLYLINK}';
+
+/**
+	@additional_params: new_pm_body
+		SUBJECT: The personal message subject.
+		SENDER:  The user name for the member sending the personal message.
+		MESSAGE:  The text of the personal message.
+		REPLYLINK:  The link to directly access the reply page.
+	@description: A notification email sent to the receivers of a personal message
+*/
+$txt['new_pm_body_subject'] = 'New Personal Message: {SUBJECT}';
+$txt['new_pm_body_body'] = 'You have just been sent a personal message by {SENDER} on {FORUMNAME}
+
+IMPORTANT: Remember, this is just a notification. Please do not reply to this email.
+
+The message they sent you was:
+
+{MESSAGE}
+
+Reply to this Personal Message here: {REPLYLINK}';
+
+/**
+	@additional_params: new_pm_tolist
+		SUBJECT: The personal message subject.
+		SENDER:  The user name for the member sending the personal message.
+		REPLYLINK:  The link to directly access the reply page.
+		TOLIST:  The list of users that will receive the personal message.
+	@description: A notification email sent to the receivers of a personal message
+*/
+$txt['new_pm_tolist_subject'] = 'New Personal Message: {SUBJECT}';
+$txt['new_pm_tolist_body'] = 'You and {TOLIST} have just been sent a personal message by {SENDER} on {FORUMNAME}
+
+IMPORTANT: Remember, this is just a notification. Please do not reply to this email.
+
+Reply to this Personal Message (to the sender only) here: {REPLYLINK}';
+
+/**
+	@additional_params: new_pm_body_tolist
+		SUBJECT: The personal message subject.
+		SENDER:  The user name for the member sending the personal message.
+		MESSAGE:  The text of the personal message.
+		REPLYLINK:  The link to directly access the reply page.
+		TOLIST:  The list of users that will receive the personal message.
+	@description: A notification email sent to the receivers of a personal message
+*/
+$txt['new_pm_body_tolist_subject'] = 'New Personal Message: {SUBJECT}';
+$txt['new_pm_body_tolist_body'] = 'You and {TOLIST} have just been sent a personal message by {SENDER} on {FORUMNAME}
+
+IMPORTANT: Remember, this is just a notification. Please do not reply to this email.
+
+The message they sent you was:
+
+{MESSAGE}
+
+Reply to this Personal Message (to the sender only) here: {REPLYLINK}';
+
 /**
 	@additional_params: happy_birthday
 		REALNAME: The real (display) name of the person receiving the birthday message.

+ 0 - 8
Themes/default/languages/PersonalMessage.english.php

@@ -19,14 +19,6 @@ $txt['delete_message'] = 'Delete Messages';
 $txt['delete_all'] = 'Delete all messages in your PMBOX';
 $txt['delete_all_confirm'] = 'Are you sure you want to delete all messages?';
 $txt['recipient'] = 'Recipient';
-// Don't translate the word "SUBJECT" here, as it is used to format the message - use numeric entities as well.
-$txt['new_pm_subject'] = 'New Personal Message: SUBJECT';
-// Don't translate SENDER or MESSAGE in this language string; they are replaced with the corresponding text - use numeric entities too.
-$txt['pm_email'] = 'You have just been sent a personal message by SENDER on ' . $context['forum_name'] . '.' . "\n\n" . 'IMPORTANT: Remember, this is just a notification. Please do not reply to this email.';
-$txt['pm_email_body'] = "\n\n" . 'The message they sent you was:' . "\n\n" . 'MESSAGE';
-$txt['pm_multiple'] = '(multiple recipients: \'name1, name2\')';
-// Use numeric entities in the below string.
-$txt['instant_reply'] = 'Reply to this Personal Message here:';
 
 $txt['delete_selected_confirm'] = 'Are you sure you want to delete all selected personal messages?';