Path: blob/master/src/applications/notification/controller/PhabricatorNotificationClearController.php
12256 views
<?php12final class PhabricatorNotificationClearController3extends PhabricatorNotificationController {45public function handleRequest(AphrontRequest $request) {6$viewer = $request->getViewer();7$chrono_key = $request->getStr('chronoKey');89if ($request->isDialogFormPost()) {10$should_clear = true;11} else {12$should_clear = $request->hasCSRF();13}1415if ($should_clear) {16$table = new PhabricatorFeedStoryNotification();1718queryfx(19$table->establishConnection('w'),20'UPDATE %T SET hasViewed = 1 '.21'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %s',22$table->getTableName(),23$viewer->getPHID(),24$chrono_key);2526PhabricatorUserCache::clearCache(27PhabricatorUserNotificationCountCacheType::KEY_COUNT,28$viewer->getPHID());2930return id(new AphrontReloadResponse())31->setURI('/notification/');32}3334$dialog = new AphrontDialogView();35$dialog->setUser($viewer);36$dialog->addCancelButton('/notification/');37if ($chrono_key) {38$dialog->setTitle(pht('Really mark all notifications as read?'));39$dialog->addHiddenInput('chronoKey', $chrono_key);4041$is_serious =42PhabricatorEnv::getEnvConfig('phabricator.serious-business');43if ($is_serious) {44$dialog->appendChild(45pht(46'All unread notifications will be marked as read. You can not '.47'undo this action.'));48} else {49$dialog->appendChild(50pht(51"You can't ignore your problems forever, you know."));52}5354$dialog->addSubmitButton(pht('Mark All Read'));55} else {56$dialog->setTitle(pht('No notifications to mark as read.'));57$dialog->appendChild(pht('You have no unread notifications.'));58}5960return id(new AphrontDialogResponse())->setDialog($dialog);61}62}636465