@@ -995,7 +995,7 @@ public function send_notifications_new_topic($post, $cur_posting, $new_tid)
995995 array ('fp.read_forum ' => 'IS NULL ' ),
996996 array ('fp.read_forum ' => '1 ' )
997997 );
998- $ result ['select ' ] = array ('u.id ' , 'u.email ' , 'u.notify_with_post ' );
998+ $ result ['select ' ] = array ('u.id ' , 'u.group_id ' , ' u. email ' , 'u.notify_with_post ' );
999999
10001000 $ result = DB ::for_table ('users ' )
10011001 ->table_alias ('u ' )
@@ -1027,15 +1027,16 @@ public function send_notifications_new_topic($post, $cur_posting, $new_tid)
10271027
10281028 // Loop through subscribed users and send emails
10291029 foreach ($ result as $ cur_subscriber ) {
1030+ $ cur_subscriber ['prefs ' ] = Container::get ('prefs ' )->loadPrefs ($ cur_subscriber );
10301031 // Is the subscription email for User::getPref('language', $cur_subscriber['id']) cached or not?
1031- if (!isset ($ notification_emails [User:: getPref ( ' language ' , $ cur_subscriber ['id ' ]) ])) {
1032- if (file_exists (ForumEnv::get ('FEATHER_ROOT ' ).'featherbb/lang/ ' .User:: getPref ( ' language ' , $ cur_subscriber ['id ' ]) .'/mail_templates/new_topic.tpl ' )) {
1032+ if (!isset ($ notification_emails [$ cur_subscriber ['prefs ' ][ ' language ' ] ])) {
1033+ if (file_exists (ForumEnv::get ('FEATHER_ROOT ' ).'featherbb/lang/ ' .$ cur_subscriber ['prefs ' ][ ' language ' ] .'/mail_templates/new_topic.tpl ' )) {
10331034 // Load the "new topic" template
1034- $ mail_tpl = trim (file_get_contents (ForumEnv::get ('FEATHER_ROOT ' ).'featherbb/lang/ ' .User:: getPref ( ' language ' , $ cur_subscriber ['id ' ]) .'/mail_templates/new_topic.tpl ' ));
1035+ $ mail_tpl = trim (file_get_contents (ForumEnv::get ('FEATHER_ROOT ' ).'featherbb/lang/ ' .$ cur_subscriber ['prefs ' ][ ' language ' ] .'/mail_templates/new_topic.tpl ' ));
10351036 $ mail_tpl = Container::get ('hooks ' )->fire ('model.post.send_notifications_new_topic_mail_tpl ' , $ mail_tpl );
10361037
10371038 // Load the "new topic full" template (with post included)
1038- $ mail_tpl_full = trim (file_get_contents (ForumEnv::get ('FEATHER_ROOT ' ).'featherbb/lang/ ' .User:: getPref ( ' language ' , $ cur_subscriber ['id ' ]) .'/mail_templates/new_topic_full.tpl ' ));
1039+ $ mail_tpl_full = trim (file_get_contents (ForumEnv::get ('FEATHER_ROOT ' ).'featherbb/lang/ ' .$ cur_subscriber ['prefs ' ][ ' language ' ] .'/mail_templates/new_topic_full.tpl ' ));
10391040
10401041 // The first row contains the subject (it also starts with "Subject:")
10411042 $ first_crlf = strpos ($ mail_tpl , "\n" );
@@ -1065,19 +1066,19 @@ public function send_notifications_new_topic($post, $cur_posting, $new_tid)
10651066 $ mail_message_full = str_replace ('<board_mailer> ' , ForumSettings::get ('o_board_title ' ), $ mail_message_full );
10661067 $ mail_message_full = Container::get ('hooks ' )->fire ('model.post.send_notifications_new_topic_mail_message_full ' , $ mail_message_full );
10671068
1068- $ notification_emails [User:: getPref ( ' language ' , $ cur_subscriber ['id ' ]) ][0 ] = $ mail_subject ;
1069- $ notification_emails [User:: getPref ( ' language ' , $ cur_subscriber ['id ' ]) ][1 ] = $ mail_message ;
1070- $ notification_emails [User:: getPref ( ' language ' , $ cur_subscriber ['id ' ]) ][2 ] = $ mail_subject_full ;
1071- $ notification_emails [User:: getPref ( ' language ' , $ cur_subscriber ['id ' ]) ][3 ] = $ mail_message_full ;
1069+ $ notification_emails [$ cur_subscriber ['prefs ' ][ ' language ' ] ][0 ] = $ mail_subject ;
1070+ $ notification_emails [$ cur_subscriber ['prefs ' ][ ' language ' ] ][1 ] = $ mail_message ;
1071+ $ notification_emails [$ cur_subscriber ['prefs ' ][ ' language ' ] ][2 ] = $ mail_subject_full ;
1072+ $ notification_emails [$ cur_subscriber ['prefs ' ][ ' language ' ] ][3 ] = $ mail_message_full ;
10721073 }
10731074 }
10741075
10751076 // We have to double check here because the templates could be missing
1076- if (isset ($ notification_emails [User:: getPref ( ' language ' , $ cur_subscriber ['id ' ]) ])) {
1077+ if (isset ($ notification_emails [$ cur_subscriber ['prefs ' ][ ' language ' ] ])) {
10771078 if ($ cur_subscriber ['notify_with_post ' ] == '0 ' ) {
1078- Container::get ('email ' )->feather_mail ($ cur_subscriber ['email ' ], $ notification_emails [User:: getPref ( ' language ' , $ cur_subscriber ['id ' ])] [0 ], $ notification_emails [User:: getPref ( ' language ' , $ cur_subscriber ['id ' ]) ][1 ]);
1079+ Container::get ('email ' )->feather_mail ($ cur_subscriber ['email ' ], $ notification_emails [$ cur_subscriber ['prefs ' ][ ' language ' ]] [0 ], $ notification_emails [$ cur_subscriber ['prefs ' ][ ' language ' ] ][1 ]);
10791080 } else {
1080- Container::get ('email ' )->feather_mail ($ cur_subscriber ['email ' ], $ notification_emails [User:: getPref ( ' language ' , $ cur_subscriber ['id ' ])] [2 ], $ notification_emails [User:: getPref ( ' language ' , $ cur_subscriber ['id ' ]) ][3 ]);
1081+ Container::get ('email ' )->feather_mail ($ cur_subscriber ['email ' ], $ notification_emails [$ cur_subscriber ['prefs ' ][ ' language ' ]] [2 ], $ notification_emails [$ cur_subscriber ['prefs ' ][ ' language ' ] ][3 ]);
10811082 }
10821083 }
10831084 }
0 commit comments