diff options
-rw-r--r-- | phpBB/common.php | 3 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 9 | ||||
-rw-r--r-- | phpBB/includes/notifications/service.php | 4 | ||||
-rw-r--r-- | phpBB/includes/notifications/type/base.php | 15 | ||||
-rw-r--r-- | phpBB/includes/notifications/type/post.php | 13 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/overall_header.html | 7 |
6 files changed, 45 insertions, 6 deletions
diff --git a/phpBB/common.php b/phpBB/common.php index 281eb88c4d..52879deb9c 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -146,6 +146,9 @@ if (!$config['use_system_cron']) $cron = $phpbb_container->get('cron.manager'); } +// Load notifications +$phpbb_notifications = $phpbb_container->get('notifications'); + /** * Main event which is triggered on every page * diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 834f57a38b..7632ea1fcb 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4778,7 +4778,7 @@ function phpbb_http_login($param) 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; + global $phpbb_dispatcher, $phpbb_container; if (defined('HEADER_INC')) { @@ -5092,6 +5092,13 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); + // Output the notifications + $phpbb_notifications = $phpbb_container->get('notifications'); + foreach ($phpbb_notifications->load_notifications() as $notification) + { + $notification->display(); + } + // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index fd2c51a330..8db414cb16 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -87,14 +87,14 @@ class phpbb_notifications_service while ($row = $this->db->sql_fetchrow($result)) { - $type_class_name = $this->get_type_class_name($row['type'], true); + $type_class_name = $this->get_type_class_name($row['item_type'], true); $notification = new $type_class_name($this->phpbb_container, $row); $notification->users($this->users); $user_ids = array_merge($user_ids, $notification->users_to_query()); - $notifications[] = $notification(); + $notifications[] = $notification; } $this->db->sql_freeresult($result); diff --git a/phpBB/includes/notifications/type/base.php b/phpBB/includes/notifications/type/base.php index 2b194557e3..1b01e1d46c 100644 --- a/phpBB/includes/notifications/type/base.php +++ b/phpBB/includes/notifications/type/base.php @@ -85,7 +85,7 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type */ protected function get_data($name) { - return $this->data['data'][$name]; + return (isset($this->data['data'][$name])) ? $this->data['data'][$name] : null; } /** @@ -105,7 +105,18 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type */ public function users(&$users) { - $this->users = $users; + $this->users = &$users; + } + + /** + * Get a user row from our users cache + * + * @param int $user_id + * @return array + */ + protected function get_user($user_id) + { + return $this->users[$user_id]; } /** diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index 08da7a77cb..4b343650a1 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -37,7 +37,18 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base */ public function get_title() { - return $this->data['post_username'] . ' posted in the topic ' . censor_text($this->data['topic_title']); + if ($this->get_data('post_username')) + { + $username = $this->get_data('post_username'); + } + else + { + $user_data = $this->get_user($this->get_data('poster_id')); + + $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + } + + return $username . ' posted in the topic ' . censor_text($this->get_data('topic_title')); } /** diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 43ae83767d..77fdb230ad 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -166,3 +166,10 @@ </div> </div> <!-- ENDIF --> + +<!-- BEGIN notifications --> + <p> + <a href="{notifications.URL}">{notifications.TITLE}</a><br /> + {notifications.TIME} + </p> +<!-- END notifications -->
\ No newline at end of file |