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