Ver código fonte

Most likely complete backward compatible rewriting completed [Bug 3983]

emanuele 13 anos atrás
pai
commit
43a7e709f2

+ 21 - 0
Sources/Load.php

@@ -2083,6 +2083,27 @@ function loadLanguage($template_name, $lang = '', $fatal = true, $force_reload =
 			log_error(sprintf($txt['theme_language_error'], $template_name . '.' . $lang, 'template'));
 			break;
 		}
+
+		// For the sake of backward compatibility
+		if (!empty($txt['emails']))
+		{
+			foreach ($txt['emails'] as $key => $value)
+			{
+				$txt[$key . '_subject'] = $value['subject'];
+				$txt[$key . '_body'] = $value['body'];
+			}
+			$txt['emails'] = array();
+		}
+		if (!empty($birthdayEmails))
+		{
+			foreach ($birthdayEmails as $key => $value)
+			{
+				$txtBirthdayEmails[$key . '_subject'] = $value['subject'];
+				$txtBirthdayEmails[$key . '_body'] = $value['body'];
+				$txtBirthdayEmails[$key . '_author'] = $value['author'];
+			}
+			$birthdayEmails = array();
+		}
 	}
 
 	// Keep track of what we're up to soldier.

+ 15 - 8
Sources/ManageMail.php

