コード例 #1
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $configs = id(new PhabricatorAuthProviderConfigQuery())->setViewer($viewer)->execute();
     $list = new PHUIObjectItemListView();
     $can_manage = $this->hasApplicationCapability(AuthManageProvidersCapability::CAPABILITY);
     foreach ($configs as $config) {
         $item = new PHUIObjectItemView();
         $id = $config->getID();
         $edit_uri = $this->getApplicationURI('config/edit/' . $id . '/');
         $enable_uri = $this->getApplicationURI('config/enable/' . $id . '/');
         $disable_uri = $this->getApplicationURI('config/disable/' . $id . '/');
         $provider = $config->getProvider();
         if ($provider) {
             $name = $provider->getProviderName();
         } else {
             $name = $config->getProviderType() . ' (' . $config->getProviderClass() . ')';
         }
         $item->setHeader($name);
         if ($provider) {
             $item->setHref($edit_uri);
         } else {
             $item->addAttribute(pht('Provider Implementation Missing!'));
         }
         $domain = null;
         if ($provider) {
             $domain = $provider->getProviderDomain();
             if ($domain !== 'self') {
                 $item->addAttribute($domain);
             }
         }
         if ($config->getShouldAllowRegistration()) {
             $item->addAttribute(pht('Allows Registration'));
         } else {
             $item->addAttribute(pht('Does Not Allow Registration'));
         }
         if ($config->getIsEnabled()) {
             $item->setStatusIcon('fa-check-circle green');
             $item->addAction(id(new PHUIListItemView())->setIcon('fa-times')->setHref($disable_uri)->setDisabled(!$can_manage)->addSigil('workflow'));
         } else {
             $item->setStatusIcon('fa-ban red');
             $item->addIcon('fa-ban grey', pht('Disabled'));
             $item->addAction(id(new PHUIListItemView())->setIcon('fa-plus')->setHref($enable_uri)->setDisabled(!$can_manage)->addSigil('workflow'));
         }
         $list->addItem($item);
     }
     $list->setNoDataString(pht('%s You have not added authentication providers yet. Use "%s" to add ' . 'a provider, which will let users register new Phabricator accounts ' . 'and log in.', phutil_tag('strong', array(), pht('No Providers Configured:')), phutil_tag('a', array('href' => $this->getApplicationURI('config/new/')), pht('Add Authentication Provider'))));
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Auth Providers'));
     $crumbs->setBorder(true);
     $guidance_context = new PhabricatorAuthProvidersGuidanceContext();
     $guidance = id(new PhabricatorGuidanceEngine())->setViewer($viewer)->setGuidanceContext($guidance_context)->newInfoView();
     $button = id(new PHUIButtonView())->setTag('a')->setColor(PHUIButtonView::SIMPLE)->setHref($this->getApplicationURI('config/new/'))->setIcon('fa-plus')->setDisabled(!$can_manage)->setText(pht('Add Provider'));
     $list->setFlush(true);
     $list = id(new PHUIObjectBoxView())->setHeaderText(pht('Providers'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->appendChild($list);
     $title = pht('Auth Providers');
     $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-key')->addActionLink($button);
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($guidance, $list));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
コード例 #2
0
 private function buildPaymentMethodsSection(PhortuneAccount $account)
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $account, PhabricatorPolicyCapability::CAN_EDIT);
     $id = $account->getID();
     $header = id(new PHUIHeaderView())->setHeader(pht('Payment Methods'))->addActionLink(id(new PHUIButtonView())->setTag('a')->setHref($this->getApplicationURI($id . '/card/new/'))->setText(pht('Add Payment Method'))->setIcon(id(new PHUIIconView())->setIconFont('fa-plus')));
     $list = id(new PHUIObjectItemListView())->setUser($viewer)->setNoDataString(pht('No payment methods associated with this account.'));
     $methods = id(new PhortunePaymentMethodQuery())->setViewer($viewer)->withAccountPHIDs(array($account->getPHID()))->execute();
     if ($methods) {
         $this->loadHandles(mpull($methods, 'getAuthorPHID'));
     }
     foreach ($methods as $method) {
         $id = $method->getID();
         $item = new PHUIObjectItemView();
         $item->setHeader($method->getFullDisplayName());
         switch ($method->getStatus()) {
             case PhortunePaymentMethod::STATUS_ACTIVE:
                 $item->setBarColor('green');
                 $disable_uri = $this->getApplicationURI('card/' . $id . '/disable/');
                 $item->addAction(id(new PHUIListItemView())->setIcon('fa-times')->setHref($disable_uri)->setDisabled(!$can_edit)->setWorkflow(true));
                 break;
             case PhortunePaymentMethod::STATUS_DISABLED:
                 $item->setDisabled(true);
                 break;
         }
         $provider = $method->buildPaymentProvider();
         $item->addAttribute($provider->getPaymentMethodProviderDescription());
         $item->setImageURI($provider->getPaymentMethodIcon());
         $edit_uri = $this->getApplicationURI('card/' . $id . '/edit/');
         $item->addAction(id(new PHUIListItemView())->setIcon('fa-pencil')->setHref($edit_uri)->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
         $list->addItem($item);
     }
     return id(new PHUIObjectBoxView())->setHeader($header)->appendChild($list);
 }
