2012-06-11 09:37:06 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorNotificationPanelController
|
|
|
|
extends PhabricatorNotificationController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$query = new PhabricatorNotificationQuery();
|
2012-10-23 12:01:59 -07:00
|
|
|
$query->setViewer($user);
|
2012-06-11 09:37:06 -07:00
|
|
|
$query->setUserPHID($user->getPHID());
|
|
|
|
$query->setLimit(15);
|
|
|
|
|
|
|
|
$stories = $query->execute();
|
|
|
|
|
2012-06-17 11:35:18 -07:00
|
|
|
if ($stories) {
|
|
|
|
$builder = new PhabricatorNotificationBuilder($stories);
|
|
|
|
$notifications_view = $builder->buildView();
|
|
|
|
$content = $notifications_view->render();
|
|
|
|
} else {
|
2013-02-13 14:50:15 -08:00
|
|
|
$content = hsprintf(
|
|
|
|
'<div class="phabricator-notification no-notifications">%s</div>',
|
|
|
|
pht('You have no notifications.'));
|
2012-06-11 17:49:32 -07:00
|
|
|
}
|
|
|
|
|
2013-02-13 14:50:15 -08:00
|
|
|
$content = hsprintf(
|
|
|
|
'<div class="phabricator-notification-header">%s</div>'.
|
|
|
|
'%s'.
|
|
|
|
'<div class="phabricator-notification-view-all">%s</div>',
|
|
|
|
pht('Notifications'),
|
|
|
|
$content,
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/notification/',
|
|
|
|
),
|
|
|
|
'View All Notifications'));
|
2012-06-18 14:07:38 -07:00
|
|
|
|
2012-06-20 13:20:41 -07:00
|
|
|
$unread_count = id(new PhabricatorFeedStoryNotification())
|
|
|
|
->countUnread($user);
|
|
|
|
|
2012-06-11 09:37:06 -07:00
|
|
|
$json = array(
|
2012-06-17 11:35:18 -07:00
|
|
|
'content' => $content,
|
2012-06-20 13:20:41 -07:00
|
|
|
'number' => $unread_count,
|
2012-06-11 09:37:06 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($json);
|
|
|
|
}
|
|
|
|
}
|