[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/people/application/ -> PhabricatorPeopleApplication.php (source)

   1  <?php
   2  
   3  final class PhabricatorPeopleApplication extends PhabricatorApplication {
   4  
   5    public function getName() {
   6      return pht('People');
   7    }
   8  
   9    public function getShortDescription() {
  10      return pht('User Accounts and Profiles');
  11    }
  12  
  13    public function getBaseURI() {
  14      return '/people/';
  15    }
  16  
  17    public function getTitleGlyph() {
  18      return "\xE2\x99\x9F";
  19    }
  20  
  21    public function getIconName() {
  22      return 'people';
  23    }
  24  
  25    public function isPinnedByDefault(PhabricatorUser $viewer) {
  26      return $viewer->getIsAdmin();
  27    }
  28  
  29    public function getFlavorText() {
  30      return pht('Sort of a social utility.');
  31    }
  32  
  33    public function canUninstall() {
  34      return false;
  35    }
  36  
  37    public function getEventListeners() {
  38      return array(
  39        new PhabricatorPeopleHovercardEventListener(),
  40      );
  41    }
  42  
  43    public function getRoutes() {
  44      return array(
  45        '/people/' => array(
  46          '(query/(?P<key>[^/]+)/)?' => 'PhabricatorPeopleListController',
  47          'logs/(?:query/(?P<queryKey>[^/]+)/)?'
  48            => 'PhabricatorPeopleLogsController',
  49          'approve/(?P<id>[1-9]\d*)/' => 'PhabricatorPeopleApproveController',
  50          '(?P<via>disapprove)/(?P<id>[1-9]\d*)/'
  51            => 'PhabricatorPeopleDisableController',
  52          '(?P<via>disable)/(?P<id>[1-9]\d*)/'
  53            => 'PhabricatorPeopleDisableController',
  54          'empower/(?P<id>[1-9]\d*)/' => 'PhabricatorPeopleEmpowerController',
  55          'delete/(?P<id>[1-9]\d*)/' => 'PhabricatorPeopleDeleteController',
  56          'rename/(?P<id>[1-9]\d*)/' => 'PhabricatorPeopleRenameController',
  57          'welcome/(?P<id>[1-9]\d*)/' => 'PhabricatorPeopleWelcomeController',
  58          'create/' => 'PhabricatorPeopleCreateController',
  59          'new/(?P<type>[^/]+)/' => 'PhabricatorPeopleNewController',
  60          'ldap/' => 'PhabricatorPeopleLdapController',
  61          'editprofile/(?P<id>[1-9]\d*)/' =>
  62            'PhabricatorPeopleProfileEditController',
  63          'picture/(?P<id>[1-9]\d*)/' =>
  64            'PhabricatorPeopleProfilePictureController',
  65        ),
  66        '/p/(?P<username>[\w._-]+)/'
  67          => 'PhabricatorPeopleProfileController',
  68        '/p/(?P<username>[\w._-]+)/calendar/'
  69          => 'PhabricatorPeopleCalendarController',
  70      );
  71    }
  72  
  73    public function getRemarkupRules() {
  74      return array(
  75        new PhabricatorMentionRemarkupRule(),
  76      );
  77    }
  78  
  79    protected function getCustomCapabilities() {
  80      return array(
  81        PeopleBrowseUserDirectoryCapability::CAPABILITY => array(),
  82      );
  83    }
  84  
  85    public function loadStatus(PhabricatorUser $user) {
  86      if (!$user->getIsAdmin()) {
  87        return array();
  88      }
  89  
  90      $need_approval = id(new PhabricatorPeopleQuery())
  91        ->setViewer($user)
  92        ->withIsApproved(false)
  93        ->withIsDisabled(false)
  94        ->execute();
  95  
  96      if (!$need_approval) {
  97        return array();
  98      }
  99  
 100      $status = array();
 101  
 102      $count = count($need_approval);
 103      $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
 104      $status[] = id(new PhabricatorApplicationStatusView())
 105        ->setType($type)
 106        ->setText(pht('%d User(s) Need Approval', $count))
 107        ->setCount($count);
 108  
 109      return $status;
 110    }
 111  
 112    public function buildMainMenuItems(
 113      PhabricatorUser $user,
 114      PhabricatorController $controller = null) {
 115  
 116      $items = array();
 117  
 118      if ($user->isLoggedIn() && $user->isUserActivated()) {
 119        $image = $user->loadProfileImageURI();
 120  
 121        $item = id(new PHUIListItemView())
 122          ->setName($user->getUsername())
 123          ->setHref('/p/'.$user->getUsername().'/')
 124          ->addClass('core-menu-item')
 125          ->setAural(pht('Profile'))
 126          ->setOrder(100);
 127  
 128        $classes = array(
 129          'phabricator-core-menu-icon',
 130          'phabricator-core-menu-profile-image',
 131        );
 132  
 133        $item->appendChild(
 134          phutil_tag(
 135            'span',
 136            array(
 137              'class' => implode(' ', $classes),
 138              'style' => 'background-image: url('.$image.')',
 139            ),
 140            ''));
 141  
 142        $items[] = $item;
 143      }
 144  
 145      return $items;
 146    }
 147  
 148  
 149    public function getQuickCreateItems(PhabricatorUser $viewer) {
 150      $items = array();
 151  
 152      if ($viewer->getIsAdmin()) {
 153        $item = id(new PHUIListItemView())
 154          ->setName(pht('User Account'))
 155          ->setIcon('fa-users')
 156          ->setHref($this->getBaseURI().'create/');
 157        $items[] = $item;
 158      }
 159  
 160      return $items;
 161    }
 162  
 163  }


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