コード例 #3
0
 private function buildPaymentMethodsSection(PhortuneAccount $account)
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $account, PhabricatorPolicyCapability::CAN_EDIT);
     $id = $account->getID();
     $header = id(new PHUIHeaderView())->setHeader(pht('Payment Methods'));
     $list = id(new PHUIObjectItemListView())->setUser($viewer)->setFlush(true)->setNoDataString(pht('No payment methods associated with this account.'));
     $methods = id(new PhortunePaymentMethodQuery())->setViewer($viewer)->withAccountPHIDs(array($account->getPHID()))->execute();
     foreach ($methods as $method) {
         $id = $method->getID();
         $item = new PHUIObjectItemView();
         $item->setHeader($method->getFullDisplayName());
         switch ($method->getStatus()) {
             case PhortunePaymentMethod::STATUS_ACTIVE:
                 $item->setStatusIcon('fa-check green');
                 $disable_uri = $this->getApplicationURI('card/' . $id . '/disable/');
                 $item->addAction(id(new PHUIListItemView())->setIcon('fa-times')->setHref($disable_uri)->setDisabled(!$can_edit)->setWorkflow(true));
                 break;
             case PhortunePaymentMethod::STATUS_DISABLED:
                 $item->setStatusIcon('fa-ban lightbluetext');
                 $item->setDisabled(true);
                 break;
         }
         $provider = $method->buildPaymentProvider();
         $item->addAttribute($provider->getPaymentMethodProviderDescription());
         $edit_uri = $this->getApplicationURI('card/' . $id . '/edit/');
         $item->addAction(id(new PHUIListItemView())->setIcon('fa-pencil')->setHref($edit_uri)->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
         $list->addItem($item);
     }
     return id(new PHUIObjectBoxView())->setHeader($header)->setObjectList($list);
 }
コード例 #4
0
 protected function renderResultList(array $lists, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($lists, 'PhabricatorMetaMTAMailingList');
     $view = id(new PHUIObjectItemListView());
     foreach ($lists as $list) {
         $item = new PHUIObjectItemView();
         $item->setHeader($list->getName());
         $item->setHref($list->getURI());
         $item->addAttribute($list->getEmail());
         $item->addAction(id(new PHUIListItemView())->setIcon('fa-pencil')->setHref($this->getApplicationURI('/edit/' . $list->getID() . '/')));
         $view->addItem($item);
     }
     return $view;
 }
コード例 #5
0
 public function render()
 {
     $handles = $this->handles;
     require_celerity_resource('maniphest-task-summary-css');
     $list = new PHUIObjectItemListView();
     $list->setFlush(true);
     $status_map = ManiphestTaskStatus::getTaskStatusMap();
     $color_map = ManiphestTaskPriority::getColorMap();
     if ($this->showBatchControls) {
         Javelin::initBehavior('maniphest-list-editor');
     }
     foreach ($this->tasks as $task) {
         $item = new PHUIObjectItemView();
         $item->setObjectName('T' . $task->getID());
         $item->setHeader($task->getTitle());
         $item->setHref('/T' . $task->getID());
         if ($task->getOwnerPHID()) {
             $owner = $handles[$task->getOwnerPHID()];
             $item->addByline(pht('Assigned: %s', $owner->renderLink()));
         }
         $status = $task->getStatus();
         if ($task->isClosed()) {
             $item->setDisabled(true);
         }
         $item->setBarColor(idx($color_map, $task->getPriority(), 'grey'));
         $item->addIcon('none', phabricator_datetime($task->getDateModified(), $this->getUser()));
         if ($this->showSubpriorityControls) {
             $item->setGrippable(true);
         }
         if ($this->showSubpriorityControls || $this->showBatchControls) {
             $item->addSigil('maniphest-task');
         }
         $project_handles = array_select_keys($handles, $task->getProjectPHIDs());
         $item->addAttribute(id(new PHUIHandleTagListView())->setLimit(4)->setNoDataString(pht('No Projects'))->setSlim(true)->setHandles($project_handles));
         $item->setMetadata(array('taskID' => $task->getID()));
         if ($this->showBatchControls) {
             $href = new PhutilURI('/maniphest/task/edit/' . $task->getID() . '/');
             if (!$this->showSubpriorityControls) {
                 $href->setQueryParam('ungrippable', 'true');
             }
             $item->addAction(id(new PHUIListItemView())->setIcon('fa-pencil')->addSigil('maniphest-edit-task')->setHref($href));
         }
         $list->addItem($item);
     }
     return $list;
 }
