Differential D18133 Diff 43631 src/applications/notification/controller/PhabricatorNotificationPanelController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/notification/controller/PhabricatorNotificationPanelController.php
| <?php | <?php | ||||
| final class PhabricatorNotificationPanelController | final class PhabricatorNotificationPanelController | ||||
| extends PhabricatorNotificationController { | extends PhabricatorNotificationController { | ||||
| public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
| $viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
| $query = id(new PhabricatorNotificationQuery()) | $query = id(new PhabricatorNotificationQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withUserPHIDs(array($viewer->getPHID())) | ->withUserPHIDs(array($viewer->getPHID())) | ||||
| ->setLimit(15); | ->setLimit(15); | ||||
| $stories = $query->execute(); | $stories = $query->execute(); | ||||
| $clear_ui_class = 'phabricator-notification-clear-all'; | $clear_ui_class = 'phabricator-notification-clear-all'; | ||||
| $clear_uri = id(new PhutilURI('/notification/clear/')); | $clear_ui = null; | ||||
| if ($stories) { | if ($stories) { | ||||
| $builder = id(new PhabricatorNotificationBuilder($stories)) | $builder = id(new PhabricatorNotificationBuilder($stories)) | ||||
| ->setUser($viewer); | ->setUser($viewer); | ||||
| $notifications_view = $builder->buildView(); | $notifications_view = $builder->buildView(); | ||||
| $content = $notifications_view->render(); | $content = $notifications_view->render(); | ||||
| $clear_uri->setQueryParam( | |||||
| 'chronoKey', | |||||
| head($stories)->getChronologicalKey()); | |||||
| } else { | } else { | ||||
| $content = phutil_tag_div( | $content = phutil_tag_div( | ||||
| 'phabricator-notification no-notifications', | 'phabricator-notification no-notifications', | ||||
| pht('You have no notifications.')); | pht('You have no notifications.')); | ||||
| $clear_ui_class .= ' disabled'; | $clear_ui_class .= ' disabled'; | ||||
| } | } | ||||
| $clear_ui = javelin_tag( | |||||
| 'a', | $chrono_key = head($stories)->getChronologicalKey(); | ||||
| $clear_ui = phabricator_form( | |||||
| $viewer, | |||||
| array( | array( | ||||
| 'sigil' => 'workflow', | 'method' => 'POST', | ||||
| 'href' => (string)$clear_uri, | 'action' => '/notification/clear/?chronoKey='.$chrono_key, | ||||
| 'sigil' => 'notifications-clear-all-form', | |||||
| 'class' => $clear_ui_class, | 'class' => $clear_ui_class, | ||||
| 'id' => 'notifications-mark-read', | |||||
| ), | ), | ||||
| pht('Mark All Read')); | pht('Mark All Read')); | ||||
| $notifications_link = phutil_tag( | $notifications_link = phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'href' => '/notification/', | 'href' => '/notification/', | ||||
| ), | ), | ||||
| Show All 37 Lines | |||||