diff options
| author | David King <imkingdavid@gmail.com> | 2013-02-28 18:53:23 -0500 |
|---|---|---|
| committer | David King <imkingdavid@gmail.com> | 2013-02-28 18:53:23 -0500 |
| commit | 8200509c7940166d560c309c35b2ade2e4952f75 (patch) | |
| tree | 5f4e89b1fe677520a4310754860a9c85511bb2b0 /phpBB/includes/functions.php | |
| parent | 1eead4da97635df35bfcdd6b1ce7ed71d9851d41 (diff) | |
| parent | ecb9f44bf11756e1072354bfd658edfd4c01f74a (diff) | |
| download | forums-8200509c7940166d560c309c35b2ade2e4952f75.tar forums-8200509c7940166d560c309c35b2ade2e4952f75.tar.gz forums-8200509c7940166d560c309c35b2ade2e4952f75.tar.bz2 forums-8200509c7940166d560c309c35b2ade2e4952f75.tar.xz forums-8200509c7940166d560c309c35b2ade2e4952f75.zip | |
Merge remote-tracking branch 'EXreaction/ticket/11103' into develop
# By Nathan Guse (169) and others
# Via Nathan Guse (29) and Nathaniel Guse (7)
* EXreaction/ticket/11103: (217 commits)
[ticket/11103] Revert whitespace changes
[ticket/11103] Few more minor language things
[ticket/11103] Don't call generate_board_url many times
[ticket/11103] Case time in queries as an int
[ticket/11103] Fix effectively installed check
[ticket/11103] Remove padding from notifications for now.
[ticket/11103] Notifications Migration file
[ticket/11103] Restore new/unread messages info/link in header (properly)
[ticket/11103] Add newlines to bottom of css file
[ticket/11103] HTML encode double arrow character
[ticket/11103] Add Notification Settings link in flyout menu
[ticket/11103] Restore new/unread messages info/link in header
[ticket/11103] Update styling of UCP Notifications in subsilver2
[ticket/11103] Update styling of UCP Notifications in prosilver
[ticket/11103] Update styling of subsilver2 notification modal
[ticket/11103] Update styling of prosilver notification modal
[ticket/11103] Remove title attribute from notification link
[ticket/11103] Mark/Unmark All buttons
[ticket/11103] Make the number of notifications strong if > 0
[ticket/11103] Rounded Corners and antialiased pointer
...
Diffstat (limited to 'phpBB/includes/functions.php')
| -rw-r--r-- | phpBB/includes/functions.php | 83 |
1 files changed, 81 insertions, 2 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d9af268f80..6a1f144967 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1347,7 +1347,7 @@ function phpbb_timezone_select($user, $default = '', $truncate = false) function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $user_id = 0) { global $db, $user, $config; - global $request; + global $request, $phpbb_container; $post_time = ($post_time === 0 || $post_time > time()) ? time() : (int) $post_time; @@ -1355,6 +1355,20 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ { if ($forum_id === false || !sizeof($forum_id)) { + // Mark all forums read (index page) + + $phpbb_notifications = $phpbb_container->get('notification_manager'); + + // Mark all topic notifications read for this user + $phpbb_notifications->mark_notifications_read(array( + 'topic', + 'quote', + 'bookmark', + 'post', + 'approve_topic', + 'approve_post', + ), false, $user->data['user_id'], $post_time); + if ($config['load_db_lastread'] && $user->data['is_registered']) { // Mark all forums read (index page) @@ -1409,6 +1423,32 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $forum_id = array($forum_id); } + $phpbb_notifications = $phpbb_container->get('notification_manager'); + + $phpbb_notifications->mark_notifications_read_by_parent(array( + 'topic', + 'approve_topic', + ), $forum_id, $user->data['user_id'], $post_time); + + // Mark all post/quote notifications read for this user in this forum + $topic_ids = array(); + $sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_id); + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $topic_ids[] = $row['topic_id']; + } + $db->sql_freeresult($result); + + $phpbb_notifications->mark_notifications_read_by_parent(array( + 'quote', + 'bookmark', + 'post', + 'approve_post', + ), $topic_ids, $user->data['user_id'], $post_time); + // Add 0 to forums array to mark global announcements correctly // $forum_id[] = 0; @@ -1506,6 +1546,21 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ return; } + $phpbb_notifications = $phpbb_container->get('notification_manager'); + + // Mark post notifications read for this user in this topic + $phpbb_notifications->mark_notifications_read(array( + 'topic', + 'approve_topic', + ), $topic_id, $user->data['user_id'], $post_time); + + $phpbb_notifications->mark_notifications_read_by_parent(array( + 'quote', + 'bookmark', + 'post', + 'approve_post', + ), $topic_id, $user->data['user_id'], $post_time); + if ($config['load_db_lastread'] && $user->data['is_registered']) { $sql = 'UPDATE ' . TOPICS_TRACK_TABLE . " @@ -5013,7 +5068,7 @@ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null) function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; - global $phpbb_dispatcher, $request; + global $phpbb_dispatcher, $request, $phpbb_container; if (defined('HEADER_INC')) { @@ -5202,8 +5257,26 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $timezone_name = $user->lang['timezones'][$timezone_name]; } + // Output the notifications + $notifications = false; + if ($config['load_notifications'] && $user->data['user_id'] != ANONYMOUS && $user->data['user_type'] != USER_IGNORE) + { + $phpbb_notifications = $phpbb_container->get('notification_manager'); + + $notifications = $phpbb_notifications->load_notifications(array( + 'all_unread' => true, + 'limit' => 5, + )); + + foreach ($notifications['notifications'] as $notification) + { + $template->assign_block_vars('notifications', $notification->prepare_for_display()); + } + } + $hidden_fields_for_jumpbox = phpbb_build_hidden_fields_for_query_params($request, array('f')); + // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -5220,6 +5293,12 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 'HIDDEN_FIELDS_FOR_JUMPBOX' => $hidden_fields_for_jumpbox, + 'UNREAD_NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : '', + 'NOTIFICATIONS_COUNT' => ($notifications !== false) ? $user->lang('NOTIFICATIONS_COUNT', $notifications['unread_count']) : '', + 'U_VIEW_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications'), + 'U_NOTIFICATION_SETTINGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications&mode=notification_options'), + 'S_NOTIFICATIONS_DISPLAY' => $config['load_notifications'], + 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'S_USER_NEW' => $user->data['user_new'], |
