private function buildActionView(PhabricatorUser $user, PhabricatorApplication $selected)
 {
     $view = id(new PhabricatorActionListView())->setUser($user)->setObjectURI($this->getRequest()->getRequestURI());
     if ($selected->getHelpURI()) {
         $view->addAction(id(new PhabricatorActionView())->setName(pht('Help / Documentation'))->setIcon('fa-life-ring')->setHref($selected->getHelpURI()));
     }
     $can_edit = PhabricatorPolicyFilter::hasCapability($user, $selected, PhabricatorPolicyCapability::CAN_EDIT);
     $edit_uri = $this->getApplicationURI('edit/' . get_class($selected) . '/');
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Policies'))->setIcon('fa-pencil')->setDisabled(!$can_edit)->setWorkflow(!$can_edit)->setHref($edit_uri));
     if ($selected->canUninstall()) {
         if ($selected->isInstalled()) {
             $view->addAction(id(new PhabricatorActionView())->setName(pht('Uninstall'))->setIcon('fa-times')->setDisabled(!$can_edit)->setWorkflow(true)->setHref($this->getApplicationURI(get_class($selected) . '/uninstall/')));
         } else {
             $action = id(new PhabricatorActionView())->setName(pht('Install'))->setIcon('fa-plus')->setDisabled(!$can_edit)->setWorkflow(true)->setHref($this->getApplicationURI(get_class($selected) . '/install/'));
             $beta_enabled = PhabricatorEnv::getEnvConfig('phabricator.show-beta-applications');
             if ($selected->isBeta() && !$beta_enabled) {
                 $action->setDisabled(true);
             }
             $view->addAction($action);
         }
     } else {
         $view->addAction(id(new PhabricatorActionView())->setName(pht('Uninstall'))->setIcon('fa-times')->setWorkflow(true)->setDisabled(true)->setHref($this->getApplicationURI(get_class($selected) . '/uninstall/')));
     }
     return $view;
 }
 protected final function canAcceptApplicationMail(PhabricatorApplication $app, PhabricatorMetaMTAReceivedMail $mail)
 {
     $application_emails = id(new PhabricatorMetaMTAApplicationEmailQuery())->setViewer($this->getViewer())->withApplicationPHIDs(array($app->getPHID()))->execute();
     foreach ($mail->getToAddresses() as $to_address) {
         foreach ($application_emails as $application_email) {
             $create_address = $application_email->getAddress();
             if ($this->matchAddresses($create_address, $to_address)) {
                 $this->setApplicationEmail($application_email);
                 return true;
             }
         }
     }
     return false;
 }
 public static function loadForRevision($revision)
 {
     $app_legalpad = 'PhabricatorLegalpadApplication';
     if (!PhabricatorApplication::isClassInstalled($app_legalpad)) {
         return array();
     }
     if (!$revision->getPHID()) {
         return array();
     }
     $phids = PhabricatorEdgeQuery::loadDestinationPHIDs($revision->getPHID(), LegalpadObjectNeedsSignatureEdgeType::EDGECONST);
     if ($phids) {
         // NOTE: We're bypassing permissions to pull these. We have to expose
         // some information about signature status in order to implement this
         // field meaningfully (otherwise, we could not tell reviewers that they
         // can't accept the revision yet), but that's OK because the only way to
         // require signatures is with a "Global" Herald rule, which requires a
         // high level of access.
         $signatures = id(new LegalpadDocumentSignatureQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withDocumentPHIDs($phids)->withSignerPHIDs(array($revision->getAuthorPHID()))->execute();
         $signatures = mpull($signatures, null, 'getDocumentPHID');
         $phids = array_fuse($phids);
         foreach ($phids as $phid) {
             $phids[$phid] = isset($signatures[$phid]);
         }
     }
     return $phids;
 }
 public function execute()
 {
     $viewer = $this->getViewer();
     $conpherence_app = 'PhabricatorConpherenceApplication';
     $is_c_installed = PhabricatorApplication::isClassInstalledForViewer($conpherence_app, $viewer);
     $raw_message_count_number = null;
     $message_count_number = null;
     if ($is_c_installed) {
         $unread_status = ConpherenceParticipationStatus::BEHIND;
         $unread = id(new ConpherenceParticipantCountQuery())->withParticipantPHIDs(array($viewer->getPHID()))->withParticipationStatus($unread_status)->execute();
         $raw_message_count_number = idx($unread, $viewer->getPHID(), 0);
         $message_count_number = $this->formatNumber($raw_message_count_number);
     }
     $conpherence_data = array('isInstalled' => $is_c_installed, 'countType' => 'messages', 'count' => $message_count_number, 'rawCount' => $raw_message_count_number);
     $this->setConpherenceData($conpherence_data);
     $notification_app = 'PhabricatorNotificationsApplication';
     $is_n_installed = PhabricatorApplication::isClassInstalledForViewer($notification_app, $viewer);
     $notification_count_number = null;
     $raw_notification_count_number = null;
     if ($is_n_installed) {
         $raw_notification_count_number = id(new PhabricatorFeedStoryNotification())->countUnread($viewer);
         $notification_count_number = $this->formatNumber($raw_notification_count_number);
     }
     $notification_data = array('isInstalled' => $is_n_installed, 'countType' => 'notifications', 'count' => $notification_count_number, 'rawCount' => $raw_notification_count_number);
     $this->setNotificationData($notification_data);
     return array($notification_app => $this->getNotificationData(), $conpherence_app => $this->getConpherenceData());
 }
 public function publishNotifications()
 {
     $cursor = $this->getCursor();
     $now = PhabricatorTime::getNow();
     if ($cursor > $now) {
         return;
     }
     $calendar_class = 'PhabricatorCalendarApplication';
     if (!PhabricatorApplication::isClassInstalled($calendar_class)) {
         return;
     }
     try {
         $lock = PhabricatorGlobalLock::newLock('calendar.notify')->lock(5);
     } catch (PhutilLockException $ex) {
         return;
     }
     $caught = null;
     try {
         $this->sendNotifications();
     } catch (Exception $ex) {
         $caught = $ex;
     }
     $lock->unlock();
     // Wait a little while before checking for new notifications to send.
     $this->setCursor($cursor + phutil_units('1 minute in seconds'));
     if ($caught) {
         throw $caught;
     }
 }
 private function buildMainResponse(array $projects)
 {
     assert_instances_of($projects, 'PhabricatorProject');
     $viewer = $this->getRequest()->getUser();
     $has_maniphest = PhabricatorApplication::isClassInstalledForViewer('PhabricatorManiphestApplication', $viewer);
     $has_audit = PhabricatorApplication::isClassInstalledForViewer('PhabricatorAuditApplication', $viewer);
     $has_differential = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDifferentialApplication', $viewer);
     if ($has_maniphest) {
         $unbreak_panel = $this->buildUnbreakNowPanel();
         $triage_panel = $this->buildNeedsTriagePanel($projects);
         $tasks_panel = $this->buildTasksPanel();
     } else {
         $unbreak_panel = null;
         $triage_panel = null;
         $tasks_panel = null;
     }
     if ($has_audit) {
         $audit_panel = $this->buildAuditPanel();
         $commit_panel = $this->buildCommitPanel();
     } else {
         $audit_panel = null;
         $commit_panel = null;
     }
     if (PhabricatorEnv::getEnvConfig('welcome.html') !== null) {
         $welcome_panel = $this->buildWelcomePanel();
     } else {
         $welcome_panel = null;
     }
     if ($has_differential) {
         $revision_panel = $this->buildRevisionPanel();
     } else {
         $revision_panel = null;
     }
     return array($welcome_panel, $unbreak_panel, $triage_panel, $revision_panel, $tasks_panel, $audit_panel, $commit_panel, $this->minipanels);
 }
 private function buildMainResponse()
 {
     require_celerity_resource('phabricator-dashboard-css');
     $viewer = $this->getViewer();
     $has_maniphest = PhabricatorApplication::isClassInstalledForViewer('PhabricatorManiphestApplication', $viewer);
     $has_diffusion = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDiffusionApplication', $viewer);
     $has_differential = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDifferentialApplication', $viewer);
     $revision_panel = null;
     if ($has_differential) {
         $revision_panel = $this->buildRevisionPanel();
     }
     $tasks_panel = null;
     if ($has_maniphest) {
         $tasks_panel = $this->buildTasksPanel();
     }
     $repository_panel = null;
     if ($has_diffusion) {
         $repository_panel = $this->buildRepositoryPanel();
     }
     $feed_panel = $this->buildFeedPanel();
     $dashboard = id(new AphrontMultiColumnView())->setFluidlayout(true)->setGutter(AphrontMultiColumnView::GUTTER_LARGE);
     $main_panel = phutil_tag('div', array('class' => 'homepage-panel'), array($revision_panel, $tasks_panel, $repository_panel));
     $dashboard->addColumn($main_panel, 'thirds');
     $side_panel = phutil_tag('div', array('class' => 'homepage-side-panel'), array($feed_panel));
     $dashboard->addColumn($side_panel, 'third');
     $view = id(new PHUIBoxView())->addClass('dashboard-view')->appendChild($dashboard);
     return $view;
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $selected = PhabricatorApplication::getByClass($this->application);
     if (!$selected) {
         return new Aphront404Response();
     }
     $view_uri = $this->getApplicationURI('view/' . $this->application);
     $beta_enabled = PhabricatorEnv::getEnvConfig('phabricator.show-beta-applications');
     $dialog = id(new AphrontDialogView())->setUser($user)->addCancelButton($view_uri);
     if ($selected->isBeta() && !$beta_enabled) {
         $dialog->setTitle(pht('Beta Applications Not Enabled'))->appendChild(pht('To manage beta applications, enable them by setting %s in your ' . 'Phabricator configuration.', phutil_tag('tt', array(), 'phabricator.show-beta-applications')));
         return id(new AphrontDialogResponse())->setDialog($dialog);
     }
     if ($request->isDialogFormPost()) {
         $this->manageApplication();
         return id(new AphrontRedirectResponse())->setURI($view_uri);
     }
     if ($this->action == 'install') {
         if ($selected->canUninstall()) {
             $dialog->setTitle('Confirmation')->appendChild('Install ' . $selected->getName() . ' application?')->addSubmitButton('Install');
         } else {
             $dialog->setTitle('Information')->appendChild('You cannot install an installed application.');
         }
     } else {
         if ($selected->canUninstall()) {
             $dialog->setTitle('Confirmation')->appendChild('Really Uninstall ' . $selected->getName() . ' application?')->addSubmitButton('Uninstall');
         } else {
             $dialog->setTitle('Information')->appendChild('This application cannot be uninstalled,
              because it is required for Phabricator to work.');
         }
     }
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 private function executeManiphestFieldChecks()
 {
     $maniphest_appclass = 'PhabricatorManiphestApplication';
     if (!PhabricatorApplication::isClassInstalled($maniphest_appclass)) {
         return;
     }
     $capabilities = array(ManiphestEditAssignCapability::CAPABILITY, ManiphestEditPoliciesCapability::CAPABILITY, ManiphestEditPriorityCapability::CAPABILITY, ManiphestEditProjectsCapability::CAPABILITY, ManiphestEditStatusCapability::CAPABILITY);
     // Check for any of these capabilities set to anything other than
     // "All Users".
     $any_set = false;
     $app = new PhabricatorManiphestApplication();
     foreach ($capabilities as $capability) {
         $setting = $app->getPolicy($capability);
         if ($setting != PhabricatorPolicies::POLICY_USER) {
             $any_set = true;
             break;
         }
     }
     if (!$any_set) {
         return;
     }
     $issue_summary = pht('Maniphest is currently configured with deprecated policy settings ' . 'which will be removed in a future version of Phabricator.');
     $message = pht('Some policy settings in Maniphest are now deprecated and will be ' . 'removed in a future version of Phabricator. You are currently using ' . 'at least one of these settings.' . "\n\n" . 'The deprecated settings are "Can Assign Tasks", ' . '"Can Edit Task Policies", "Can Prioritize Tasks", ' . '"Can Edit Task Projects", and "Can Edit Task Status". You can ' . 'find these settings in Applications, or follow the link below.' . "\n\n" . 'You can find discussion of this change (including rationale and ' . 'recommendations on how to configure similar features) in the upstream, ' . 'at the link below.' . "\n\n" . 'To resolve this issue, set all of these policies to "All Users" after ' . 'making any necessary form customization changes.');
     $more_href = 'https://secure.phabricator.com/T10003';
     $edit_href = '/applications/view/PhabricatorManiphestApplication/';
     $issue = $this->newIssue('maniphest.T10003-per-field-policies')->setShortName(pht('Deprecated Policies'))->setName(pht('Deprecated Maniphest Field Policies'))->setSummary($issue_summary)->setMessage($message)->addLink($more_href, pht('Learn More: Upstream Discussion'))->addLink($edit_href, pht('Edit These Settings'));
 }
 public function execute()
 {
     $viewer = $this->getViewer();
     $conpherence_app = 'PhabricatorConpherenceApplication';
     $is_c_installed = PhabricatorApplication::isClassInstalledForViewer($conpherence_app, $viewer);
     if ($is_c_installed) {
         $raw_message_count_number = $viewer->getUnreadMessageCount();
         $message_count_number = $this->formatNumber($raw_message_count_number);
     } else {
         $raw_message_count_number = null;
         $message_count_number = null;
     }
     $conpherence_data = array('isInstalled' => $is_c_installed, 'countType' => 'messages', 'count' => $message_count_number, 'rawCount' => $raw_message_count_number);
     $this->setConpherenceData($conpherence_data);
     $notification_app = 'PhabricatorNotificationsApplication';
     $is_n_installed = PhabricatorApplication::isClassInstalledForViewer($notification_app, $viewer);
     if ($is_n_installed) {
         $raw_notification_count_number = $viewer->getUnreadNotificationCount();
         $notification_count_number = $this->formatNumber($raw_notification_count_number);
     } else {
         $notification_count_number = null;
         $raw_notification_count_number = null;
     }
     $notification_data = array('isInstalled' => $is_n_installed, 'countType' => 'notifications', 'count' => $notification_count_number, 'rawCount' => $raw_notification_count_number);
     $this->setNotificationData($notification_data);
     return array($notification_app => $this->getNotificationData(), $conpherence_app => $this->getConpherenceData());
 }
 public function buildIconNavView(PhabricatorUser $user)
 {
     $viewer = $this->getViewer();
     $picture = $user->getProfileImageURI();
     $name = $user->getUsername();
     $nav = new AphrontSideNavFilterView();
     $nav->setIconNav(true);
     $nav->setBaseURI(new PhutilURI('/p/'));
     $nav->addIcon("{$name}/", $name, null, $picture);
     $class = 'PhabricatorCalendarApplication';
     if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
         $nav->addIcon("{$name}/calendar/", pht('Calendar'), 'fa-calendar');
     }
     $class = 'PhabricatorManiphestApplication';
     if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
         $phid = $user->getPHID();
         $view_uri = sprintf('/maniphest/?statuses=open()&assigned=%s#R', $phid);
         $nav->addIcon('maniphest', pht('Open Tasks'), 'fa-anchor', null, $view_uri);
     }
     $class = 'PhabricatorDifferentialApplication';
     if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
         $username = phutil_escape_uri($name);
         $view_uri = '/differential/?authors=' . $username;
         $nav->addIcon('differential', pht('Revisions'), 'fa-cog', null, $view_uri);
     }
     $class = 'PhabricatorAuditApplication';
     if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
         $username = phutil_escape_uri($name);
         $view_uri = '/audit/?authors=' . $username;
         $nav->addIcon('audit', pht('Commits'), 'fa-code', null, $view_uri);
     }
     return $nav;
 }
 public function handleRequestException(AphrontRequest $request, Exception $ex)
 {
     $viewer = $this->getViewer($request);
     if (!$viewer->isLoggedIn()) {
         // If the user isn't logged in, just give them a login form. This is
         // probably a generally more useful response than a policy dialog that
         // they have to click through to get a login form.
         //
         // Possibly we should add a header here like "you need to login to see
         // the thing you are trying to look at".
         $auth_app_class = 'PhabricatorAuthApplication';
         $auth_app = PhabricatorApplication::getByClass($auth_app_class);
         return id(new PhabricatorAuthStartController())->setRequest($request)->setCurrentApplication($auth_app)->handleRequest($request);
     }
     $content = array(phutil_tag('div', array('class' => 'aphront-policy-rejection'), $ex->getRejection()));
     $list = null;
     if ($ex->getCapabilityName()) {
         $list = $ex->getMoreInfo();
         foreach ($list as $key => $item) {
             $list[$key] = $item;
         }
         $content[] = phutil_tag('div', array('class' => 'aphront-capability-details'), pht('Users with the "%s" capability:', $ex->getCapabilityName()));
     }
     $dialog = id(new AphrontDialogView())->setTitle($ex->getTitle())->setClass('aphront-access-dialog')->setUser($viewer)->appendChild($content);
     if ($list) {
         $dialog->appendList($list);
     }
     if ($request->isAjax()) {
         $dialog->addCancelButton('/', pht('Close'));
     } else {
         $dialog->addCancelButton('/', pht('OK'));
     }
     return $dialog;
 }
 public function buildIconNavView(PhabricatorProject $project)
 {
     $this->setProject($project);
     $viewer = $this->getViewer();
     $id = $project->getID();
     $picture = $project->getProfileImageURI();
     $name = $project->getName();
     $columns = id(new PhabricatorProjectColumnQuery())->setViewer($viewer)->withProjectPHIDs(array($project->getPHID()))->execute();
     if ($columns) {
         $board_icon = 'fa-columns';
     } else {
         $board_icon = 'fa-columns grey';
     }
     $nav = new AphrontSideNavFilterView();
     $nav->setIconNav(true);
     $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
     $nav->addIcon("profile/{$id}/", $name, null, $picture);
     $class = 'PhabricatorManiphestApplication';
     if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
         $phid = $project->getPHID();
         $nav->addIcon("board/{$id}/", pht('Workboard'), $board_icon);
         $query_uri = urisprintf('/maniphest/?statuses=open()&projects=%s#R', $phid);
         $nav->addIcon(null, pht('Open Tasks'), 'fa-anchor', null, $query_uri);
     }
     $nav->addIcon("feed/{$id}/", pht('Feed'), 'fa-newspaper-o');
     $nav->addIcon("members/{$id}/", pht('Members'), 'fa-group');
     $nav->addIcon("details/{$id}/", pht('Edit Details'), 'fa-pencil');
     return $nav;
 }
 public function renderView()
 {
     $view = $this->newStoryView();
     $handle = $this->getHandle($this->getPrimaryObjectPHID());
     $view->setHref($handle->getURI());
     $type = phid_get_type($handle->getPHID());
     $phid_types = PhabricatorPHIDType::getAllTypes();
     $icon = null;
     if (!empty($phid_types[$type])) {
         $phid_type = $phid_types[$type];
         $class = $phid_type->getPHIDTypeApplicationClass();
         if ($class) {
             $application = PhabricatorApplication::getByClass($class);
             $icon = $application->getIcon();
         }
     }
     $view->setAppIcon($icon);
     $xaction_phids = $this->getValue('transactionPHIDs');
     $xaction = $this->getPrimaryTransaction();
     $xaction->setHandles($this->getHandles());
     $view->setTitle($xaction->getTitleForFeed());
     foreach ($xaction_phids as $xaction_phid) {
         $secondary_xaction = $this->getObject($xaction_phid);
         $secondary_xaction->setHandles($this->getHandles());
         $body = $secondary_xaction->getBodyForFeed($this);
         if (nonempty($body)) {
             $view->appendChild($body);
         }
     }
     $view->setImage($this->getHandle($xaction->getAuthorPHID())->getImageURI());
     return $view;
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $applications = PhabricatorApplication::getAllInstalledApplications();
     foreach ($applications as $key => $application) {
         if (!$application->shouldAppearInLaunchView()) {
             unset($applications[$key]);
         }
     }
     $groups = PhabricatorApplication::getApplicationGroups();
     $applications = msort($applications, 'getApplicationOrder');
     $applications = mgroup($applications, 'getApplicationGroup');
     $applications = array_select_keys($applications, array_keys($groups));
     $view = array();
     foreach ($applications as $group => $application_list) {
         $status = array();
         foreach ($application_list as $key => $application) {
             $status[$key] = $application->loadStatus($user);
         }
         $views = array();
         foreach ($application_list as $key => $application) {
             $views[] = id(new PhabricatorApplicationLaunchView())->setApplication($application)->setApplicationStatus(idx($status, $key, array()))->setUser($user);
         }
         $view[] = id(new PhabricatorHeaderView())->setHeader($groups[$group]);
         $view[] = phutil_render_tag('div', array('class' => 'phabricator-application-list'), id(new AphrontNullView())->appendChild($views)->render());
     }
     return $this->buildApplicationPage($view, array('title' => 'Applications', 'device' => true));
 }
 protected function getBuiltinProfilePanels($object)
 {
     $viewer = $this->getViewer();
     $panels = array();
     $panels[] = $this->newPanel()->setBuiltinKey(self::PANEL_PROFILE)->setPanelKey(PhabricatorPeopleDetailsProfilePanel::PANELKEY);
     // TODO: Convert this into a proper panel type.
     $have_calendar = PhabricatorApplication::isClassInstalledForViewer('PhabricatorCalendarApplication', $viewer);
     if ($have_calendar) {
         $uri = urisprintf('/p/%s/calendar/', $object->getUsername());
         $panels[] = $this->newPanel()->setBuiltinKey('calendar')->setPanelKey(PhabricatorLinkProfilePanel::PANELKEY)->setPanelProperty('icon', 'calendar')->setPanelProperty('name', pht('Calendar'))->setPanelProperty('uri', $uri);
     }
     $have_maniphest = PhabricatorApplication::isClassInstalledForViewer('PhabricatorManiphestApplication', $viewer);
     if ($have_maniphest) {
         $uri = urisprintf('/maniphest/?statuses=open()&assigned=%s#R', $object->getPHID());
         $panels[] = $this->newPanel()->setBuiltinKey('tasks')->setPanelKey(PhabricatorLinkProfilePanel::PANELKEY)->setPanelProperty('icon', 'maniphest')->setPanelProperty('name', pht('Open Tasks'))->setPanelProperty('uri', $uri);
     }
     $have_differential = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDifferentialApplication', $viewer);
     if ($have_differential) {
         $uri = urisprintf('/differential/?authors=%s#R', $object->getPHID());
         $panels[] = $this->newPanel()->setBuiltinKey('revisions')->setPanelKey(PhabricatorLinkProfilePanel::PANELKEY)->setPanelProperty('icon', 'differential')->setPanelProperty('name', pht('Revisions'))->setPanelProperty('uri', $uri);
     }
     $have_diffusion = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDiffusionApplication', $viewer);
     if ($have_diffusion) {
         $uri = urisprintf('/audit/?authors=%s#R', $object->getPHID());
         $panels[] = $this->newPanel()->setBuiltinKey('commits')->setPanelKey(PhabricatorLinkProfilePanel::PANELKEY)->setPanelProperty('icon', 'diffusion')->setPanelProperty('name', pht('Commits'))->setPanelProperty('uri', $uri);
     }
     $panels[] = $this->newPanel()->setBuiltinKey(self::PANEL_MANAGE)->setPanelKey(PhabricatorPeopleManageProfilePanel::PANELKEY);
     return $panels;
 }
 public function buildNav()
 {
     $user = $this->getRequest()->getUser();
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/'));
     $applications = id(new PhabricatorApplicationQuery())->setViewer($user)->withInstalled(true)->withUnlisted(false)->withLaunchable(true)->execute();
     $pinned = $user->loadPreferences()->getPinnedApplications($applications, $user);
     // Force "Applications" to appear at the bottom.
     $meta_app = 'PhabricatorApplicationsApplication';
     $pinned = array_fuse($pinned);
     unset($pinned[$meta_app]);
     $pinned[$meta_app] = $meta_app;
     $applications[$meta_app] = PhabricatorApplication::getByClass($meta_app);
     $tiles = array();
     $home_app = new PhabricatorHomeApplication();
     $tiles[] = id(new PhabricatorApplicationLaunchView())->setApplication($home_app)->setApplicationStatus($home_app->loadStatus($user))->addClass('phabricator-application-launch-phone-only')->setUser($user);
     foreach ($pinned as $pinned_application) {
         if (empty($applications[$pinned_application])) {
             continue;
         }
         $application = $applications[$pinned_application];
         $tile = id(new PhabricatorApplicationLaunchView())->setApplication($application)->setApplicationStatus($application->loadStatus($user))->setUser($user);
         $tiles[] = $tile;
     }
     $nav->addCustomBlock(phutil_tag('div', array('class' => 'application-tile-group'), $tiles));
     $nav->addFilter('', pht('Customize Applications...'), '/settings/panel/home/');
     $nav->addClass('phabricator-side-menu-home');
     $nav->selectFilter(null);
     return $nav;
 }
