mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/11103] Make $phpbb_notifications a global and use it everywhere
Do not use phpbb_container everywhere (makes testing difficult) PHPBB3-11103
This commit is contained in:
parent
07fb66ac10
commit
b9bc65eed8
9 changed files with 28 additions and 46 deletions
|
@ -125,6 +125,9 @@ $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader');
|
|||
$template = $phpbb_container->get('template');
|
||||
$phpbb_style = $phpbb_container->get('style');
|
||||
|
||||
// Notifications manager
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
|
|
|
@ -89,7 +89,7 @@ services:
|
|||
- .%core.php_ext%
|
||||
- @cache.driver
|
||||
|
||||
notifications:
|
||||
notification_manager:
|
||||
class: phpbb_notification_manager
|
||||
arguments:
|
||||
- @dbal.conn
|
||||
|
|
|
@ -1285,7 +1285,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, $phpbb_container;
|
||||
global $request, $phpbb_notifications;
|
||||
|
||||
if ($mode == 'all')
|
||||
{
|
||||
|
@ -1294,7 +1294,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
|||
// Mark all forums read (index page)
|
||||
|
||||
// Mark all topic notifications read for this user
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$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'])
|
||||
|
@ -1336,7 +1335,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
|||
}
|
||||
|
||||
// Mark topic notifications read for this user in this forum
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$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
|
||||
|
@ -1448,7 +1446,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
|||
}
|
||||
|
||||
// Mark post notifications read for this user in this topic
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$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);
|
||||
|
||||
|
@ -4806,7 +4803,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, $phpbb_container;
|
||||
global $phpbb_dispatcher, $phpbb_notifications;
|
||||
|
||||
if (defined('HEADER_INC'))
|
||||
{
|
||||
|
@ -4996,7 +4993,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
|
|||
}
|
||||
|
||||
// Output the notifications
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$notifications = $phpbb_notifications->load_notifications(array(
|
||||
'all_unread' => true,
|
||||
'limit' => 5,
|
||||
|
|
|
@ -619,7 +619,7 @@ function move_posts($post_ids, $topic_id, $auto_sync = true)
|
|||
function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_sync = true, $call_delete_posts = true)
|
||||
{
|
||||
global $db, $config;
|
||||
global $phpbb_container;
|
||||
global $phpbb_notifications;
|
||||
|
||||
$approved_topics = 0;
|
||||
$forum_ids = $topic_ids = array();
|
||||
|
@ -717,7 +717,6 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
|
|||
}
|
||||
|
||||
// Delete notifications
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$phpbb_notifications->delete_notifications(array('topic', 'approve_topic', 'topic_in_queue'), $topic_ids);
|
||||
|
||||
return $return;
|
||||
|
@ -729,7 +728,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
|
|||
function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = true, $post_count_sync = true, $call_delete_topics = true)
|
||||
{
|
||||
global $db, $config, $phpbb_root_path, $phpEx, $auth, $user;
|
||||
global $phpbb_container;
|
||||
global $phpbb_notifications;
|
||||
|
||||
if ($where_type === 'range')
|
||||
{
|
||||
|
@ -899,7 +898,6 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
|
|||
}
|
||||
|
||||
// Delete notifications
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$phpbb_notifications->delete_notifications(array('quote', 'bookmark', 'post', 'approve_post', 'post_in_queue'), $post_ids);
|
||||
|
||||
return sizeof($post_ids);
|
||||
|
|
|
@ -1409,7 +1409,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
|
|||
function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true, $update_search_index = true)
|
||||
{
|
||||
global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path;
|
||||
global $phpbb_container;
|
||||
global $phpbb_notifications;
|
||||
|
||||
// We do not handle erasing posts here
|
||||
if ($mode == 'delete')
|
||||
|
@ -2220,7 +2220,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
|||
}
|
||||
|
||||
// Send Notifications
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$notification_data = array_merge($data, array(
|
||||
'topic_title' => (isset($data['topic_title'])) ? $data['topic_title'] : $subject,
|
||||
'post_username' => $username,
|
||||
|
@ -2229,6 +2228,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
|||
'post_time' => $current_time,
|
||||
'post_subject' => $subject,
|
||||
));
|
||||
|
||||
if ($post_approval)
|
||||
{
|
||||
switch ($mode)
|
||||
|
|
|
@ -876,10 +876,9 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id)
|
|||
return;
|
||||
}
|
||||
|
||||
global $db, $user, $phpbb_container;
|
||||
global $db, $user, $phpbb_notifications;
|
||||
|
||||
// Mark the PM as read
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$phpbb_notifications->mark_notifications_read('pm', $msg_id, $user_id);
|
||||
|
||||
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . "
|
||||
|
@ -986,7 +985,7 @@ function handle_mark_actions($user_id, $mark_action)
|
|||
function delete_pm($user_id, $msg_ids, $folder_id)
|
||||
{
|
||||
global $db, $user, $phpbb_root_path, $phpEx;
|
||||
global $phpbb_container;
|
||||
global $phpbb_notifications;
|
||||
|
||||
$user_id = (int) $user_id;
|
||||
$folder_id = (int) $folder_id;
|
||||
|
@ -1099,7 +1098,6 @@ function delete_pm($user_id, $msg_ids, $folder_id)
|
|||
}
|
||||
|
||||
// Delete Notifications
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$phpbb_notifications->delete_notifications('pm', array_keys($delete_rows));
|
||||
|
||||
// Now we have to check which messages we can delete completely
|
||||
|
@ -1146,7 +1144,7 @@ function delete_pm($user_id, $msg_ids, $folder_id)
|
|||
function phpbb_delete_user_pms($user_id)
|
||||
{
|
||||
global $db, $user, $phpbb_root_path, $phpEx;
|
||||
global $phpbb_container;
|
||||
global $phpbb_notifications;
|
||||
|
||||
$user_id = (int) $user_id;
|
||||
|
||||
|
@ -1265,7 +1263,6 @@ function phpbb_delete_user_pms($user_id)
|
|||
$db->sql_query($sql);
|
||||
|
||||
// Delete Notifications
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$phpbb_notifications->delete_notifications('pm', $delivered_msg);
|
||||
}
|
||||
|
||||
|
@ -1280,7 +1277,6 @@ function phpbb_delete_user_pms($user_id)
|
|||
$db->sql_query($sql);
|
||||
|
||||
// Delete Notifications
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$phpbb_notifications->delete_notifications('pm', $undelivered_msg);
|
||||
}
|
||||
}
|
||||
|
@ -1326,7 +1322,6 @@ function phpbb_delete_user_pms($user_id)
|
|||
$db->sql_query($sql);
|
||||
|
||||
// Delete Notifications
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$phpbb_notifications->delete_notifications('pm', $delete_ids);
|
||||
}
|
||||
}
|
||||
|
@ -1565,7 +1560,7 @@ function get_folder_status($folder_id, $folder)
|
|||
function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||
{
|
||||
global $db, $auth, $config, $phpEx, $template, $user, $phpbb_root_path;
|
||||
global $phpbb_container;
|
||||
global $phpbb_notifications;
|
||||
|
||||
// We do not handle erasing pms here
|
||||
if ($mode == 'delete')
|
||||
|
@ -1865,8 +1860,6 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
|||
$db->sql_transaction('commit');
|
||||
|
||||
// Send Notifications
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
|
||||
$pm_data = array_merge($data, array(
|
||||
'message_subject' => $subject,
|
||||
'recipients' => $recipients,
|
||||
|
|
|
@ -451,7 +451,7 @@ function approve_post($post_id_list, $id, $mode)
|
|||
{
|
||||
global $db, $template, $user, $config;
|
||||
global $phpEx, $phpbb_root_path;
|
||||
global $request, $phpbb_container;
|
||||
global $request, $phpbb_notifications;
|
||||
|
||||
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve')))
|
||||
{
|
||||
|
@ -601,7 +601,6 @@ function approve_post($post_id_list, $id, $mode)
|
|||
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
|
||||
|
||||
// Handle notifications
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
foreach ($post_info as $post_id => $post_data)
|
||||
{
|
||||
if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
|
||||
|
@ -720,7 +719,7 @@ function disapprove_post($post_id_list, $id, $mode)
|
|||
{
|
||||
global $db, $template, $user, $config;
|
||||
global $phpEx, $phpbb_root_path;
|
||||
global $request, $phpbb_container;
|
||||
global $request, $phpbb_notifications;
|
||||
|
||||
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve')))
|
||||
{
|
||||
|
@ -854,7 +853,6 @@ function disapprove_post($post_id_list, $id, $mode)
|
|||
}
|
||||
|
||||
// Handle notifications (topic/post in queue)
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
foreach ($post_info as $post_id => $post_data)
|
||||
{
|
||||
if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
|
||||
|
|
|
@ -21,15 +21,10 @@ class ucp_notifications
|
|||
|
||||
public function main($id, $mode)
|
||||
{
|
||||
global $phpbb_container;
|
||||
global $template, $user, $request, $phpbb_notifications;
|
||||
|
||||
add_form_key('ucp_notification_options');
|
||||
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$template = $phpbb_container->get('template');
|
||||
$user = $phpbb_container->get('user');
|
||||
$request = $phpbb_container->get('request');
|
||||
|
||||
$subscriptions = $phpbb_notifications->get_subscriptions(false, true);
|
||||
|
||||
// Add/remove subscriptions
|
||||
|
|
|
@ -60,7 +60,6 @@ if ($ext = $request->variable('ext', ''))
|
|||
$mark_notifications = request_var('mark_notification', array(0));
|
||||
if (!empty($mark_notifications))
|
||||
{
|
||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||
$phpbb_notifications->mark_notifications_read_by_id($mark_notifications);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue