diff --git a/src/applications/notification/controller/PhabricatorNotificationClearController.php b/src/applications/notification/controller/PhabricatorNotificationClearController.php
index ba781234e7..0b6027d379 100644
--- a/src/applications/notification/controller/PhabricatorNotificationClearController.php
+++ b/src/applications/notification/controller/PhabricatorNotificationClearController.php
@@ -1,54 +1,53 @@
getRequest();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
$chrono_key = $request->getStr('chronoKey');
- $user = $request->getUser();
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(),
- $user->getPHID(),
+ $viewer->getPHID(),
$chrono_key);
return id(new AphrontReloadResponse())
->setURI('/notification/');
}
$dialog = new AphrontDialogView();
- $dialog->setUser($user);
+ $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);
}
}
diff --git a/src/applications/notification/controller/PhabricatorNotificationIndividualController.php b/src/applications/notification/controller/PhabricatorNotificationIndividualController.php
index 6e6f7361df..68214d1965 100644
--- a/src/applications/notification/controller/PhabricatorNotificationIndividualController.php
+++ b/src/applications/notification/controller/PhabricatorNotificationIndividualController.php
@@ -1,60 +1,59 @@
getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
$stories = id(new PhabricatorNotificationQuery())
->setViewer($viewer)
->withUserPHIDs(array($viewer->getPHID()))
->withKeys(array($request->getStr('key')))
->execute();
if (!$stories) {
return $this->buildEmptyResponse();
}
$story = head($stories);
if ($story->getAuthorPHID() === $viewer->getPHID()) {
// Don't show the user individual notifications about their own
// actions. Primarily, this stops pages from showing notifications
// immediately after you click "Submit" on a comment form if the
// notification server returns faster than the web server.
// TODO: It would be nice to retain the "page updated" bubble on copies
// of the page that are open in other tabs, but there isn't an obvious
// way to do this easily.
return $this->buildEmptyResponse();
}
$builder = new PhabricatorNotificationBuilder(array($story));
$content = $builder->buildView()->render();
$dict = $builder->buildDict();
$data = $dict[0];
$response = array(
'pertinent' => true,
'primaryObjectPHID' => $story->getPrimaryObjectPHID(),
'desktopReady' => $data['desktopReady'],
'href' => $data['href'],
'icon' => $data['icon'],
'title' => $data['title'],
'body' => $data['body'],
'content' => hsprintf('%s', $content),
);
return id(new AphrontAjaxResponse())->setContent($response);
}
private function buildEmptyResponse() {
return id(new AphrontAjaxResponse())->setContent(
array(
'pertinent' => false,
));
}
}
diff --git a/src/applications/notification/controller/PhabricatorNotificationListController.php b/src/applications/notification/controller/PhabricatorNotificationListController.php
index b7ab15df90..718c2431a1 100644
--- a/src/applications/notification/controller/PhabricatorNotificationListController.php
+++ b/src/applications/notification/controller/PhabricatorNotificationListController.php
@@ -1,35 +1,31 @@
getURIData('queryKey');
- public function willProcessRequest(array $data) {
- $this->queryKey = idx($data, 'queryKey');
- }
-
- public function processRequest() {
$controller = id(new PhabricatorApplicationSearchController())
- ->setQueryKey($this->queryKey)
+ ->setQueryKey($querykey)
->setSearchEngine(new PhabricatorNotificationSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function buildSideNavView() {
- $user = $this->getRequest()->getUser();
+ $viewer = $this->getViewer();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
id(new PhabricatorNotificationSearchEngine())
- ->setViewer($user)
+ ->setViewer($viewer)
->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav;
}
}
diff --git a/src/applications/notification/controller/PhabricatorNotificationPanelController.php b/src/applications/notification/controller/PhabricatorNotificationPanelController.php
index 3e8f16b07a..c16069a0e6 100644
--- a/src/applications/notification/controller/PhabricatorNotificationPanelController.php
+++ b/src/applications/notification/controller/PhabricatorNotificationPanelController.php
@@ -1,93 +1,91 @@
getRequest();
- $user = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
$query = id(new PhabricatorNotificationQuery())
- ->setViewer($user)
- ->withUserPHIDs(array($user->getPHID()))
+ ->setViewer($viewer)
+ ->withUserPHIDs(array($viewer->getPHID()))
->setLimit(15);
$stories = $query->execute();
$clear_ui_class = 'phabricator-notification-clear-all';
$clear_uri = id(new PhutilURI('/notification/clear/'));
if ($stories) {
$builder = new PhabricatorNotificationBuilder($stories);
$notifications_view = $builder->buildView();
$content = $notifications_view->render();
$clear_uri->setQueryParam(
'chronoKey',
head($stories)->getChronologicalKey());
} else {
$content = phutil_tag_div(
'phabricator-notification no-notifications',
pht('You have no notifications.'));
$clear_ui_class .= ' disabled';
}
$clear_ui = javelin_tag(
'a',
array(
'sigil' => 'workflow',
'href' => (string)$clear_uri,
'class' => $clear_ui_class,
),
pht('Mark All Read'));
$notifications_link = phutil_tag(
'a',
array(
'href' => '/notification/',
),
pht('Notifications'));
if (PhabricatorEnv::getEnvConfig('notification.enabled')) {
$connection_status = new PhabricatorNotificationStatusView();
} else {
$connection_status = phutil_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'Notifications User Guide: Setup and Configuration'),
),
pht('Notification Server not enabled.'));
}
$connection_ui = phutil_tag(
'div',
array(
'class' => 'phabricator-notification-footer',
),
$connection_status);
$header = phutil_tag(
'div',
array(
'class' => 'phabricator-notification-header',
),
array(
$notifications_link,
$clear_ui,
));
$content = hsprintf(
'%s%s%s',
$header,
$content,
$connection_ui);
$unread_count = id(new PhabricatorFeedStoryNotification())
- ->countUnread($user);
+ ->countUnread($viewer);
$json = array(
'content' => $content,
'number' => (int)$unread_count,
);
return id(new AphrontAjaxResponse())->setContent($json);
}
}
diff --git a/src/applications/notification/controller/PhabricatorNotificationStatusController.php b/src/applications/notification/controller/PhabricatorNotificationStatusController.php
index 2c9e308985..e889c7af5e 100644
--- a/src/applications/notification/controller/PhabricatorNotificationStatusController.php
+++ b/src/applications/notification/controller/PhabricatorNotificationStatusController.php
@@ -1,84 +1,85 @@
renderServerStatus($status);
} catch (Exception $ex) {
$status = new PHUIInfoView();
$status->setTitle(pht('Notification Server Issue'));
$status->appendChild(hsprintf(
'%s
'.
'%s %s',
pht(
'Unable to determine server status. This probably means the server '.
'is not in great shape. The specific issue encountered was:'),
get_class($ex),
phutil_escape_html_newlines($ex->getMessage())));
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Status'));
return $this->buildApplicationPage(
array(
$crumbs,
$status,
),
array(
'title' => pht('Notification Server Status'),
'device' => false,
));
}
private function renderServerStatus(array $status) {
$rows = array();
foreach ($status as $key => $value) {
switch ($key) {
case 'uptime':
$value /= 1000;
$value = phutil_format_relative_time_detailed($value);
break;
case 'log':
case 'instance':
break;
default:
$value = number_format($value);
break;
}
$rows[] = array($key, $value);
}
$table = new AphrontTableView($rows);
$table->setColumnClasses(
array(
'header',
'wide',
));
$test_icon = id(new PHUIIconView())
->setIconFont('fa-exclamation-triangle');
$test_button = id(new PHUIButtonView())
->setTag('a')
->setWorkflow(true)
->setText(pht('Send Test Notification'))
->setHref($this->getApplicationURI('test/'))
->setIcon($test_icon);
$header = id(new PHUIHeaderView())
->setHeader(pht('Notification Server Status'))
->addActionLink($test_button);
$box = id(new PHUIObjectBoxView())
->setHeader($header)
->appendChild($table);
return $box;
}
}
diff --git a/src/applications/notification/controller/PhabricatorNotificationTestController.php b/src/applications/notification/controller/PhabricatorNotificationTestController.php
index 706242818c..5c76e53357 100644
--- a/src/applications/notification/controller/PhabricatorNotificationTestController.php
+++ b/src/applications/notification/controller/PhabricatorNotificationTestController.php
@@ -1,43 +1,42 @@
getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
$story_type = 'PhabricatorNotificationTestFeedStory';
$story_data = array(
'title' => pht(
'This is a test notification, sent at %s.',
phabricator_datetime(time(), $viewer)),
);
$viewer_phid = $viewer->getPHID();
// NOTE: Because we don't currently show you your own notifications, make
// sure this comes from a different PHID.
$application_phid = id(new PhabricatorNotificationsApplication())
->getPHID();
// TODO: When it's easier to get these buttons to render as forms, this
// would be slightly nicer as a more standard isFormPost() check.
if ($request->validateCSRF()) {
id(new PhabricatorFeedStoryPublisher())
->setStoryType($story_type)
->setStoryData($story_data)
->setStoryTime(time())
->setStoryAuthorPHID($application_phid)
->setRelatedPHIDs(array($viewer_phid))
->setPrimaryObjectPHID($viewer_phid)
->setSubscribedPHIDs(array($viewer_phid))
->setNotifyAuthor(true)
->publish();
}
return id(new AphrontAjaxResponse());
}
}