Skip to content

Commit 293d64e

Browse files
committed
[ticket/13189] Do not use confirm box for marking all notifications read
We already use a token for preventing CSRF when marking notifications read. Making a user confirm the marking read action serves no real purpose. No information will be lost by just marking the notifications read but it will prevent users from always having to confirm this action. PHPBB3-13189
1 parent afada9e commit 293d64e

2 files changed

Lines changed: 14 additions & 26 deletions

File tree

phpBB/includes/ucp/ucp_notifications.php

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -95,35 +95,25 @@ public function main($id, $mode)
9595
case 'notification_list':
9696
default:
9797
// Mark all items read
98-
if ($request->variable('mark', '') == 'all' && (confirm_box(true) || check_link_hash($request->variable('token', ''), 'mark_all_notifications_read')))
98+
if ($request->variable('mark', '') == 'all' && check_link_hash($request->variable('token', ''), 'mark_all_notifications_read'))
9999
{
100-
if (confirm_box(true))
101-
{
102-
$phpbb_notifications->mark_notifications_read(false, false, $user->data['user_id'], $form_time);
103-
104-
meta_refresh(3, $this->u_action);
105-
$message = $user->lang['NOTIFICATIONS_MARK_ALL_READ_SUCCESS'];
100+
$phpbb_notifications->mark_notifications_read(false, false, $user->data['user_id'], $form_time);
106101

107-
if ($request->is_ajax())
108-
{
109-
$json_response = new \phpbb\json_response();
110-
$json_response->send(array(
111-
'MESSAGE_TITLE' => $user->lang['INFORMATION'],
112-
'MESSAGE_TEXT' => $message,
113-
'success' => true,
114-
));
115-
}
116-
$message .= '<br /><br />' . $user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>');
102+
meta_refresh(3, $this->u_action);
103+
$message = $user->lang['NOTIFICATIONS_MARK_ALL_READ_SUCCESS'];
117104

118-
trigger_error($message);
119-
}
120-
else
105+
if ($request->is_ajax())
121106
{
122-
confirm_box(false, 'NOTIFICATIONS_MARK_ALL_READ', build_hidden_fields(array(
123-
'mark' => 'all',
124-
'form_time' => $form_time,
125-
)));
107+
$json_response = new \phpbb\json_response();
108+
$json_response->send(array(
109+
'MESSAGE_TITLE' => $user->lang['INFORMATION'],
110+
'MESSAGE_TEXT' => $message,
111+
'success' => true,
112+
));
126113
}
114+
$message .= '<br /><br />' . $user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>');
115+
116+
trigger_error($message);
127117
}
128118

129119
// Mark specific notifications read

tests/functional/notification_test.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ public function test_mark_notifications_read()
8282
// Get form token
8383
$link = $crawler->selectLink($this->lang('NOTIFICATIONS_MARK_ALL_READ'))->link()->getUri();
8484
$crawler = self::request('GET', substr($link, strpos($link, 'ucp.')));
85-
$form = $crawler->selectButton($this->lang('YES'))->form();
86-
$crawler = self::submit($form);
8785
$this->assertEquals(0, $crawler->filter('#notification_list_button strong')->text());
8886
}
8987
}

0 commit comments

Comments
 (0)