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:50:15 +01:00
|
|
|
$content = hsprintf(
|
|
|
|
'<div class="phabricator-notification no-notifications">%s</div>',
|
|
|
|
pht('You have no notifications.'));
|
2012-06-12 02:49:32 +02:00
|
|
|
}
|
|
|
|
|
2013-02-13 23:50:15 +01: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 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,
|
2013-05-22 00:44:44 +02:00
|
|
|
'number' => (int)$unread_count,
|
2012-06-11 18:37:06 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($json);
|
|
|
|
}
|
|
|
|
}
|