diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index fc9b48c624..03776de2b4 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -165,7 +165,7 @@ class phpbb_notification_manager } $load_special[$row['item_type']] = array_merge($load_special[$row['item_type']], $notification->get_load_special()); - $notifications[] = $notification; + $notifications[$row['notification_id']] = $notification; } $this->load_users($user_ids); diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php index e8959d1352..9ef0e71009 100644 --- a/phpBB/includes/notification/type/base.php +++ b/phpBB/includes/notification/type/base.php @@ -138,7 +138,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i 'UNREAD' => $this->unread, - 'U_MARK_READ' => append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification[]=' . $this->notification_id), + 'U_MARK_READ' => append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification=' . $this->notification_id), ); } @@ -148,7 +148,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) * @return string */ - public function mark_read($return = true) + public function mark_read($return = false) { return $this->mark(false, $return); } @@ -159,7 +159,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) * @return string */ - public function mark_unread($return = true) + public function mark_unread($return = false) { return $this->mark(true, $return); } @@ -352,11 +352,11 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i $this->unread = (bool) $unread; $where = array( - 'item_type = ' . $this->db->sql_escape($this->item_type), + "item_type = '" . $this->db->sql_escape($this->item_type) . "'", 'item_id = ' . (int) $this->item_id, 'user_id = ' . (int) $this->user_id, ); - $where = implode(' AND ' . $where); + $where = implode(' AND ', $where); if ($return) { @@ -364,7 +364,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i } $sql = 'UPDATE ' . NOTIFICATIONS_TABLE . ' - SET unread = ' . $this->unread . ' + SET unread = ' . (int) $this->unread . ' WHERE ' . $where; $this->db->sql_query($sql); } diff --git a/phpBB/index.php b/phpBB/index.php index af0441f5e3..7f85879d23 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -23,6 +23,23 @@ $user->session_begin(); $auth->acl($user->data); $user->setup(); +// Mark notifications read +if (($mark_notification = request_var('mark_notification', 0))) +{ + $notification = $phpbb_notifications->load_notifications(array( + 'notification_id' => $mark_notification + )); + + if (isset($notification['notifications'][$mark_notification])) + { + $notification = $notification['notifications'][$mark_notification]; + + $notification->mark_read(); + + redirect($notification->get_url()); + } +} + // Handle the display of extension front pages if ($ext = $request->variable('ext', '')) { @@ -56,13 +73,6 @@ if ($ext = $request->variable('ext', '')) exit_handler(); } -// Mark notifications read -$mark_notifications = request_var('mark_notification', array(0)); -if (!empty($mark_notifications)) -{ - $phpbb_notifications->mark_notifications_read_by_id($mark_notifications); -} - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); $user->add_lang('viewforum'); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 2f9f646cd3..8980c274ef 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -395,7 +395,7 @@ $lang = array_merge($lang, array( 'NOTIFICATION_POST' => '%1$s replied to the topic "%2$s".', 'NOTIFICATION_POST_APPROVED' => 'Your post was approved "%2$s".', 'NOTIFICATION_POST_DISAPPROVED' => 'Your post "%1$s" was disapproved for reason: "%2$s".', - 'NOTIFICATION_POST_IN_QUEUE' => 'A new post titled "%2$s" was posted by "%1$s" and needs approval.', + 'NOTIFICATION_POST_IN_QUEUE' => 'A new post titled "%2$s" was posted by %1$s and needs approval.', 'NOTIFICATION_QUOTE' => '%1$s quoted you in the post "%2$s".', 'NOTIFICATION_REPORT_PM' => '%1$s reported a Private Message "%2$s" for reason: "%3$s".', 'NOTIFICATION_REPORT_POST' => '%1$s reported a post "%2$s" for reason: "%3$s".', @@ -403,7 +403,7 @@ $lang = array_merge($lang, array( 'NOTIFICATION_TOPIC' => '%1$s posted a new topic "%2$s" in the forum "%3$s".', 'NOTIFICATION_TOPIC_APPROVED' => 'Your topic "%2$s" in the forum "%3$s" was approved.', 'NOTIFICATION_TOPIC_DISAPPROVED' => 'Your topic "%1$s" was disapproved for reason: "%2$s".', - 'NOTIFICATION_TOPIC_IN_QUEUE' => 'A new topic titled "%2$s" was posted by "%1$s" and needs approval.', + 'NOTIFICATION_TOPIC_IN_QUEUE' => 'A new topic titled "%2$s" was posted by %1$s and needs approval.', 'NOTIFY_ADMIN' => 'Please notify the board administrator or webmaster.', 'NOTIFY_ADMIN_EMAIL' => 'Please notify the board administrator or webmaster: %1$s', 'NO_ACCESS_ATTACHMENT' => 'You are not allowed to access this file.', diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index e00ad555ff..20b98c6f8c 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -137,14 +137,15 @@