mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/11103] Output the notifications to the template
For now, just dumping the notifications in the header. PHPBB3-11103
This commit is contained in:
parent
44f07df96f
commit
e45fb0025e
6 changed files with 45 additions and 6 deletions
|
@ -146,6 +146,9 @@ if (!$config['use_system_cron'])
|
||||||
$cron = $phpbb_container->get('cron.manager');
|
$cron = $phpbb_container->get('cron.manager');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load notifications
|
||||||
|
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main event which is triggered on every page
|
* Main event which is triggered on every page
|
||||||
*
|
*
|
||||||
|
|
|
@ -4778,7 +4778,7 @@ function phpbb_http_login($param)
|
||||||
function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum')
|
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 $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'))
|
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')),
|
'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
|
// application/xhtml+xml not used because of IE
|
||||||
header('Content-type: text/html; charset=UTF-8');
|
header('Content-type: text/html; charset=UTF-8');
|
||||||
|
|
||||||
|
|
|
@ -87,14 +87,14 @@ class phpbb_notifications_service
|
||||||
|
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
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 = new $type_class_name($this->phpbb_container, $row);
|
||||||
$notification->users($this->users);
|
$notification->users($this->users);
|
||||||
|
|
||||||
$user_ids = array_merge($user_ids, $notification->users_to_query());
|
$user_ids = array_merge($user_ids, $notification->users_to_query());
|
||||||
|
|
||||||
$notifications[] = $notification();
|
$notifications[] = $notification;
|
||||||
}
|
}
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type
|
||||||
*/
|
*/
|
||||||
protected function get_data($name)
|
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)
|
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,7 +37,18 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
|
||||||
*/
|
*/
|
||||||
public function get_title()
|
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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -166,3 +166,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
|
|
||||||
|
<!-- BEGIN notifications -->
|
||||||
|
<p>
|
||||||
|
<a href="{notifications.URL}">{notifications.TITLE}</a><br />
|
||||||
|
{notifications.TIME}
|
||||||
|
</p>
|
||||||
|
<!-- END notifications -->
|
Loading…
Add table
Reference in a new issue