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


PHP PhabricatorPolicies类代码示例

本文整理汇总了PHP中PhabricatorPolicies的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorPolicies类的具体用法?PHP PhabricatorPolicies怎么用?PHP PhabricatorPolicies使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getPolicy

 public function getPolicy($capability)
 {
     // These objects are low-level and only accessed through the storage
     // engine, so policies are mostly just in place to let us use the common
     // query infrastructure.
     return PhabricatorPolicies::getMostOpenPolicy();
 }
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:PhabricatorFileChunk.php

示例2: getPolicy

 public function getPolicy($capability)
 {
     switch ($capability) {
         case PhabricatorPolicyCapability::CAN_VIEW:
             return PhabricatorPolicies::getMostOpenPolicy();
     }
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:7,代码来源:PhabricatorCalendarExternalInvitee.php

示例3: initializeNewDocument

 public static function initializeNewDocument(PhabricatorUser $actor, $slug)
 {
     $document = new PhrictionDocument();
     $document->setSlug($slug);
     $content = new PhrictionContent();
     $content->setSlug($slug);
     $default_title = PhabricatorSlug::getDefaultTitle($slug);
     $content->setTitle($default_title);
     $document->attachContent($content);
     $parent_doc = null;
     $ancestral_slugs = PhabricatorSlug::getAncestry($slug);
     if ($ancestral_slugs) {
         $parent = end($ancestral_slugs);
         $parent_doc = id(new PhrictionDocumentQuery())->setViewer($actor)->withSlugs(array($parent))->executeOne();
     }
     if ($parent_doc) {
         $document->setViewPolicy($parent_doc->getViewPolicy());
         $document->setEditPolicy($parent_doc->getEditPolicy());
     } else {
         $default_view_policy = PhabricatorPolicies::getMostOpenPolicy();
         $document->setViewPolicy($default_view_policy);
         $document->setEditPolicy(PhabricatorPolicies::POLICY_USER);
     }
     return $document;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:25,代码来源:PhrictionDocument.php

示例4: testFileVisibility

 public function testFileVisibility()
 {
     $engine = new PhabricatorTestStorageEngine();
     $data = Filesystem::readRandomCharacters(64);
     $author = $this->generateNewTestUser();
     $viewer = $this->generateNewTestUser();
     $users = array($author, $viewer);
     $params = array('name' => 'test.dat', 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'authorPHID' => $author->getPHID(), 'storageEngines' => array($engine));
     $file = PhabricatorFile::newFromFileData($data, $params);
     $filter = new PhabricatorPolicyFilter();
     // Test bare file policies.
     $this->assertEqual(array(true, false), $this->canViewFile($users, $file), pht('File Visibility'));
     // Create an object and test object policies.
     $object = ManiphestTask::initializeNewTask($author);
     $object->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy());
     $object->save();
     $this->assertTrue($filter->hasCapability($author, $object, PhabricatorPolicyCapability::CAN_VIEW), pht('Object Visible to Author'));
     $this->assertTrue($filter->hasCapability($viewer, $object, PhabricatorPolicyCapability::CAN_VIEW), pht('Object Visible to Others'));
     // Attach the file to the object and test that the association opens a
     // policy exception for the non-author viewer.
     $file->attachToObject($object->getPHID());
     // Test the attached file's visibility.
     $this->assertEqual(array(true, true), $this->canViewFile($users, $file), pht('Attached File Visibility'));
     // Create a "thumbnail" of the original file.
     $params = array('name' => 'test.thumb.dat', 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'storageEngines' => array($engine));
     $xform = PhabricatorFile::newFromFileData($data, $params);
     id(new PhabricatorTransformedFile())->setOriginalPHID($file->getPHID())->setTransform('test-thumb')->setTransformedPHID($xform->getPHID())->save();
     // Test the thumbnail's visibility.
     $this->assertEqual(array(true, true), $this->canViewFile($users, $xform), pht('Attached Thumbnail Visibility'));
     // Detach the object and make sure it affects the thumbnail.
     $file->detachFromObject($object->getPHID());
     // Test the detached thumbnail's visibility.
     $this->assertEqual(array(true, false), $this->canViewFile($users, $xform), pht('Detached Thumbnail Visibility'));
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:34,代码来源:PhabricatorFileTestCase.php

示例5: getPolicy

 public function getPolicy($capability)
 {
     switch ($capability) {
         case PhabricatorPolicyCapability::CAN_VIEW:
             return PhabricatorPolicies::getMostOpenPolicy();
         case PhabricatorPolicyCapability::CAN_EDIT:
             return $this->getUserPHID();
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:9,代码来源:PhabricatorCalendarEvent.php

示例6: render

 public function render()
 {
     $viewer = $this->getUser();
     if (!$viewer->isLoggedIn()) {
         return null;
     }
     $instructions_id = celerity_generate_unique_node_id();
     require_celerity_resource('global-drag-and-drop-css');
     Javelin::initBehavior('global-drag-and-drop', array('ifSupported' => $this->showIfSupportedID, 'instructions' => $instructions_id, 'uploadURI' => '/file/dropupload/', 'browseURI' => '/file/query/authored/', 'viewPolicy' => PhabricatorPolicies::getMostOpenPolicy()));
     return phutil_tag('div', array('id' => $instructions_id, 'class' => 'phabricator-global-upload-instructions', 'style' => 'display: none;'), pht("⇪ Drop Files to Upload"));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:11,代码来源:PhabricatorGlobalUploadTargetView.php

示例7: getPolicy

 public function getPolicy($capability)
 {
     $policy = PhabricatorPolicies::POLICY_NOONE;
     switch ($capability) {
         case PhabricatorPolicyCapability::CAN_VIEW:
             // Since it's impossible to perform any meaningful computations with
             // time if a user can't view some of it, visibility on tracked time is
             // unrestricted. If we eventually lock it down, it should be per-user.
             // (This doesn't mean that users can see tracked objects.)
             return PhabricatorPolicies::getMostOpenPolicy();
     }
     return $policy;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:13,代码来源:PhrequentUserTime.php

示例8: initializeNewCalendarEvent

 public static function initializeNewCalendarEvent(PhabricatorUser $actor, $mode)
 {
     $app = id(new PhabricatorApplicationQuery())->setViewer($actor)->withClasses(array('PhabricatorCalendarApplication'))->executeOne();
     $view_policy = null;
     $is_recurring = 0;
     if ($mode == 'public') {
         $view_policy = PhabricatorPolicies::getMostOpenPolicy();
     }
     if ($mode == 'recurring') {
         $is_recurring = true;
     }
     return id(new PhabricatorCalendarEvent())->setUserPHID($actor->getPHID())->setIsCancelled(0)->setIsAllDay(0)->setIsRecurring($is_recurring)->setIcon(self::DEFAULT_ICON)->setViewPolicy($view_policy)->setEditPolicy($actor->getPHID())->setSpacePHID($actor->getDefaultSpacePHID())->attachInvitees(array())->applyViewerTimezone($actor);
 }
开发者ID:phpengineer,项目名称:phabricator,代码行数:13,代码来源:PhabricatorCalendarEvent.php

示例9: execute

 protected function execute(ConduitAPIRequest $request)
 {
     $data = $request->getValue('data_base64');
     $name = $request->getValue('name');
     $can_cdn = $request->getValue('canCDN');
     $view_policy = $request->getValue('viewPolicy');
     $user = $request->getUser();
     $data = base64_decode($data, $strict = true);
     if (!$view_policy) {
         $view_policy = PhabricatorPolicies::getMostOpenPolicy();
     }
     $file = PhabricatorFile::newFromFileData($data, array('name' => $name, 'authorPHID' => $user->getPHID(), 'viewPolicy' => $view_policy, 'canCDN' => $can_cdn, 'isExplicitUpload' => true));
     return $file->getPHID();
 }
开发者ID:denghp,项目名称:phabricator,代码行数:14,代码来源:FileUploadConduitAPIMethod.php

示例10: validateOption

 public function validateOption(PhabricatorConfigOption $option, $value)
 {
     if (phid_get_type($value) != PhabricatorFileFilePHIDType::TYPECONST) {
         throw new Exception(pht('%s is not a valid file PHID.', $value));
     }
     $file = id(new PhabricatorFileQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs(array($value))->executeOne();
     if (!$file) {
         throw new Exception(pht('%s is not a valid file PHID.', $value));
     }
     $most_open_policy = PhabricatorPolicies::getMostOpenPolicy();
     if ($file->getViewPolicy() != $most_open_policy) {
         throw new Exception(pht('Specified file %s has policy "%s" but should have policy "%s".', $value, $file->getViewPolicy(), $most_open_policy));
     }
     if (!$file->isViewableImage()) {
         throw new Exception(pht('Specified file %s is not a viewable image.', $value));
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:17,代码来源:PhabricatorCustomHeaderConfigType.php

示例11: execute

 public function execute(HarbormasterBuild $build, HarbormasterBuildTarget $build_target)
 {
     $settings = $this->getSettings();
     $variables = $build_target->getVariables();
     $path = $this->mergeVariables('vsprintf', $settings['path'], $variables);
     $artifact = $build->loadArtifact($settings['artifact']);
     $file = $artifact->loadPhabricatorFile();
     $fragment = id(new PhragmentFragmentQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPaths(array($path))->executeOne();
     if ($fragment === null) {
         PhragmentFragment::createFromFile(PhabricatorUser::getOmnipotentUser(), $file, $path, PhabricatorPolicies::getMostOpenPolicy(), PhabricatorPolicies::POLICY_USER);
     } else {
         if ($file->getMimeType() === 'application/zip') {
             $fragment->updateFromZIP(PhabricatorUser::getOmnipotentUser(), $file);
         } else {
             $fragment->updateFromFile(PhabricatorUser::getOmnipotentUser(), $file);
         }
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:18,代码来源:HarbormasterPublishFragmentBuildStepImplementation.php

示例12: getBook

 protected function getBook()
 {
     if (!$this->book) {
         $book_name = $this->getConfig('name');
         $book = id(new DivinerLiveBook())->loadOneWhere('name = %s', $book_name);
         if (!$book) {
             $book = id(new DivinerLiveBook())->setName($book_name)->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy())->setEditPolicy(PhabricatorPolicies::POLICY_ADMIN)->save();
         }
         $conn_w = $book->establishConnection('w');
         $conn_w->openTransaction();
         $book->setRepositoryPHID($this->getRepositoryPHID())->setConfigurationData($this->getConfigurationData())->save();
         // TODO: This is gross. Without this, the repository won't be updated for
         // atoms which have already been published.
         queryfx($conn_w, 'UPDATE %T SET repositoryPHID = %s WHERE bookPHID = %s', id(new DivinerLiveSymbol())->getTableName(), $this->getRepositoryPHID(), $book->getPHID());
         $conn_w->saveTransaction();
         $this->book = $book;
         id(new PhabricatorSearchIndexer())->queueDocumentForIndexing($book->getPHID());
     }
     return $this->book;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:20,代码来源:DivinerLivePublisher.php

示例13: getPolicy

 public function getPolicy($capability)
 {
     switch ($capability) {
         case PhabricatorPolicyCapability::CAN_VIEW:
             return PhabricatorPolicies::getMostOpenPolicy();
         case PhabricatorPolicyCapability::CAN_EDIT:
             // NOTE: In practice, this policy is always limited by the "Mangage
             // Build Plans" policy.
             if ($this->isAutoplan()) {
                 return PhabricatorPolicies::POLICY_NOONE;
             }
             return PhabricatorPolicies::getMostOpenPolicy();
     }
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:14,代码来源:HarbormasterBuildPlan.php

示例14: initializeNewPhurlURL

 public static function initializeNewPhurlURL(PhabricatorUser $actor)
 {
     $app = id(new PhabricatorApplicationQuery())->setViewer($actor)->withClasses(array('PhabricatorPhurlApplication'))->executeOne();
     return id(new PhabricatorPhurlURL())->setAuthorPHID($actor->getPHID())->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy())->setEditPolicy($actor->getPHID())->setSpacePHID($actor->getDefaultSpacePHID());
 }
开发者ID:hamilyjing,项目名称:phabricator,代码行数:5,代码来源:PhabricatorPhurlURL.php

示例15: initializeNewBlog

 public static function initializeNewBlog(PhabricatorUser $actor)
 {
     $blog = id(new PhameBlog())->setCreatorPHID($actor->getPHID())->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy())->setEditPolicy(PhabricatorPolicies::POLICY_USER)->setJoinPolicy(PhabricatorPolicies::POLICY_USER);
     return $blog;
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:5,代码来源:PhameBlog.php


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