当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorSpacesNamespaceQuery::getViewerSpacesExist方法代码示例

本文整理汇总了PHP中PhabricatorSpacesNamespaceQuery::getViewerSpacesExist方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorSpacesNamespaceQuery::getViewerSpacesExist方法的具体用法?PHP PhabricatorSpacesNamespaceQuery::getViewerSpacesExist怎么用?PHP PhabricatorSpacesNamespaceQuery::getViewerSpacesExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhabricatorSpacesNamespaceQuery的用法示例。


在下文中一共展示了PhabricatorSpacesNamespaceQuery::getViewerSpacesExist方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildManagementPanelContent

 public function buildManagementPanelContent()
 {
     $repository = $this->getRepository();
     $viewer = $this->getViewer();
     $view = id(new PHUIPropertyListView())->setViewer($viewer)->setActionList($this->newActions());
     $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $repository);
     $view_parts = array();
     if (PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) {
         $space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($repository);
         $view_parts[] = $viewer->renderHandle($space_phid);
     }
     $view_parts[] = $descriptions[PhabricatorPolicyCapability::CAN_VIEW];
     $view->addProperty(pht('Visible To'), phutil_implode_html(" · ", $view_parts));
     $view->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
     $pushable = $repository->isHosted() ? $descriptions[DiffusionPushCapability::CAPABILITY] : phutil_tag('em', array(), pht('Not a Hosted Repository'));
     $view->addProperty(pht('Pushable By'), $pushable);
     return $this->newBox(pht('Policies'), $view);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:18,代码来源:DiffusionRepositoryPoliciesManagementPanel.php

示例2: render

 public function render()
 {
     $object = $this->getObject();
     $space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($object);
     if (!$space_phid) {
         return null;
     }
     // If the viewer can't see spaces, pretend they don't exist.
     $viewer = $this->getUser();
     if (!PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) {
         return null;
     }
     // If this is the default space, don't show a space label.
     $default = PhabricatorSpacesNamespaceQuery::getDefaultSpace();
     if ($default) {
         if ($default->getPHID() == $space_phid) {
             return null;
         }
     }
     return phutil_tag('span', array('class' => 'spaces-name'), array($viewer->renderHandle($space_phid)->setUseShortName(true), ' | '));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:21,代码来源:PHUISpacesNamespaceContextView.php

示例3: buildEmailTable

 private function buildEmailTable($is_edit, $highlight)
 {
     $viewer = $this->getViewer();
     $application = $this->getApplication();
     $uri = new PhutilURI($this->getPanelURI());
     $emails = id(new PhabricatorMetaMTAApplicationEmailQuery())->setViewer($viewer)->withApplicationPHIDs(array($application->getPHID()))->execute();
     $rowc = array();
     $rows = array();
     foreach ($emails as $email) {
         $button_edit = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('edit', $email->getID()), 'sigil' => 'workflow'), pht('Edit'));
         $button_remove = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('delete', $email->getID()), 'sigil' => 'workflow'), pht('Delete'));
         if ($highlight == $email->getID()) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = null;
         }
         $space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($email);
         if ($space_phid) {
             $email_space = $viewer->renderHandle($space_phid);
         } else {
             $email_space = null;
         }
         $rows[] = array($email_space, $email->getAddress(), $button_edit, $button_remove);
     }
     $table = id(new AphrontTableView($rows))->setNoDataString(pht('No application emails created yet.'));
     $table->setHeaders(array(pht('Space'), pht('Email'), pht('Edit'), pht('Delete')));
     $table->setColumnClasses(array('', 'wide', 'action', 'action'));
     $table->setRowClasses($rowc);
     $table->setColumnVisibility(array(PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer), true, $is_edit, $is_edit));
     return $table;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:31,代码来源:PhabricatorMetaMTAApplicationEmailPanel.php

