Skip to content

Commit 425df94

Browse files
committed
Migrate notify_with_post
1 parent f46e976 commit 425df94

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

featherbb/Controller/Install.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ public function create_db(array $data)
239239
'show.img.sig' => 1,
240240
'show.avatars' => 1,
241241
'show.sig' => 1,
242-
'email.setting' => 1
242+
'email.setting' => 1,
243+
'notify_with_post' => 0,
243244
));
244245
Container::get('prefs')->setGroup(2, array(
245246
'post.min_interval' => 0,

featherbb/Model/Api/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function display($id)
2020
// Remove sensitive fields for regular users
2121
if (!$this->isAdMod) {
2222
Container::get('hooks')->bind('model.profile.get_user_info', function ($user) {
23-
$user = $user->select_delete_many(array('u.email', 'u.registration_ip', 'u.notify_with_post', 'u.auto_notify', 'u.admin_note', 'u.last_visit'));
23+
$user = $user->select_delete_many(array('u.email', 'u.registration_ip', 'u.auto_notify', 'u.admin_note', 'u.last_visit'));
2424
return $user;
2525
});
2626
}

featherbb/Model/Install.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ class Install
206206
`url` varchar(100) DEFAULT NULL,
207207
`location` varchar(30) DEFAULT NULL,
208208
`signature` text,
209-
`notify_with_post` tinyint(1) NOT NULL DEFAULT '0',
210209
`auto_notify` tinyint(1) NOT NULL DEFAULT '0',
211210
`num_posts` int(10) unsigned NOT NULL DEFAULT '0',
212211
`last_post` int(10) unsigned DEFAULT NULL,

featherbb/Model/Post.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ public static function send_notifications_reply($tid, $cur_posting, $new_pid, $p
784784
array('fp.read_forum' => 'IS NULL'),
785785
array('fp.read_forum' => '1')
786786
);
787-
$result['select'] = array('u.id', 'u.email', 'u.notify_with_post');
787+
$result['select'] = array('u.id', 'u.email', 'u.group_id');
788788

789789
$result = DB::for_table('users')
790790
->table_alias('u')
@@ -815,15 +815,16 @@ public static function send_notifications_reply($tid, $cur_posting, $new_pid, $p
815815

816816
// Loop through subscribed users and send emails
817817
foreach($result as $cur_subscriber) {
818+
$cur_subscriber['prefs'] = Container::get('prefs')->loadPrefs($cur_subscriber);
818819
// Is the subscription email for User::getPref('language', $cur_subscriber['id']) cached or not?
819-
if (!isset($notification_emails[User::getPref('language', $cur_subscriber['id'])])) {
820-
if (file_exists(ForumEnv::get('FEATHER_ROOT').'featherbb/lang/'.User::getPref('language', $cur_subscriber['id']).'/mail_templates/new_reply.tpl')) {
820+
if (!isset($notification_emails[$cur_subscriber['prefs']['language']])) {
821+
if (file_exists(ForumEnv::get('FEATHER_ROOT').'featherbb/lang/'.$cur_subscriber['prefs']['language'].'/mail_templates/new_reply.tpl')) {
821822
// Load the "new reply" template
822-
$mail_tpl = trim(file_get_contents(ForumEnv::get('FEATHER_ROOT').'featherbb/lang/'.User::getPref('language', $cur_subscriber['id']).'/mail_templates/new_reply.tpl'));
823+
$mail_tpl = trim(file_get_contents(ForumEnv::get('FEATHER_ROOT').'featherbb/lang/'.$cur_subscriber['prefs']['language'].'/mail_templates/new_reply.tpl'));
823824
$mail_tpl = Container::get('hooks')->fire('model.post.send_notifications_reply_mail_tpl', $mail_tpl);
824825

825826
// Load the "new reply full" template (with post included)
826-
$mail_tpl_full = trim(file_get_contents(ForumEnv::get('FEATHER_ROOT').'featherbb/lang/'.User::getPref('language', $cur_subscriber['id']).'/mail_templates/new_reply_full.tpl'));
827+
$mail_tpl_full = trim(file_get_contents(ForumEnv::get('FEATHER_ROOT').'featherbb/lang/'.$cur_subscriber['prefs']['language'].'/mail_templates/new_reply_full.tpl'));
827828
$mail_tpl_full = Container::get('hooks')->fire('model.post.send_notifications_reply_mail_tpl_full', $mail_tpl_full);
828829

829830
// The first row contains the subject (it also starts with "Subject:")
@@ -853,21 +854,21 @@ public static function send_notifications_reply($tid, $cur_posting, $new_pid, $p
853854
$mail_message_full = str_replace('<board_mailer>', ForumSettings::get('o_board_title'), $mail_message_full);
854855
$mail_message_full = Container::get('hooks')->fire('model.post.send_notifications_reply_mail_message_full', $mail_message_full);
855856

856-
$notification_emails[User::getPref('language', $cur_subscriber['id'])][0] = $mail_subject;
857-
$notification_emails[User::getPref('language', $cur_subscriber['id'])][1] = $mail_message;
858-
$notification_emails[User::getPref('language', $cur_subscriber['id'])][2] = $mail_subject_full;
859-
$notification_emails[User::getPref('language', $cur_subscriber['id'])][3] = $mail_message_full;
857+
$notification_emails[$cur_subscriber['prefs']['language']][0] = $mail_subject;
858+
$notification_emails[$cur_subscriber['prefs']['language']][1] = $mail_message;
859+
$notification_emails[$cur_subscriber['prefs']['language']][2] = $mail_subject_full;
860+
$notification_emails[$cur_subscriber['prefs']['language']][3] = $mail_message_full;
860861

861862
$mail_subject = $mail_message = $mail_subject_full = $mail_message_full = null;
862863
}
863864
}
864865

865866
// We have to double check here because the templates could be missing
866-
if (isset($notification_emails[User::getPref('language', $cur_subscriber['id'])])) {
867-
if ($cur_subscriber['notify_with_post'] == '0') {
868-
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]);
867+
if (isset($notification_emails[$cur_subscriber['prefs']['language']])) {
868+
if ($cur_subscriber['prefs']['notify_with_post'] == '0') {
869+
Container::get('email')->feather_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['prefs']['language']][0], $notification_emails[$cur_subscriber['prefs']['language']][1]);
869870
} else {
870-
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]);
871+
Container::get('email')->feather_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['prefs']['language']][2], $notification_emails[$cur_subscriber['prefs']['language']][3]);
871872
}
872873
}
873874
}
@@ -995,7 +996,7 @@ public function send_notifications_new_topic($post, $cur_posting, $new_tid)
995996
array('fp.read_forum' => 'IS NULL'),
996997
array('fp.read_forum' => '1')
997998
);
998-
$result['select'] = array('u.id', 'u.group_id', 'u.email', 'u.notify_with_post');
999+
$result['select'] = array('u.id', 'u.group_id', 'u.email');
9991000