コード例 #6
0
 protected function renderResultList(array $users, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($users, 'PhabricatorUser');
     $request = $this->getRequest();
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $is_approval = $query->getQueryKey() == 'approval';
     foreach ($users as $user) {
         $primary_email = $user->loadPrimaryEmail();
         if ($primary_email && $primary_email->getIsVerified()) {
             $email = pht('Verified');
         } else {
             $email = pht('Unverified');
         }
         $item = new PHUIObjectItemView();
         $item->setHeader($user->getFullName())->setHref('/p/' . $user->getUsername() . '/')->addAttribute(phabricator_datetime($user->getDateCreated(), $viewer))->addAttribute($email)->setImageURI($user->getProfileImageURI());
         if ($is_approval && $primary_email) {
             $item->addAttribute($primary_email->getAddress());
         }
         if ($user->getIsDisabled()) {
             $item->addIcon('fa-ban', pht('Disabled'));
         }
         if (!$is_approval) {
             if (!$user->getIsApproved()) {
                 $item->addIcon('fa-clock-o', pht('Needs Approval'));
             }
         }
         if ($user->getIsAdmin()) {
             $item->addIcon('fa-star', pht('Admin'));
         }
         if ($user->getIsSystemAgent()) {
             $item->addIcon('fa-desktop', pht('Bot/Script'));
         }
         if ($viewer->getIsAdmin()) {
             $user_id = $user->getID();
             if ($is_approval) {
                 $item->addAction(id(new PHUIListItemView())->setIcon('fa-ban')->setName(pht('Disable'))->setWorkflow(true)->setHref($this->getApplicationURI('disapprove/' . $user_id . '/')));
                 $item->addAction(id(new PHUIListItemView())->setIcon('fa-thumbs-o-up')->setName(pht('Approve'))->setWorkflow(true)->setHref($this->getApplicationURI('approve/' . $user_id . '/')));
             }
         }
         $list->addItem($item);
     }
     return $list;
 }