示例4: validateSpaceTransactions

 private function validateSpaceTransactions(PhabricatorLiskDAO $object, array $xactions, $transaction_type)
 {
     $errors = array();
     $actor = $this->getActor();
     $has_spaces = PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($actor);
     $actor_spaces = PhabricatorSpacesNamespaceQuery::getViewerSpaces($actor);
     $active_spaces = PhabricatorSpacesNamespaceQuery::getViewerActiveSpaces($actor);
     foreach ($xactions as $xaction) {
         $space_phid = $xaction->getNewValue();
         if ($space_phid === null) {
             if (!$has_spaces) {
                 // The install doesn't have any spaces, so this is fine.
                 continue;
             }
             // The install has some spaces, so every object needs to be put
             // in a valid space.
             $errors[] = new PhabricatorApplicationTransactionValidationError($transaction_type, pht('Invalid'), pht('You must choose a space for this object.'), $xaction);
             continue;
         }
         // If the PHID isn't `null`, it needs to be a valid space that the
         // viewer can see.
         if (empty($actor_spaces[$space_phid])) {
             $errors[] = new PhabricatorApplicationTransactionValidationError($transaction_type, pht('Invalid'), pht('You can not shift this object in the selected space, because ' . 'the space does not exist or you do not have access to it.'), $xaction);
         } else {
             if (empty($active_spaces[$space_phid])) {
                 // It's OK to edit objects in an archived space, so just move on if
                 // we aren't adjusting the value.
                 $old_space_phid = $this->getTransactionOldValue($object, $xaction);
                 if ($space_phid == $old_space_phid) {
                     continue;
                 }
                 $errors[] = new PhabricatorApplicationTransactionValidationError($transaction_type, pht('Archived'), pht('You can not shift this object into the selected space, because ' . 'the space is archived. Objects can not be created inside (or ' . 'moved into) archived spaces.'), $xaction);
             }
         }
     }
     return $errors;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:37,代码来源:PhabricatorApplicationTransactionEditor.php

示例5: buildSpacesControl

 private function buildSpacesControl()
 {
     if ($this->capability != PhabricatorPolicyCapability::CAN_VIEW) {
         return null;
     }
     if (!$this->object instanceof PhabricatorSpacesInterface) {
         return null;
     }
     $viewer = $this->getUser();
     if (!PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) {
         return null;
     }
     $space_phid = $this->getSpacePHID();
     if ($space_phid === null) {
         $space_phid = $viewer->getDefaultSpacePHID();
     }
     $select = AphrontFormSelectControl::renderSelectTag($space_phid, PhabricatorSpacesNamespaceQuery::getSpaceOptionsForViewer($viewer, $space_phid), array('disabled' => $this->getDisabled(), 'name' => 'spacePHID', 'class' => 'aphront-space-select-control-knob'));
     return $select;
 }
开发者ID:mduan,项目名称:phabricator,代码行数:19,代码来源:AphrontFormPolicyControl.php

示例6: willBeginExecution


//.........这里部分代码省略.........
             return $this->delegateToController($controller);
         }
         if ($user->getIsDisabled()) {
             $controller = new PhabricatorDisabledUserController();
             return $this->delegateToController($controller);
         }
     }
     $auth_class = 'PhabricatorAuthApplication';
     $auth_application = PhabricatorApplication::getByClass($auth_class);
     // Require partial sessions to finish login before doing anything.
     if (!$this->shouldAllowPartialSessions()) {
         if ($user->hasSession() && $user->getSession()->getIsPartial()) {
             $login_controller = new PhabricatorAuthFinishController();
             $this->setCurrentApplication($auth_application);
             return $this->delegateToController($login_controller);
         }
     }
     // Check if the user needs to configure MFA.
     $need_mfa = $this->shouldRequireMultiFactorEnrollment();
     $have_mfa = $user->getIsEnrolledInMultiFactor();
     if ($need_mfa && !$have_mfa) {
         // Check if the cache is just out of date. Otherwise, roadblock the user
         // and require MFA enrollment.
         $user->updateMultiFactorEnrollment();
         if (!$user->getIsEnrolledInMultiFactor()) {
             $mfa_controller = new PhabricatorAuthNeedsMultiFactorController();
             $this->setCurrentApplication($auth_application);
             return $this->delegateToController($mfa_controller);
         }
     }
     if ($this->shouldRequireLogin()) {
         // This actually means we need either:
         //   - a valid user, or a public controller; and
         //   - permission to see the application; and
         //   - permission to see at least one Space if spaces are configured.
         $allow_public = $this->shouldAllowPublic() && PhabricatorEnv::getEnvConfig('policy.allow-public');
         // If this controller isn't public, and the user isn't logged in, require
         // login.
         if (!$allow_public && !$user->isLoggedIn()) {
             $login_controller = new PhabricatorAuthStartController();
             $this->setCurrentApplication($auth_application);
             return $this->delegateToController($login_controller);
         }
         if ($user->isLoggedIn()) {
             if ($this->shouldRequireEmailVerification()) {
                 if (!$user->getIsEmailVerified()) {
                     $controller = new PhabricatorMustVerifyEmailController();
                     $this->setCurrentApplication($auth_application);
                     return $this->delegateToController($controller);
                 }
             }
         }
         // If Spaces are configured, require that the user have access to at
         // least one. If we don't do this, they'll get confusing error messages
         // later on.
         $spaces = PhabricatorSpacesNamespaceQuery::getSpacesExist();
         if ($spaces) {
             $viewer_spaces = PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($user);
             if (!$viewer_spaces) {
                 $controller = new PhabricatorSpacesNoAccessController();
                 return $this->delegateToController($controller);
             }
         }
         // If the user doesn't have access to the application, don't let them use
         // any of its controllers. We query the application in order to generate
         // a policy exception if the viewer doesn't have permission.
         $application = $this->getCurrentApplication();
         if ($application) {
             id(new PhabricatorApplicationQuery())->setViewer($user)->withPHIDs(array($application->getPHID()))->executeOne();
         }
     }
     if (!$this->shouldAllowLegallyNonCompliantUsers()) {
         $legalpad_class = 'PhabricatorLegalpadApplication';
         $legalpad = id(new PhabricatorApplicationQuery())->setViewer($user)->withClasses(array($legalpad_class))->withInstalled(true)->execute();
         $legalpad = head($legalpad);
         $doc_query = id(new LegalpadDocumentQuery())->setViewer($user)->withSignatureRequired(1)->needViewerSignatures(true);
         if ($user->hasSession() && !$user->getSession()->getIsPartial() && !$user->getSession()->getSignedLegalpadDocuments() && $user->isLoggedIn() && $legalpad) {
             $sign_docs = $doc_query->execute();
             $must_sign_docs = array();
             foreach ($sign_docs as $sign_doc) {
                 if (!$sign_doc->getUserSignature($user->getPHID())) {
                     $must_sign_docs[] = $sign_doc;
                 }
             }
             if ($must_sign_docs) {
                 $controller = new LegalpadDocumentSignController();
                 $this->getRequest()->setURIMap(array('id' => head($must_sign_docs)->getID()));
                 $this->setCurrentApplication($legalpad);
                 return $this->delegateToController($controller);
             } else {
                 $engine = id(new PhabricatorAuthSessionEngine())->signLegalpadDocuments($user, $sign_docs);
             }
         }
     }
     // NOTE: We do this last so that users get a login page instead of a 403
     // if they need to login.
     if ($this->shouldRequireAdmin() && !$user->getIsAdmin()) {
         return new Aphront403Response();
     }
 }
开发者ID:propn,项目名称:phabricator,代码行数:101,代码来源:PhabricatorController.php


注:本文中的PhabricatorSpacesNamespaceQuery::getViewerSpacesExist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。