@@ -278,15 +278,22 @@ function list_getMailQueueSize()
  */
 function ModifyMailSettings($return_config = false)
 {
-	global $txt, $scripturl, $context, $settings, $birthdayEmails, $modSettings;
+	global $txt, $scripturl, $context, $settings, $modSettings, $txtBirthdayEmails;
 
 	loadLanguage('EmailTemplates');
 
-	$body = $birthdayEmails[empty($modSettings['birthday_email']) ? 'happy_birthday' : $modSettings['birthday_email']]['body'];
-	$subject = $birthdayEmails[empty($modSettings['birthday_email']) ? 'happy_birthday' : $modSettings['birthday_email']]['subject'];
+	$body = $txtBirthdayEmails[(empty($modSettings['birthday_email']) ? 'happy_birthday' : $modSettings['birthday_email']) . '_body'];
+	$subject = $txtBirthdayEmails[(empty($modSettings['birthday_email']) ? 'happy_birthday' : $modSettings['birthday_email']) . '_subject'];
 
 	$emails = array();
-	foreach ($birthdayEmails as $index => $dummy)
+	$processedBirthdayEmails = array();
+	foreach ($txtBirthdayEmails as $key => $value)
+	{
+		$index = substr($key, 0, strrpos($key, '_'));
+		$element = substr($key, strrpos($key, '_') + 1);
+		$processedBirthdayEmails[$index][$element] = $value;
+	}
+	foreach ($processedBirthdayEmails as $index => $dummy)
 		$emails[$index] = $index;
 
 	$config_vars = array(
@@ -302,8 +309,8 @@ function ModifyMailSettings($return_config = false)
 			array('text', 'smtp_username'),
 			array('password', 'smtp_password'),
 		'',
-			array('select', 'birthday_email', $emails, 'value' => empty($modSettings['birthday_email']) ? 'happy_birthday' : $modSettings['birthday_email'], 'javascript' => 'onchange="fetch_birthday_preview()"'),
-			'birthday_subject' => array('var_message', 'birthday_subject', 'var_message' => $birthdayEmails[empty($modSettings['birthday_email']) ? 'happy_birthday' : $modSettings['birthday_email']]['subject'], 'disabled' => true, 'size' => strlen($subject) + 3),
+			array('select', 'birthday_email', $emails, 'value' => array('subject' => $subject, 'body' => $body), 'javascript' => 'onchange="fetch_birthday_preview()"'),
+			'birthday_subject' => array('var_message', 'birthday_subject', 'var_message' => $processedBirthdayEmails[empty($modSettings['birthday_email']) ? 'happy_birthday' : $modSettings['birthday_email']]['subject'], 'disabled' => true, 'size' => strlen($subject) + 3),
 			'birthday_body' => array('var_message', 'birthday_body', 'var_message' => nl2br($body), 'disabled' => true, 'size' => ceil(strlen($body) / 25)),
 	);
 
@@ -341,9 +348,9 @@ function ModifyMailSettings($return_config = false)
 		var bDay = {';
 
 	$i = 0;
-	foreach ($birthdayEmails as $index => $email)
+	foreach ($processedBirthdayEmails as $index => $email)
 	{
-		$is_last = ++$i == count($birthdayEmails);
+		$is_last = ++$i == count($processedBirthdayEmails);
 		$context['settings_insert_above'] .= '
 			' . $index . ': {
 				subject: ' . JavaScriptEscape($email['subject']) . ',

+ 2 - 1
Sources/ScheduledTasks.php

@@ -1320,7 +1320,8 @@ function scheduled_birthdayemails()
 	{
 		// We need to do some shuffling to make this work properly.
 		loadLanguage('EmailTemplates', $lang);
-		$txt['emails']['happy_birthday'] = $birthdayEmails[$greeting];
+		$txt['emails']['happy_birthday']['subject'] = $txtBirthdayEmails[$greeting . '_subject'];
+		$txt['emails']['happy_birthday']['body'] = $txtBirthdayEmails[$greeting . '_body'];
 
 		foreach ($recps as $recp)
 		{

+ 3 - 3
Sources/Subs-Post.php

@@ -3227,12 +3227,12 @@ function loadEmailTemplate($template, $replacements = array(), $lang = '', $load
 	if ($loadLang)
 		loadLanguage('EmailTemplates', $lang);
 
-	if (!isset($txt['emails'][$template]))
+	if (!isset($txt['emails_' . $template . '_subject']) || !isset($txt['emails_' . $template . '_body']))
 		fatal_lang_error('email_no_template', 'template', array($template));
 
 	$ret = array(
-		'subject' => $txt['emails'][$template]['subject'],
-		'body' => $txt['emails'][$template]['body'],
+		'subject' => $txt['emails_' . $template . '_subject'],
+		'body' => $txt['emails_' . $template . '_body'],
 	);
 
 	// Add in the default replacements.

+ 19 - 19
Themes/default/languages/EmailTemplates.english.php

@@ -9,7 +9,7 @@
 
 // Do not use block comments in this file, they will have special meaning.
 
-global $context, $birthdayEmails;
+global $context, $txtBirthdayEmails;
 
 $txt['scheduled_approval_email_topic'] = 'The following topics are awaiting approval:';
 $txt['scheduled_approval_email_msg'] = 'The following posts are awaiting approval:';
@@ -928,16 +928,16 @@ The following error occurred when processing a paid subscription
 	@description: A message sent to members on their birthday.
 */
 
-$birthdayEmails['happy_birthday_subject'] = 'Happy birthday from {FORUMNAME}.';
-$birthdayEmails['happy_birthday_body'] = 'Dear {REALNAME},
+$txtBirthdayEmails['happy_birthday_subject'] = 'Happy birthday from {FORUMNAME}.';
+$txtBirthdayEmails['happy_birthday_body'] = 'Dear {REALNAME},
 
 We here at {FORUMNAME} would like to wish you a happy birthday.  May this day and the year to follow be full of joy.
 
 {REGARDS}';
-$birthdayEmails['happy_birthday_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=2676">Thantos</a>';
+$txtBirthdayEmails['happy_birthday_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=2676">Thantos</a>';
 
-$birthdayEmails['karlbenson1_subject'] = 'On your Birthday...';
-$birthdayEmails['karlbenson1_body'] = 'We could have sent you a birthday card.  We could have sent you some flowers or a cake.
+$txtBirthdayEmails['karlbenson1_subject'] = 'On your Birthday...';
+$txtBirthdayEmails['karlbenson1_body'] = 'We could have sent you a birthday card.  We could have sent you some flowers or a cake.
 
 But we didn\'t.
 
@@ -952,27 +952,27 @@ We would like to wish you a very special birthday.
 {REGARDS}
 
 //:: This message was automatically generated :://';
-$birthdayEmails['karlbenson1_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=63186">karlbenson</a>';
+$txtBirthdayEmails['karlbenson1_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=63186">karlbenson</a>';
 
-$birthdayEmails['nite0859_subject'] = 'Happy Birthday!';
-$birthdayEmails['nite0859_body'] = 'Your friends at {FORUMNAME} would like to take a moment of your time to wish you a happy birthday, {REALNAME}. If you have not done so recently, please visit our community in order for others to have the opportunity to pass along their warm regards.
+$txtBirthdayEmails['nite0859_subject'] = 'Happy Birthday!';
+$txtBirthdayEmails['nite0859_body'] = 'Your friends at {FORUMNAME} would like to take a moment of your time to wish you a happy birthday, {REALNAME}. If you have not done so recently, please visit our community in order for others to have the opportunity to pass along their warm regards.
 
 Even though today is your birthday, {REALNAME}, we would like to remind you that your membership in our community has been the best gift to us thus far.
 
 Best Wishes,
 The Staff of {FORUMNAME}';
-$birthdayEmails['nite0859_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=46625">nite0859</a>';
+$txtBirthdayEmails['nite0859_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=46625">nite0859</a>';
 
-$birthdayEmails['zwaldowski_subject'] = 'Birthday Wishes to {REALNAME}';
-$birthdayEmails['zwaldowski_body'] = 'Dear {REALNAME},
+$txtBirthdayEmails['zwaldowski_subject'] = 'Birthday Wishes to {REALNAME}';
+$txtBirthdayEmails['zwaldowski_body'] = 'Dear {REALNAME},
 
 Another year in your life has passed.  We at {FORUMNAME} hope it has been filled with happiness, and wish you luck in the coming one.
 
 {REGARDS}';
-$birthdayEmails['zwaldowski_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=72038">zwaldowski</a>';
+$txtBirthdayEmails['zwaldowski_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=72038">zwaldowski</a>';
 
-$birthdayEmails['geezmo_subject'] = 'Happy birthday, {REALNAME}!';
-$birthdayEmails['geezmo_body'] = 'Do you know who\'s having a birthday today, {REALNAME}?
+$txtBirthdayEmails['geezmo_subject'] = 'Happy birthday, {REALNAME}!';
+$txtBirthdayEmails['geezmo_body'] = 'Do you know who\'s having a birthday today, {REALNAME}?
 
 We know... YOU!
 
@@ -983,14 +983,14 @@ You\'re now a year older but we hope you\'re a lot happier than last year.
 Enjoy your day today, {REALNAME}!
 
 - From your {FORUMNAME} family';
-$birthdayEmails['geezmo_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=48671">geezmo</a>';
+$txtBirthdayEmails['geezmo_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=48671">geezmo</a>';
 
-$birthdayEmails['karlbenson2_subject'] = 'Your Birthday Greeting';
-$birthdayEmails['karlbenson2_body'] = 'We hope your birthday is the best ever cloudy, sunny or whatever the weather.
+$txtBirthdayEmails['karlbenson2_subject'] = 'Your Birthday Greeting';
+$txtBirthdayEmails['karlbenson2_body'] = 'We hope your birthday is the best ever cloudy, sunny or whatever the weather.
 Have lots of birthday cake and fun, and tell us what you have done.
 
 We hope this message brought you cheer, and make it last, until same time same place, next year.
 
 {REGARDS}';
-$birthdayEmails['karlbenson2_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=63186">karlbenson</a>';
+$txtBirthdayEmails['karlbenson2_author'] = '<a href="http://www.simplemachines.org/community/?action=profile;u=63186">karlbenson</a>';
 ?>