コード例 #7
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $configs = id(new PhabricatorAuthProviderConfigQuery())->setViewer($viewer)->execute();
     $list = new PHUIObjectItemListView();
     $can_manage = $this->hasApplicationCapability(AuthManageProvidersCapability::CAPABILITY);
     foreach ($configs as $config) {
         $item = new PHUIObjectItemView();
         $id = $config->getID();
         $edit_uri = $this->getApplicationURI('config/edit/' . $id . '/');
         $enable_uri = $this->getApplicationURI('config/enable/' . $id . '/');
         $disable_uri = $this->getApplicationURI('config/disable/' . $id . '/');
         $provider = $config->getProvider();
         if ($provider) {
             $name = $provider->getProviderName();
         } else {
             $name = $config->getProviderType() . ' (' . $config->getProviderClass() . ')';
         }
         $item->setHeader($name);
         if ($provider) {
             $item->setHref($edit_uri);
         } else {
             $item->addAttribute(pht('Provider Implementation Missing!'));
         }
         $domain = null;
         if ($provider) {
             $domain = $provider->getProviderDomain();
             if ($domain !== 'self') {
                 $item->addAttribute($domain);
             }
         }
         if ($config->getShouldAllowRegistration()) {
             $item->addAttribute(pht('Allows Registration'));
         } else {
             $item->addAttribute(pht('Does Not Allow Registration'));
         }
         if ($config->getIsEnabled()) {
             $item->setState(PHUIObjectItemView::STATE_SUCCESS);
             $item->addAction(id(new PHUIListItemView())->setIcon('fa-times')->setHref($disable_uri)->setDisabled(!$can_manage)->addSigil('workflow'));
         } else {
             $item->setState(PHUIObjectItemView::STATE_FAIL);
             $item->addIcon('fa-times grey', pht('Disabled'));
             $item->addAction(id(new PHUIListItemView())->setIcon('fa-plus')->setHref($enable_uri)->setDisabled(!$can_manage)->addSigil('workflow'));
         }
         $list->addItem($item);
     }
     $list->setNoDataString(pht('%s You have not added authentication providers yet. Use "%s" to add ' . 'a provider, which will let users register new Phabricator accounts ' . 'and log in.', phutil_tag('strong', array(), pht('No Providers Configured:')), phutil_tag('a', array('href' => $this->getApplicationURI('config/new/')), pht('Add Authentication Provider'))));
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Auth Providers'));
     $domains_key = 'auth.email-domains';
     $domains_link = $this->renderConfigLink($domains_key);
     $domains_value = PhabricatorEnv::getEnvConfig($domains_key);
     $approval_key = 'auth.require-approval';
     $approval_link = $this->renderConfigLink($approval_key);
     $approval_value = PhabricatorEnv::getEnvConfig($approval_key);
     $issues = array();
     if ($domains_value) {
         $issues[] = pht('Phabricator is configured with an email domain whitelist (in %s), so ' . 'only users with a verified email address at one of these %s ' . 'allowed domain(s) will be able to register an account: %s', $domains_link, phutil_count($domains_value), phutil_tag('strong', array(), implode(', ', $domains_value)));
     } else {
         $issues[] = pht('Anyone who can browse to this Phabricator install will be able to ' . 'register an account. To add email domain restrictions, configure ' . '%s.', $domains_link);
     }
     if ($approval_value) {
         $issues[] = pht('Administrative approvals are enabled (in %s), so all new users must ' . 'have their accounts approved by an administrator.', $approval_link);
     } else {
         $issues[] = pht('Administrative approvals are disabled, so users who register will ' . 'be able to use their accounts immediately. To enable approvals, ' . 'configure %s.', $approval_link);
     }
     if (!$domains_value && !$approval_value) {
         $severity = PHUIInfoView::SEVERITY_WARNING;
         $issues[] = pht('You can safely ignore this warning if the install itself has ' . 'access controls (for example, it is deployed on a VPN) or if all of ' . 'the configured providers have access controls (for example, they are ' . 'all private LDAP or OAuth servers).');
     } else {
         $severity = PHUIInfoView::SEVERITY_NOTICE;
     }
     $warning = id(new PHUIInfoView())->setSeverity($severity)->setErrors($issues);
     $image = id(new PHUIIconView())->setIconFont('fa-plus');
     $button = id(new PHUIButtonView())->setTag('a')->setColor(PHUIButtonView::SIMPLE)->setHref($this->getApplicationURI('config/new/'))->setIcon($image)->setDisabled(!$can_manage)->setText(pht('Add Provider'));
     $header = id(new PHUIHeaderView())->setHeader(pht('Authentication Providers'))->addActionLink($button);
     $list->setFlush(true);
     $list = id(new PHUIObjectBoxView())->setHeader($header)->setInfoView($warning)->appendChild($list);
     return $this->buildApplicationPage(array($crumbs, $list), array('title' => pht('Authentication Providers')));
 }
コード例 #8
0
 protected function renderResultList(array $usertimes, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($usertimes, 'PhrequentUserTime');
     $viewer = $this->requireViewer();
     $view = id(new PHUIObjectItemListView())->setUser($viewer);
     foreach ($usertimes as $usertime) {
         $item = new PHUIObjectItemView();
         if ($usertime->getObjectPHID() === null) {
             $item->setHeader($usertime->getNote());
         } else {
             $obj = $handles[$usertime->getObjectPHID()];
             $item->setHeader($obj->getLinkName());
             $item->setHref($obj->getURI());
         }
         $item->setObject($usertime);
         $item->addByline(pht('Tracked: %s', $handles[$usertime->getUserPHID()]->renderLink()));
         $started_date = phabricator_date($usertime->getDateStarted(), $viewer);
         $item->addIcon('none', $started_date);
         $block = new PhrequentTimeBlock(array($usertime));
         $time_spent = $block->getTimeSpentOnObject($usertime->getObjectPHID(), PhabricatorTime::getNow());
         $time_spent = $time_spent == 0 ? 'none' : phutil_format_relative_time_detailed($time_spent);
         if ($usertime->getDateEnded() !== null) {
             $item->addAttribute(pht('Tracked %s', $time_spent));
             $item->addAttribute(pht('Ended on %s', phabricator_datetime($usertime->getDateEnded(), $viewer)));
         } else {
             $item->addAttribute(pht('Tracked %s so far', $time_spent));
             if ($usertime->getObjectPHID() !== null && $usertime->getUserPHID() === $viewer->getPHID()) {
                 $item->addAction(id(new PHUIListItemView())->setIcon('fa-stop')->addSigil('phrequent-stop-tracking')->setWorkflow(true)->setRenderNameAsTooltip(true)->setName(pht('Stop'))->setHref('/phrequent/track/stop/' . $usertime->getObjectPHID() . '/'));
             }
             $item->setBarColor('green');
         }
         $view->addItem($item);
     }
     return $view;
 }