mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02:00
[ticket/11444] Moving the in-board notifications to a method class
Currently the in-board method for the notifications is hardcoded and cannot be disabled. This method should be in his own class extending `phpbb\notification\method\method_interface`. It also add the possibility, for each method, to be enabled by default (ie: no entry in the DB => notification enabled). https://tracker.phpbb.com/browse/PHPBB3-11444 https://tracker.phpbb.com/browse/PHPBB3-11967 PHPBB3-11444
This commit is contained in:
committed by
Tristan Darricau
parent
58d1d37c16
commit
be0d4e20d4
@@ -94,6 +94,7 @@ class acp_board
|
||||
'allow_bbcode' => array('lang' => 'ALLOW_BBCODE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
|
||||
'allow_smilies' => array('lang' => 'ALLOW_SMILIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
|
||||
'allow_sig' => array('lang' => 'ALLOW_SIG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
|
||||
'allow_board_notifications' => array('lang' => 'ALLOW_BOARD_NOTIFICATIONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
|
||||
'allow_nocensors' => array('lang' => 'ALLOW_NO_CENSORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
|
||||
'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
|
||||
'allow_birthdays' => array('lang' => 'ALLOW_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
|
||||
|
@@ -624,7 +624,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
// Mark all topic notifications read for this user
|
||||
$phpbb_notifications->mark_notifications_read(array(
|
||||
$phpbb_notifications->mark_notifications(array(
|
||||
'notification.type.topic',
|
||||
'notification.type.quote',
|
||||
'notification.type.bookmark',
|
||||
@@ -694,7 +694,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
||||
/* @var $phpbb_notifications \phpbb\notification\manager */
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
$phpbb_notifications->mark_notifications_read_by_parent(array(
|
||||
$phpbb_notifications->mark_notifications_by_parent(array(
|
||||
'notification.type.topic',
|
||||
'notification.type.approve_topic',
|
||||
), $forum_id, $user->data['user_id'], $post_time);
|
||||
@@ -711,7 +711,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$phpbb_notifications->mark_notifications_read_by_parent(array(
|
||||
$phpbb_notifications->mark_notifications_by_parent(array(
|
||||
'notification.type.quote',
|
||||
'notification.type.bookmark',
|
||||
'notification.type.post',
|
||||
@@ -818,12 +818,12 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
// Mark post notifications read for this user in this topic
|
||||
$phpbb_notifications->mark_notifications_read(array(
|
||||
$phpbb_notifications->mark_notifications(array(
|
||||
'notification.type.topic',
|
||||
'notification.type.approve_topic',
|
||||
), $topic_id, $user->data['user_id'], $post_time);
|
||||
|
||||
$phpbb_notifications->mark_notifications_read_by_parent(array(
|
||||
$phpbb_notifications->mark_notifications_by_parent(array(
|
||||
'notification.type.quote',
|
||||
'notification.type.bookmark',
|
||||
'notification.type.post',
|
||||
@@ -4254,12 +4254,12 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
||||
|
||||
// Output the notifications
|
||||
$notifications = false;
|
||||
if ($config['load_notifications'] && $user->data['user_id'] != ANONYMOUS && $user->data['user_type'] != USER_IGNORE)
|
||||
if ($config['load_notifications'] && $config['allow_board_notifications'] && $user->data['user_id'] != ANONYMOUS && $user->data['user_type'] != USER_IGNORE)
|
||||
{
|
||||
/* @var $phpbb_notifications \phpbb\notification\manager */
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
$notifications = $phpbb_notifications->load_notifications(array(
|
||||
$notifications = $phpbb_notifications->load_notifications('notification.method.board', array(
|
||||
'all_unread' => true,
|
||||
'limit' => 5,
|
||||
));
|
||||
@@ -4296,7 +4296,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
||||
'U_VIEW_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications'),
|
||||
'U_MARK_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications&mode=notification_list&mark=all&token=' . $notification_mark_hash),
|
||||
'U_NOTIFICATION_SETTINGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications&mode=notification_options'),
|
||||
'S_NOTIFICATIONS_DISPLAY' => $config['load_notifications'],
|
||||
'S_NOTIFICATIONS_DISPLAY' => $config['load_notifications'] && $config['allow_board_notifications'],
|
||||
|
||||
'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'],
|
||||
'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'],
|
||||
|
@@ -884,7 +884,7 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id)
|
||||
/* @var $phpbb_notifications \phpbb\notification\manager */
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
$phpbb_notifications->mark_notifications_read('notification.type.pm', $msg_id, $user_id);
|
||||
$phpbb_notifications->mark_notifications('notification.type.pm', $msg_id, $user_id);
|
||||
|
||||
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . "
|
||||
SET pm_unread = 0
|
||||
|
@@ -97,7 +97,7 @@ class mcp_pm_reports
|
||||
/* @var $phpbb_notifications \phpbb\notification\manager */
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
$phpbb_notifications->mark_notifications_read_by_parent('notification.type.report_pm', $report_id, $user->data['user_id']);
|
||||
$phpbb_notifications->mark_notifications_by_parent('report_pm', $report_id, $user->data['user_id']);
|
||||
|
||||
$pm_id = $report['pm_id'];
|
||||
$report_id = $report['report_id'];
|
||||
|
@@ -166,7 +166,7 @@ class mcp_queue
|
||||
{
|
||||
$post_id = (int) $topic_info[$topic_id]['topic_first_post_id'];
|
||||
|
||||
$phpbb_notifications->mark_notifications_read('notification.type.topic_in_queue', $topic_id, $user->data['user_id']);
|
||||
$phpbb_notifications->mark_notifications('topic_in_queue', $topic_id, $user->data['user_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -174,7 +174,7 @@ class mcp_queue
|
||||
}
|
||||
}
|
||||
|
||||
$phpbb_notifications->mark_notifications_read('notification.type.post_in_queue', $post_id, $user->data['user_id']);
|
||||
$phpbb_notifications->mark_notifications('post_in_queue', $post_id, $user->data['user_id']);
|
||||
|
||||
$post_info = phpbb_get_post_data(array($post_id), 'm_approve', true);
|
||||
|
||||
@@ -738,7 +738,7 @@ class mcp_queue
|
||||
$phpbb_notifications->add_notifications(array('notification.type.quote'), $post_data);
|
||||
$phpbb_notifications->delete_notifications('notification.type.post_in_queue', $post_id);
|
||||
|
||||
$phpbb_notifications->mark_notifications_read(array(
|
||||
$phpbb_notifications->mark_notifications(array(
|
||||
'notification.type.quote',
|
||||
'notification.type.bookmark',
|
||||
'notification.type.post',
|
||||
@@ -974,8 +974,8 @@ class mcp_queue
|
||||
), $topic_data);
|
||||
}
|
||||
|
||||
$phpbb_notifications->mark_notifications_read('notification.type.quote', $topic_data['post_id'], $user->data['user_id']);
|
||||
$phpbb_notifications->mark_notifications_read('notification.type.topic', $topic_id, $user->data['user_id']);
|
||||
$phpbb_notifications->mark_notifications('quote', $topic_data['post_id'], $user->data['user_id']);
|
||||
$phpbb_notifications->mark_notifications('topic', $topic_id, $user->data['user_id']);
|
||||
|
||||
if ($notify_poster)
|
||||
{
|
||||
|
@@ -142,7 +142,7 @@ class mcp_reports
|
||||
/* @var $phpbb_notifications \phpbb\notification\manager */
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
$phpbb_notifications->mark_notifications_read('notification.type.report_post', $post_id, $user->data['user_id']);
|
||||
$phpbb_notifications->mark_notifications('report_post', $post_id, $user->data['user_id']);
|
||||
|
||||
if (!$report_id && $report['report_closed'])
|
||||
{
|
||||
|
@@ -20,7 +20,7 @@ class ucp_notifications_info
|
||||
'title' => 'UCP_NOTIFICATION_OPTIONS',
|
||||
'modes' => array(
|
||||
'notification_options' => array('title' => 'UCP_NOTIFICATION_OPTIONS', 'auth' => '', 'cat' => array('UCP_PREFS')),
|
||||
'notification_list' => array('title' => 'UCP_NOTIFICATION_LIST', 'auth' => '', 'cat' => array('UCP_MAIN')),
|
||||
'notification_list' => array('title' => 'UCP_NOTIFICATION_LIST', 'auth' => 'cfg_allow_board_notifications', 'cat' => array('UCP_MAIN')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@@ -70,15 +70,6 @@ class ucp_notifications
|
||||
$phpbb_notifications->delete_subscription($type, 0, $method_data['id']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->is_set_post(str_replace('.', '_', $type) . '_notification') && !isset($subscriptions[$type]))
|
||||
{
|
||||
$phpbb_notifications->add_subscription($type);
|
||||
}
|
||||
else if (!$request->is_set_post(str_replace('.', '_', $type) . '_notification') && isset($subscriptions[$type]))
|
||||
{
|
||||
$phpbb_notifications->delete_subscription($type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +91,7 @@ class ucp_notifications
|
||||
// Mark all items read
|
||||
if ($request->variable('mark', '') == 'all' && check_link_hash($request->variable('token', ''), 'mark_all_notifications_read'))
|
||||
{
|
||||
$phpbb_notifications->mark_notifications_read(false, false, $user->data['user_id'], $form_time);
|
||||
$phpbb_notifications->mark_notifications(false, false, $user->data['user_id'], $form_time);
|
||||
|
||||
meta_refresh(3, $this->u_action);
|
||||
$message = $user->lang['NOTIFICATIONS_MARK_ALL_READ_SUCCESS'];
|
||||
@@ -131,11 +122,11 @@ class ucp_notifications
|
||||
|
||||
if (!empty($mark_read))
|
||||
{
|
||||
$phpbb_notifications->mark_notifications_read_by_id($mark_read, $form_time);
|
||||
$phpbb_notifications->mark_notifications_by_id($mark_read, $form_time);
|
||||
}
|
||||
}
|
||||
|
||||
$notifications = $phpbb_notifications->load_notifications(array(
|
||||
$notifications = $phpbb_notifications->load_notifications('notification.method.board', array(
|
||||
'start' => $start,
|
||||
'limit' => $config['topics_per_page'],
|
||||
'count_total' => true,
|
||||
@@ -196,8 +187,6 @@ class ucp_notifications
|
||||
|
||||
'NAME' => $user->lang($data['lang']),
|
||||
'EXPLAIN' => (isset($user->lang[$data['lang'] . '_EXPLAIN'])) ? $user->lang($data['lang'] . '_EXPLAIN') : '',
|
||||
|
||||
'SUBSCRIBED' => (isset($subscriptions[$type])) ? true : false,
|
||||
));
|
||||
|
||||
foreach ($notification_methods as $method => $method_data)
|
||||
@@ -230,7 +219,7 @@ class ucp_notifications
|
||||
{
|
||||
$notification_methods = $phpbb_notifications->get_subscription_methods();
|
||||
|
||||
foreach ($notification_methods as $method => $method_data)
|
||||
foreach($notification_methods as $method => $method_data)
|
||||
{
|
||||
$template->assign_block_vars($block, array(
|
||||
'METHOD' => $method_data['id'],
|
||||
|
Reference in New Issue
Block a user