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


PHP Permission::check方法代码示例

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


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

示例1: init

 public function init()
 {
     parent::init();
     if (!Director::is_cli() && !Permission::check("ADMIN") && $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
         return Security::permissionFailure();
     }
 }
开发者ID:azt3k,项目名称:abc-silverstripe-social,代码行数:7,代码来源:PurgeTwitter.php

示例2: init

 public function init()
 {
     parent::init();
     if (!Director::is_cli() && !Permission::check('ADMIN')) {
         return Security::permissionFailure();
     }
 }
开发者ID:normann,项目名称:sapphire,代码行数:7,代码来源:SapphireInfo.php

示例3: testModelAdminOpens

 function testModelAdminOpens()
 {
     $this->autoFollowRedirection = false;
     $this->logInAs('admin');
     $this->assertTrue((bool) Permission::check("ADMIN"));
     $this->assertEquals(200, $this->get('ModelAdminTest_Admin')->getStatusCode());
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:7,代码来源:ModelAdminTest.php

示例4: updateCMSFields

 public function updateCMSFields(FieldSet $fields)
 {
     $service = singleton('WorkflowService');
     if ($effective = $service->getDefinitionFor($this->owner)) {
         $effectiveTitle = $effective->Title;
     } else {
         $effectiveTitle = _t('WorkflowApplicable.NONE', '(none)');
     }
     $allDefinitions = array(_t('WorkflowApplicable.INHERIT', 'Inherit from parent'));
     if ($definitions = $service->getDefinitions()) {
         $allDefinitions += $definitions->map();
     }
     $tab = $fields->fieldByName('Root') ? 'Root.Workflow' : 'BottomRoot.Workflow';
     $applyWorkflowField = null;
     $fields->addFieldToTab($tab, new HeaderField('AppliedWorkflowHeader', _t('WorkflowApplicable.APPLIEDWORKFLOW', 'Applied Workflow')));
     if (Permission::check('APPLY_WORKFLOW')) {
         $fields->addFieldToTab($tab, new DropdownField('WorkflowDefinitionID', _t('WorkflowApplicable.DEFINITION', 'Applied Workflow'), $allDefinitions));
     }
     $fields->addFieldToTab($tab, new ReadonlyField('EffectiveWorkflow', _t('WorkflowApplicable.EFFECTIVE_WORKFLOW', 'Effective Workflow'), $effectiveTitle));
     $fields->addFieldToTab($tab, new HeaderField('WorkflowLogHeader', _t('WorkflowApplicable.WORKFLOWLOG', 'Workflow Log')));
     $fields->addFieldToTab($tab, $logTable = new ComplexTableField($this->owner, 'WorkflowLog', 'WorkflowInstance', null, 'getActionsSummaryFields', sprintf('"TargetClass" = \'%s\' AND "TargetID" = %d', $this->owner->class, $this->owner->ID)));
     $logTable->setRelationAutoSetting(false);
     $logTable->setPermissions(array('show'));
     $logTable->setPopupSize(760, 420);
 }
开发者ID:rodneyway,项目名称:advancedworkflow,代码行数:25,代码来源:WorkflowApplicable.php

示例5: canView

 /**
  * Checks to see if the member can view or not
  * @param {int|Member} $member Member ID or instance to check
  * @return {bool} Returns boolean true if the member can view false otherwise
  */
 public function canView($member = null)
 {
     if (Permission::check('CODE_BANK_ACCESS', 'any', $member)) {
         return true;
     }
     return false;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:12,代码来源:SnippetVersion.php

示例6: onBeforeInit

 public function onBeforeInit()
 {
     $host = GlobalNavSiteTreeExtension::get_toolbar_hostname();
     if ((isset($_REQUEST['regenerate_nav']) || isset($_REQUEST['flush'])) && $host == Director::protocolAndHost() && (Permission::check('ADMIN') || Director::isDev())) {
         GlobalNavSiteTreeExtension::create_static_navs();
     }
 }
开发者ID:newleeland,项目名称:silverstripe-globaltoolbar,代码行数:7,代码来源:GlobalNavControllerExtension.php

示例7: init

 function init()
 {
     parent::init();
     // Special case for dev/build: Defer permission checks to DatabaseAdmin->init() (see #4957)
     $requestedDevBuild = stripos($this->request->getURL(), 'dev/build') === 0;
     // We allow access to this controller regardless of live-status or ADMIN permission only
     // if on CLI.  Access to this controller is always allowed in "dev-mode", or of the user is ADMIN.
     $canAccess = $requestedDevBuild || Director::isDev() || Director::is_cli() || Permission::check("ADMIN");
     if (!$canAccess) {
         return Security::permissionFailure($this);
     }
     // check for valid url mapping
     // lacking this information can cause really nasty bugs,
     // e.g. when running Director::test() from a FunctionalTest instance
     global $_FILE_TO_URL_MAPPING;
     if (Director::is_cli()) {
         if (isset($_FILE_TO_URL_MAPPING)) {
             $fullPath = $testPath = BASE_PATH;
             while ($testPath && $testPath != "/" && !preg_match('/^[A-Z]:\\\\$/', $testPath)) {
                 $matched = false;
                 if (isset($_FILE_TO_URL_MAPPING[$testPath])) {
                     $matched = true;
                     break;
                 }
                 $testPath = dirname($testPath);
             }
             if (!$matched) {
                 echo 'Warning: You probably want to define ' . 'an entry in $_FILE_TO_URL_MAPPING that covers "' . Director::baseFolder() . '"' . "\n";
             }
         } else {
             echo 'Warning: You probably want to define $_FILE_TO_URL_MAPPING in ' . 'your _ss_environment.php as instructed on the "sake" page of the doc.silverstripe.org wiki' . "\n";
         }
     }
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:34,代码来源:DevelopmentAdmin.php

示例8: updateCMSFields

 /**
  * CMS Fields
  * @return FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     if (!Permission::check("VIEW_SECTIONS")) {
         return $fields;
     }
     $SectionGrid = GridFieldConfig_RelationEditor::create()->removeComponentsByType('GridFieldAddNewButton')->addComponent(new GridFieldAddNewMultiClass())->addComponent(new GridFieldOrderableRows());
     $SectionGrid->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('AdminTitle', 'MenuTitle'))->setResultsFormat('$AdminTitle - $Type');
     $AvailableTypes = $this->AvailableSectionTypes();
     foreach ($AvailableTypes as $key => $value) {
         if ($value['selectable_option'] && !$value['limit_reached']) {
             $AvailableTypes[$key] = $value['type'];
         }
     }
     $SectionGrid->getComponentByType('GridFieldAddNewMultiClass')->setClasses($AvailableTypes);
     // Limit total sections
     $LimitSectionTotal = Config::inst()->get($this->owner->ClassName, 'LimitSectionTotal');
     if (isset($LimitSectionTotal) && $this->owner->Sections()->Count() >= $LimitSectionTotal) {
         // remove the buttons if we don't want to allow more records to be added/created
         $SectionGrid->removeComponentsByType('GridFieldAddNewButton');
         $SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
         $SectionGrid->removeComponentsByType('GridFieldAddNewMultiClass');
     }
     if (!Permission::check("LINK_SECTIONS")) {
         $SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
     }
     if (!Permission::check("REORDER_SECTIONS")) {
         $SectionGrid->removeComponentsByType('GridFieldOrderableRows');
     }
     if (!Permission::check("UNLINK_SECTIONS")) {
         $SectionGrid->removeComponentsByType('GridFieldDeleteAction');
     }
     $fields->addFieldToTab('Root.Section', GridField::create('Sections', 'Current Section(s)', $this->owner->Sections(), $SectionGrid));
     $fields->addFieldToTab('Root.Preview', UploadField::create('PreviewImage', 'Preview image')->setFolderName('Preview'));
     return $fields;
 }
开发者ID:coreiho,项目名称:silverstripe-sections,代码行数:39,代码来源:SectionPageExtension.php

示例9: init

 /**
  * Loads the requirements, checks perms, etc. If an ID is in the URL, that becomes the
  * current folder.
  */
 public function init()
 {
     parent::init();
     if (!Permission::check("ADMIN") && !Permission::check("CMS_ACCESS_BrowseFiles")) {
         return Security::permissionFailure($this, _t('KickAssets.PERMISSIONFAIL', 'You do not have permission to access this section of the CMS.'));
     }
     Requirements::clear();
     Requirements::css('kickassets/css/core.css');
     Requirements::css('kickassets/css/kickassets.css');
     Requirements::javascript('kickassets/javascript/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
     Requirements::javascript('kickassets/javascript/apprise/apprise-1.5.full.js');
     Requirements::javascript('kickassets/javascript/jquery.tooltip.js');
     Requirements::css('kickassets/javascript/apprise/apprise.css');
     Requirements::javascript('kickassets/javascript/kickassets_ui.js');
     Requirements::javascript('kickassets/javascript/chosen/chosen.jquery.js');
     Requirements::css('kickassets/javascript/chosen/chosen.css');
     Requirements::javascript('kickassets/javascript/jquery.form.js');
     Requirements::javascript('kickassets/javascript/kickassets.js');
     Requirements::css('kickassets/css/kickassets_ui.css');
     if ($this->getRequest()->param('ID')) {
         $this->currentFolder = DataObject::get_by_id("Folder", (int) $this->getRequest()->param('ID'));
         $this->currentPath = KickAssetUtil::relative_asset_dir($this->currentFolder->Filename);
     } else {
         $this->currentFolder = singleton('Folder');
         $this->currentPath = false;
     }
 }
开发者ID:heyday,项目名称:KickAssets,代码行数:32,代码来源:KickAssetAdmin.php

示例10: authorize

 /**
  * @return bool
  */
 protected function authorize()
 {
     if (!Permission::check('ADMIN_SUMMIT_APP_FRONTEND_ADMIN')) {
         return false;
     }
     return $this->checkOwnAjaxRequest();
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:10,代码来源:SummitAppMembersApi.php

示例11: init

 /**
  * Initialises the controller and ensures that only
  * ADMIN level users can access this controller
  */
 public function init()
 {
     parent::init();
     if (!Permission::check('ADMIN')) {
         return $this->httpError(403);
     }
 }
开发者ID:mparkhill,项目名称:silverstripe-codeblocks,代码行数:11,代码来源:CodeBlockController.php

示例12: init

 public function init()
 {
     parent::init();
     if (!Permission::check('CMS_ACCESS')) {
         Security::permissionFailure();
     }
 }
开发者ID:azt3k,项目名称:abc-silverstripe-social,代码行数:7,代码来源:SocialAdmin.php

示例13: index

 public function index(SS_HTTPRequest $request)
 {
     if (!Director::isDev() && !Permission::check('CMS_ACCESS_CMSMain')) {
         return Security::permissionFailure($this);
     }
     if ($request->latestParam('ID')) {
         $templates = $this->templateArray();
         if (isset($templates[$request->latestParam('ID')])) {
             $next = false;
             $previous = false;
             $useNext = false;
             foreach ($templates as $k => $v) {
                 if ($useNext) {
                     $next = new ArrayData(array('Name' => $v['Name'], 'Link' => 'patterns/index/' . $k));
                     break;
                 }
                 if ($k == $request->latestParam('ID')) {
                     // mat
                     $useNext = true;
                 } else {
                     $previous = new ArrayData(array('Name' => $v['Name'], 'Link' => 'patterns/index/' . $k));
                 }
             }
             return $this->customise(new ArrayData(array('ClassName' => 'Pattern', 'IsPatternLab' => true, 'PreviousPattern' => $previous, 'NextPattern' => $next, 'PatternName' => $templates[$request->latestParam('ID')]['Name'], 'Patterns' => $this->renderWith(array($templates[$request->latestParam('ID')]['Template'])))))->renderWith($templates[$request->latestParam('ID')]['Template']);
         }
     }
     return $this->renderWith(array(__CLASS__, 'Page'));
 }
开发者ID:dnadesign,项目名称:silverstripe-patternlab,代码行数:28,代码来源:PatternLab.php

示例14: canCreate

 /**
  * @param Member $member
  * @return boolean
  */
 public function canCreate($member = null)
 {
     if (!$member) {
         $member = Member::currentUser();
     }
     return false || Permission::check('ADMIN', 'any', $member) || Permission::check('CMS_ACCESS_AdvancedReportsAdmin', 'any', $member);
 }
开发者ID:helpfulrobot,项目名称:maldicore-advancedreports,代码行数:11,代码来源:RelatedReport.php

示例15: init

 public function init()
 {
     if (!Permission::check("ADMIN")) {
         Security::permissionFailure();
     }
     parent::init();
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:7,代码来源:EmailUtilsPage.php


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