Example #18
0
 public function getRoutingMaps()
 {
     $app = PhabricatorApplication::getByClass('PhabricatorPhameApplication');
     $maps = array();
     $maps[] = $this->newRoutingMap()->setApplication($app)->setRoutes($app->getBlogRoutes());
     return $maps;
 }
 public function isInstalled()
 {
     if (PhabricatorEnv::getEnvConfig('releeph.installed')) {
         return parent::isInstalled();
     }
     return false;
 }
 public function renderModuleStatus(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $types = PhabricatorPHIDType::getAllTypes();
     $types = msort($types, 'getTypeConstant');
     $rows = array();
     foreach ($types as $key => $type) {
         $class_name = $type->getPHIDTypeApplicationClass();
         if ($class_name !== null) {
             $app = PhabricatorApplication::getByClass($class_name);
             $app_name = $app->getName();
             $icon = $app->getFontIcon();
             if ($icon) {
                 $app_icon = id(new PHUIIconView())->setIcon($icon);
             } else {
                 $app_icon = null;
             }
         } else {
             $app_name = null;
             $app_icon = null;
         }
         $icon = $type->getTypeIcon();
         if ($icon) {
             $type_icon = id(new PHUIIconView())->setIcon($icon);
         } else {
             $type_icon = null;
         }
         $rows[] = array($type->getTypeConstant(), get_class($type), $app_icon, $app_name, $type_icon, $type->getTypeName());
     }
     $table = id(new AphrontTableView($rows))->setHeaders(array(pht('Constant'), pht('Class'), null, pht('Application'), null, pht('Name')))->setColumnClasses(array(null, 'pri', 'icon', null, 'icon', 'wide'));
     return id(new PHUIObjectBoxView())->setHeaderText(pht('PHID Types'))->setTable($table);
 }
 public function isEnabled()
 {
     $servers = PhabricatorNotificationServerRef::getEnabledAdminServers();
     if (!$servers) {
         return false;
     }
     return PhabricatorApplication::isClassInstalled('PhabricatorNotificationsApplication');
 }
 private function buildPropertyView(PhabricatorApplication $application, PhabricatorActionListView $actions)
 {
     $viewer = $this->getRequest()->getUser();
     $properties = id(new PHUIPropertyListView());
     $properties->setActionList($actions);
     $properties->addProperty(pht('Description'), $application->getShortDescription());
     if ($application->getFlavorText()) {
         $properties->addProperty(null, phutil_tag('em', array(), $application->getFlavorText()));
     }
     if ($application->isPrototype()) {
         $proto_href = PhabricatorEnv::getDoclink('User Guide: Prototype Applications');
         $learn_more = phutil_tag('a', array('href' => $proto_href, 'target' => '_blank'), pht('Learn More'));
         $properties->addProperty(pht('Prototype'), pht('This application is a prototype. %s', $learn_more));
     }
     $overview = $application->getOverview();
     if (strlen($overview)) {
         $overview = new PHUIRemarkupView($viewer, $overview);
         $properties->addSectionHeader(pht('Overview'), PHUIPropertyListView::ICON_SUMMARY);
         $properties->addTextContent($overview);
     }
     $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $application);
     $properties->addSectionHeader(pht('Policies'), 'fa-lock');
     foreach ($application->getCapabilities() as $capability) {
         $properties->addProperty($application->getCapabilityLabel($capability), idx($descriptions, $capability));
     }
     return $properties;
 }
 public function isEnabledForObject($object)
 {
     $viewer = $this->getViewer();
     $has_app = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDifferentialApplication', $viewer);
     if (!$has_app) {
         return false;
     }
     return $object instanceof DifferentialRevision;
 }
 public function isEnabledForObject($object)
 {
     $viewer = $this->getViewer();
     $has_app = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDiffusionApplication', $viewer);
     if (!$has_app) {
         return false;
     }
     return $object instanceof PhabricatorRepositoryCommit;
 }
 public function isEnabledForObject($object)
 {
     $viewer = $this->getViewer();
     $has_app = PhabricatorApplication::isClassInstalledForViewer('PhabricatorManiphestApplication', $viewer);
     if (!$has_app) {
         return false;
     }
     return $object instanceof ManiphestTask;
 }
 protected function execute(ConduitAPIRequest $request)
 {
     $authentication = array('token', 'asymmetric', 'session', 'sessionless');
     $oauth_app = 'PhabricatorOAuthServerApplication';
     if (PhabricatorApplication::isClassInstalled($oauth_app)) {
         $authentication[] = 'oauth';
     }
     return array('authentication' => $authentication, 'signatures' => array('consign'), 'input' => array('json', 'urlencoded'), 'output' => array('json', 'human'));
 }
 private function getApplicationRoutes()
 {
     $applications = PhabricatorApplication::getAllInstalledApplications();
     $routes = array();
     foreach ($applications as $application) {
         $routes += $application->getRoutes();
     }
     return $routes;
 }
 public function getRoutingMaps()
 {
     $applications = PhabricatorApplication::getAllInstalledApplications();
     $maps = array();
     foreach ($applications as $application) {
         $maps[] = $this->newRoutingMap()->setApplication($application)->setRoutes($application->getResourceRoutes());
     }
     return $maps;
 }
 public function shouldEnableForObject($object)
 {
     $viewer = $this->getViewer();
     // Workboards are only available if Maniphest is installed.
     $class = 'PhabricatorManiphestApplication';
     if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
         return false;
     }
     return true;
 }
 public function processRequest()
 {
     $viewer = $this->getRequest()->getUser();
     $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withUsernames(array($this->username))->needProfileImage(true)->needAvailability(true)->executeOne();
     if (!$user) {
         return new Aphront404Response();
     }
     require_celerity_resource('phabricator-profile-css');
     $profile = $user->loadUserProfile();
     $username = phutil_escape_uri($user->getUserName());
     $picture = $user->getProfileImageURI();
     $header = id(new PHUIHeaderView())->setHeader($user->getFullName())->setSubheader($profile->getTitle())->setImage($picture);
     $actions = id(new PhabricatorActionListView())->setObject($user)->setObjectURI($this->getRequest()->getRequestURI())->setUser($viewer);
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $user, PhabricatorPolicyCapability::CAN_EDIT);
     $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-pencil')->setName(pht('Edit Profile'))->setHref($this->getApplicationURI('editprofile/' . $user->getID() . '/'))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-picture-o')->setName(pht('Edit Profile Picture'))->setHref($this->getApplicationURI('picture/' . $user->getID() . '/'))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     if ($viewer->getIsAdmin()) {
         $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-wrench')->setName(pht('Edit Settings'))->setDisabled(!$can_edit)->setWorkflow(!$can_edit)->setHref('/settings/' . $user->getID() . '/'));
         if ($user->getIsAdmin()) {
             $empower_icon = 'fa-arrow-circle-o-down';
             $empower_name = pht('Remove Administrator');
         } else {
             $empower_icon = 'fa-arrow-circle-o-up';
             $empower_name = pht('Make Administrator');
         }
         $actions->addAction(id(new PhabricatorActionView())->setIcon($empower_icon)->setName($empower_name)->setDisabled($user->getPHID() == $viewer->getPHID())->setWorkflow(true)->setHref($this->getApplicationURI('empower/' . $user->getID() . '/')));
         $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-tag')->setName(pht('Change Username'))->setWorkflow(true)->setHref($this->getApplicationURI('rename/' . $user->getID() . '/')));
         if ($user->getIsDisabled()) {
             $disable_icon = 'fa-check-circle-o';
             $disable_name = pht('Enable User');
         } else {
             $disable_icon = 'fa-ban';
             $disable_name = pht('Disable User');
         }
         $actions->addAction(id(new PhabricatorActionView())->setIcon($disable_icon)->setName($disable_name)->setDisabled($user->getPHID() == $viewer->getPHID())->setWorkflow(true)->setHref($this->getApplicationURI('disable/' . $user->getID() . '/')));
         $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-times')->setName(pht('Delete User'))->setDisabled($user->getPHID() == $viewer->getPHID())->setWorkflow(true)->setHref($this->getApplicationURI('delete/' . $user->getID() . '/')));
         $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-envelope')->setName(pht('Send Welcome Email'))->setWorkflow(true)->setHref($this->getApplicationURI('welcome/' . $user->getID() . '/')));
     }
     $properties = $this->buildPropertyView($user, $actions);
     $name = $user->getUsername();
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($name);
     $class = 'PhabricatorConpherenceApplication';
     if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
         $href = '/conpherence/new/?participant=' . $user->getPHID();
         $image = id(new PHUIIconView())->setIconFont('fa-comments');
         $button = id(new PHUIButtonView())->setTag('a')->setColor(PHUIButtonView::SIMPLE)->setIcon($image)->setHref($href)->setText(pht('Send Message'))->setWorkflow(true);
         $header->addActionLink($button);
     }
     $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
     $nav = $this->buildIconNavView($user);
     $nav->selectFilter("{$name}/");
     $nav->appendChild($object_box);
     return $this->buildApplicationPage($nav, array('title' => $user->getUsername()));
 }