コード例 #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'));
     $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);
 }
コード例 #3
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);
     $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);
     $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($warning, $list));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
コード例 #4
0
 protected function renderResultList(array $questions, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($questions, 'PonderQuestion');
     $viewer = $this->requireViewer();
     $proj_phids = array();
     foreach ($questions as $question) {
         foreach ($question->getProjectPHIDs() as $project_phid) {
             $proj_phids[] = $project_phid;
         }
     }
     $proj_handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($proj_phids)->execute();
     $view = id(new PHUIObjectItemListView())->setUser($viewer);
     foreach ($questions as $question) {
         $color = PonderQuestionStatus::getQuestionStatusTagColor($question->getStatus());
         $icon = PonderQuestionStatus::getQuestionStatusIcon($question->getStatus());
         $full_status = PonderQuestionStatus::getQuestionStatusFullName($question->getStatus());
         $item = new PHUIObjectItemView();
         $item->setObjectName('Q' . $question->getID());
         $item->setHeader($question->getTitle());
         $item->setHref('/Q' . $question->getID());
         $item->setObject($question);
         $item->setStatusIcon($icon . ' ' . $color, $full_status);
         $project_handles = array_select_keys($proj_handles, $question->getProjectPHIDs());
         $created_date = phabricator_date($question->getDateCreated(), $viewer);
         $item->addIcon('none', $created_date);
         $item->addByline(pht('Asked by %s', $handles[$question->getAuthorPHID()]->renderLink()));
         $item->addAttribute(pht('%d Answer(s)', $question->getAnswerCount()));
         if ($project_handles) {
             $item->addAttribute(id(new PHUIHandleTagListView())->setLimit(4)->setSlim(true)->setHandles($project_handles));
         }
         $view->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($view);
     $result->setNoDataString(pht('No questions found.'));
     return $result;
 }
コード例 #5
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->setStatusIcon('fa-clock-o green');
         }
         $view->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($view);
     return $result;
 }