3 final class PhabricatorNotificationClearController
4 extends PhabricatorNotificationController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $request->getViewer();
8 $chrono_key = $request->getStr('chronoKey');
10 if ($request->isDialogFormPost()) {
13 $should_clear = $request->hasCSRF();
17 $table = new PhabricatorFeedStoryNotification();
20 $table->establishConnection('w'),
21 'UPDATE %T SET hasViewed = 1 '.
22 'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %s',
23 $table->getTableName(),
27 PhabricatorUserCache
::clearCache(
28 PhabricatorUserNotificationCountCacheType
::KEY_COUNT
,
31 return id(new AphrontReloadResponse())
32 ->setURI('/notification/');
35 $dialog = new AphrontDialogView();
36 $dialog->setUser($viewer);
37 $dialog->addCancelButton('/notification/');
39 $dialog->setTitle(pht('Really mark all notifications as read?'));
40 $dialog->addHiddenInput('chronoKey', $chrono_key);
43 PhabricatorEnv
::getEnvConfig('phabricator.serious-business');
47 'All unread notifications will be marked as read. You can not '.
48 'undo this action.'));
52 "You can't ignore your problems forever, you know."));
55 $dialog->addSubmitButton(pht('Mark All Read'));
57 $dialog->setTitle(pht('No notifications to mark as read.'));
58 $dialog->appendChild(pht('You have no unread notifications.'));
61 return id(new AphrontDialogResponse())->setDialog($dialog);