forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPhabricatorNotificationClearController.php
53 lines (44 loc) · 1.61 KB
/
PhabricatorNotificationClearController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
final class PhabricatorNotificationClearController
extends PhabricatorNotificationController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$chrono_key = $request->getStr('chronoKey');
if ($request->isDialogFormPost()) {
$table = new PhabricatorFeedStoryNotification();
queryfx(
$table->establishConnection('w'),
'UPDATE %T SET hasViewed = 1 '.
'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %s',
$table->getTableName(),
$viewer->getPHID(),
$chrono_key);
return id(new AphrontReloadResponse())
->setURI('/notification/');
}
$dialog = new AphrontDialogView();
$dialog->setUser($viewer);
$dialog->addCancelButton('/notification/');
if ($chrono_key) {
$dialog->setTitle(pht('Really mark all notifications as read?'));
$dialog->addHiddenInput('chronoKey', $chrono_key);
$is_serious =
PhabricatorEnv::getEnvConfig('phabricator.serious-business');
if ($is_serious) {
$dialog->appendChild(
pht(
'All unread notifications will be marked as read. You can not '.
'undo this action.'));
} else {
$dialog->appendChild(
pht(
"You can't ignore your problems forever, you know."));
}
$dialog->addSubmitButton(pht('Mark All Read'));
} else {
$dialog->setTitle(pht('No notifications to mark as read.'));
$dialog->appendChild(pht('You have no unread notifications.'));
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}