10001001
$result = DB::for_table('users')
10011002
->table_alias('u')
@@ -1075,7 +1076,7 @@ public function send_notifications_new_topic($post, $cur_posting, $new_tid)
10751076

10761077
// We have to double check here because the templates could be missing
10771078
if (isset($notification_emails[$cur_subscriber['prefs']['language']])) {
1078-
if ($cur_subscriber['notify_with_post'] == '0') {
1079+
if ($cur_subscriber['prefs']['notify_with_post'] == '0') {
10791080
Container::get('email')->feather_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['prefs']['language']][0], $notification_emails[$cur_subscriber['prefs']['language']][1]);
10801081
} else {
10811082
Container::get('email')->feather_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['prefs']['language']][2], $notification_emails[$cur_subscriber['prefs']['language']][3]);

featherbb/Model/Profile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ public function update_profile($id, $info, $section)
871871
case 'privacy':
872872
{
873873
$form = array(
874-
'email_setting' => intval(Input::post('form_email_setting')),
874+
'email.setting' => intval(Input::post('form_email_setting')),
875875
'notify_with_post' => Input::post('form_notify_with_post') ? '1' : '0',
876876
'auto_notify' => Input::post('form_auto_notify') ? '1' : '0',
877877
);
@@ -1003,7 +1003,7 @@ public function update_profile($id, $info, $section)
10031003

10041004
public function get_user_info($id)
10051005
{
1006-
$user['select'] = array('u.id', 'u.group_id', 'u.username', 'u.email', 'u.title', 'u.realname', 'u.url', 'u.location', 'u.signature', 'u.notify_with_post', 'u.auto_notify', 'u.num_posts', 'u.last_post', 'u.registered', 'u.registration_ip', 'u.admin_note', 'u.last_visit', 'g.g_id', 'g.g_user_title', 'g.g_moderator');
1006+
$user['select'] = array('u.id', 'u.group_id', 'u.username', 'u.email', 'u.title', 'u.realname', 'u.url', 'u.location', 'u.signature', 'u.auto_notify', 'u.num_posts', 'u.last_post', 'u.registered', 'u.registration_ip', 'u.admin_note', 'u.last_visit', 'g.g_id', 'g.g_user_title', 'g.g_moderator');
10071007

10081008
$user = DB::for_table('users')
10091009
->table_alias('u')

featherbb/View/profile/section_privacy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<legend><?php _e('Subscription legend') ?></legend>
4242
<div class="infldset">
4343
<div class="rbox">
44-
<label><input type="checkbox" name="form_notify_with_post" value="1"<?php if ($user['notify_with_post'] == '1') {echo ' checked="checked"';} ?> /><?php _e('Notify full') ?><br /></label>
44+
<label><input type="checkbox" name="form_notify_with_post" value="1"<?php if ($user['prefs']['notify_with_post'] == '1') {echo ' checked="checked"';} ?> /><?php _e('Notify full') ?><br /></label>
4545
<?php if (ForumSettings::get('o_topic_subscriptions') == '1'): ?>
4646
<label><input type="checkbox" name="form_auto_notify" value="1"<?php if ($user['auto_notify'] == '1') {echo ' checked="checked"';} ?> /><?php _e('Auto notify full') ?><br /></label>
4747
<?php endif; ?>

0 commit comments

Comments
 (0)