[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/notification/controller/ -> PhabricatorNotificationPanelController.php (source)

   1  <?php
   2  
   3  final class PhabricatorNotificationPanelController
   4    extends PhabricatorNotificationController {
   5  
   6    public function processRequest() {
   7  
   8      $request = $this->getRequest();
   9      $user = $request->getUser();
  10  
  11      $query = id(new PhabricatorNotificationQuery())
  12        ->setViewer($user)
  13        ->withUserPHIDs(array($user->getPHID()))
  14        ->setLimit(15);
  15  
  16      $stories = $query->execute();
  17  
  18      $clear_ui_class = 'phabricator-notification-clear-all';
  19      $clear_uri = id(new PhutilURI('/notification/clear/'));
  20      if ($stories) {
  21        $builder = new PhabricatorNotificationBuilder($stories);
  22        $notifications_view = $builder->buildView();
  23        $content = $notifications_view->render();
  24        $clear_uri->setQueryParam(
  25          'chronoKey',
  26          head($stories)->getChronologicalKey());
  27      } else {
  28        $content = phutil_tag_div(
  29          'phabricator-notification no-notifications',
  30          pht('You have no notifications.'));
  31        $clear_ui_class .= ' disabled';
  32      }
  33      $clear_ui = javelin_tag(
  34        'a',
  35        array(
  36          'sigil' => 'workflow',
  37          'href' => (string) $clear_uri,
  38          'class' => $clear_ui_class,
  39        ),
  40        pht('Mark All Read'));
  41  
  42      $notifications_link = phutil_tag(
  43        'a',
  44        array(
  45          'href' => '/notification/',
  46        ),
  47        pht('Notifications'));
  48  
  49      if (PhabricatorEnv::getEnvConfig('notification.enabled')) {
  50        $connection_status = new PhabricatorNotificationStatusView();
  51      } else {
  52        $connection_status = phutil_tag(
  53          'a',
  54          array(
  55            'href' => PhabricatorEnv::getDoclink(
  56              'Notifications User Guide: Setup and Configuration'),
  57          ),
  58          pht('Notification Server not enabled.'));
  59      }
  60      $connection_ui = phutil_tag(
  61        'div',
  62        array(
  63          'class' => 'phabricator-notification-footer',
  64        ),
  65        $connection_status);
  66  
  67      $header = phutil_tag(
  68        'div',
  69        array(
  70          'class' => 'phabricator-notification-header',
  71        ),
  72        array(
  73          $notifications_link,
  74          $clear_ui,
  75        ));
  76  
  77      $content = hsprintf(
  78        '%s%s%s',
  79        $header,
  80        $content,
  81        $connection_ui);
  82  
  83      $unread_count = id(new PhabricatorFeedStoryNotification())
  84        ->countUnread($user);
  85  
  86      $json = array(
  87        'content' => $content,
  88        'number'  => (int)$unread_count,
  89      );
  90  
  91      return id(new AphrontAjaxResponse())->setContent($json);
  92    }
  93  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1