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


PHP Permission::checkMember方法代码示例

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


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

示例1: update_cms_actions

 /**
  * @param FieldSet $actions
  * @parma SiteTree $page
  */
 public static function update_cms_actions(&$actions, $page)
 {
     $openRequest = $page->OpenWorkflowRequest();
     // if user doesn't have publish rights
     if (!$page->canPublish() || $openRequest) {
         // authors shouldn't be able to revert, as this republishes the page.
         // they should rather change the page and re-request publication
         $actions->removeByName('action_revert');
     }
     // Remove the one click publish if they are not an admin/workflow admin.
     if (self::$force_publishers_to_use_workflow && !Permission::checkMember(Member::currentUser(), 'IS_WORKFLOW_ADMIN')) {
         $actions->removeByName('action_publish');
     }
     // Remove the save & publish button if you don't have edit rights
     if (!$page->canEdit()) {
         $actions->removeByName('action_publish');
     }
     $liveVersion = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree_Live\".\"ID\" = {$page->ID}");
     if ($liveVersion && $liveVersion->ExpiryDate != null && $liveVersion->ExpiryDate != '0000-00-00 00:00:00') {
         if ($page->canApprove()) {
             $actions->push(new FormAction('cms_cancelexpiry', _t('WorkflowPublicationRequest.BUTTONCANCELEXPIRY', 'Cancel expiry')));
         }
     }
     // Optional method
     $isPublishable = $page->hasMethod('isPublishable') ? $page->isPublishable() : true;
     if (!$openRequest && $page->canEdit() && $isPublishable && $page->stagesDiffer('Stage', 'Live') && ($page->Version > 1 || $page->Title != "New Page") && !$page->IsDeletedFromStage && (!$page->canPublish() || self::$publisher_can_create_wf_requests)) {
         $actions->push($requestPublicationAction = new FormAction('cms_requestpublication', _t('SiteTreeCMSWorkflow.BUTTONREQUESTPUBLICATION', 'Request Publication')));
         // don't allow creation of a second request by another author
         if (!self::can_create(null, $page)) {
             $actions->makeFieldReadonly($requestPublicationAction->Name());
         }
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-cmsworkflow,代码行数:37,代码来源:WorkflowPublicationRequest.php

示例2: can_abort_deployment

 /**
  * @param \DNEnvironment $environment
  * @param \Member|null $member
  * @return bool
  */
 public static function can_abort_deployment(\DNEnvironment $environment, \Member $member = null)
 {
     if ($member === null) {
         $member = \Member::currentUser();
     }
     return \Permission::checkMember($member, 'ADMIN');
 }
开发者ID:silverstripe,项目名称:deploynaut,代码行数:12,代码来源:DeployDispatcher.php

示例3: isAdminUser

 public function isAdminUser(Member $user)
 {
     if (Permission::checkMember($user, 'ADMIN')) {
         return true;
     }
     return false;
 }
开发者ID:normann,项目名称:advancedworkflow,代码行数:7,代码来源:AdvancedWorkflowAdmin.php

示例4: canEdit

 public function canEdit($member = null)
 {
     if (!$member) {
         $member = Member::currentUser();
     }
     return Permission::checkMember($member, array('CMS_ACCESS_AssetAdmin', 'CMS_ACCESS_LeftAndMain'));
 }
开发者ID:novatio,项目名称:silverstripe-aviary,代码行数:7,代码来源:AviaryUpload.php

示例5: canPublish

 /**
  * This function should return true if the current user can publish pages
  * on this site by default
  *
  * @return boolean
  */
 public function canPublish($member = null)
 {
     if (!$member && $member !== FALSE) {
         $member = Member::currentUser();
     }
     if (is_numeric($member)) {
         $member = DataObject::get_by_id('Member', $member);
     }
     // check for admin permission
     if (Permission::checkMember($member, 'ADMIN')) {
         return true;
     }
     // check for workflow admin permission
     if (Permission::checkMember($member, 'IS_WORKFLOW_ADMIN')) {
         return true;
     }
     // check for missing cmsmain permission
     if (!Permission::checkMember($member, 'CMS_ACCESS_CMSMain')) {
         return false;
     }
     // check for empty spec
     if (!$this->owner->CanPublishType || $this->owner->CanPublishType == 'Anyone') {
         return true;
     }
     // check for any logged-in users
     if ($this->owner->CanPublishType == 'LoggedInUsers' && !Permission::checkMember($member, 'CMS_ACCESS_CMSMain')) {
         return false;
     }
     // check for specific groups
     if ($this->owner->CanPublishType == 'OnlyTheseUsers' && (!$member || !$member->inGroups($this->owner->PublisherGroups()))) {
         return false;
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-cmsworkflow,代码行数:40,代码来源:SiteConfigTwoStepWorkflow.php

示例6: requireLogin

 /**
  * Require basic authentication.  Will request a username and password if none is given.
  * 
  * Used by {@link Controller::init()}.
  * 
  * @param string $realm
  * @param string|array $permissionCode
  * @return Member $member 
  */
 static function requireLogin($realm, $permissionCode)
 {
     if (!Security::database_is_ready() || Director::is_cli()) {
         return true;
     }
     if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
         $member = MemberAuthenticator::authenticate(array('Email' => $_SERVER['PHP_AUTH_USER'], 'Password' => $_SERVER['PHP_AUTH_PW']), null);
         if ($member) {
             $authenticated = true;
         }
     }
     // If we've failed the authentication mechanism, then show the login form
     if (!isset($authenticated)) {
         header("WWW-Authenticate: Basic realm=\"{$realm}\"");
         header($_SERVER['SERVER_PROTOCOL'] . ' 401 Unauthorized');
         if (isset($_SERVER['PHP_AUTH_USER'])) {
             echo _t('BasicAuth.ERRORNOTREC', "That username / password isn't recognised");
         } else {
             echo _t('BasicAuth.ENTERINFO', "Please enter a username and password.");
         }
         die;
     }
     if (!Permission::checkMember($member->ID, $permissionCode)) {
         header("WWW-Authenticate: Basic realm=\"{$realm}\"");
         header($_SERVER['SERVER_PROTOCOL'] . ' 401 Unauthorized');
         if (isset($_SERVER['PHP_AUTH_USER'])) {
             echo _t('BasicAuth.ERRORNOTADMIN', "That user is not an administrator.");
         }
         die;
     }
     return $member;
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:41,代码来源:BasicAuth.php

示例7: regenerateToken

 /**
  *	Attempt to regenerate the current security token.
  */
 public function regenerateToken()
 {
     // Restrict this functionality to administrators.
     $user = Member::currentUserID();
     if (Permission::checkMember($user, 'ADMIN')) {
         // Attempt to create a random hash.
         $regeneration = $this->service->generateHash();
         if ($regeneration) {
             // Instantiate the new security token.
             $token = APIwesomeToken::create();
             $token->Hash = $regeneration['hash'];
             $token->AdministratorID = $user;
             $token->write();
             // Temporarily use the session to display the new security token key.
             Session::set('APIwesomeToken', "{$regeneration['key']}:{$regeneration['salt']}");
         } else {
             // Log the failed security token regeneration.
             SS_Log::log('APIwesome security token regeneration failed.', SS_Log::ERR);
             Session::set('APIwesomeToken', -1);
         }
         // Determine where the request came from.
         $from = $this->getRequest()->getVar('from');
         $redirect = $from ? $from : 'admin/json-xml/';
         return $this->redirect($redirect);
     } else {
         return $this->httpError(404);
     }
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-apiwesome,代码行数:31,代码来源:APIwesome.php

示例8: canView

 /**
  * Has the user been granted access to view the Live Chat tab?
  * @param Member|null $member
  * @return boolean
  */
 public function canView($member = null)
 {
     if (!$member && $member !== FALSE) {
         $member = Member::currentUser();
     }
     return Permission::checkMember($member, "CMS_ACCESS_LiveChatAdmin");
 }
开发者ID:helpfulrobot,项目名称:otago-livechat,代码行数:12,代码来源:LiveChatAdmin.php

示例9: canEdit

 /**
  * Shop Admins can edit
  * @param Member $member
  * @return Boolean
  */
 function canEdit($member = null)
 {
     if (Permission::checkMember($member, Config::inst()->get("EcommerceRole", "admin_permission_code"))) {
         return true;
     }
     return parent::canEdit($member);
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:12,代码来源:AccountPage.php

示例10: updateCMSFields

 /**
  * Adds token creation fields to CMS
  * 
  * @param FieldSet $fields
  * @return void
  */
 public function updateCMSFields(FieldSet &$fields)
 {
     // Only modify file objects with parent nodes
     if (!$this->owner instanceof Folder || !$this->owner->ID) {
         return;
     }
     // Only allow ADMIN and SECURE_FILE_SETTINGS members to edit these options
     if (!Permission::checkMember(Member::currentUser(), array('ADMIN', 'SECURE_FILE_SETTINGS'))) {
         return;
     }
     // Update Security Tab
     $secureFilesTab = $fields->findOrMakeTab('Root.' . _t('SecureFiles.SECUREFILETABNAME', 'Security'));
     $secureFilesTab->push(new HeaderField(_t('SecureFiles.TOKENACCESSTITLE', 'Token Access')));
     if (!$this->owner->containsFiles()) {
         $secureFilesTab->push(new ReadonlyField('DummyTokenList', '', _t('SecureFiles.NOFILESINFOLDER', 'There are no files in this folder.')));
         return;
     }
     $secureFilesTab->push($tokenList = new ComplexTableField($this->owner, 'ContainedFileTokens', 'SecureFileAccessToken', null, null, "File.ParentID = '{$this->owner->ID}'", $sourceSort = null, "JOIN File ON FileID = File.ID"));
     $tokenList->setParentIdName('FolderID');
     $tokenList->setRelationAutoSetting(false);
     // Remove add link if there are no files in this folder
     if (!$this->owner->containsFiles()) {
         $tokenList->setPermissions(array('edit', 'delete'));
     }
 }
开发者ID:hamishcampbell,项目名称:silverstripe-securefiles,代码行数:31,代码来源:SecureFileTokenPermissionDecorator.php

示例11: updateEditForm

 /**
  *	Display the current security token (allowing regeneration for an administrator).
  */
 public function updateEditForm(&$form)
 {
     // Determine whether the security section is being used.
     if ($this->owner instanceof SecurityAdmin) {
         $gridfield = null;
         foreach ($form->fields->items[0]->Tabs()->first()->Fields() as $field) {
             if ($field instanceof GridField) {
                 $gridfield = $field;
                 break;
             }
         }
     } else {
         $gridfield = $form->fields->items[0];
     }
     if (isset($gridfield) && $gridfield instanceof GridField) {
         // Restrict the security token to administrators.
         $user = Member::currentUserID();
         if (Permission::checkMember($user, 'ADMIN')) {
             Requirements::css(APIWESOME_PATH . '/css/apiwesome.css');
             // Display a confirmation message when regenerating the security token.
             Requirements::javascript(APIWESOME_PATH . '/javascript/apiwesome.js');
             $configuration = $gridfield->config;
             $configuration->addComponent(new APIwesomeTokenView());
         }
     }
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-apiwesome,代码行数:29,代码来源:APIwesomeTokenExtension.php

示例12: canView

 public function canView($member = null)
 {
     if (!$member) {
         $member = Member::currentUser();
     }
     return Permission::checkMember($member, 'ADMIN');
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:7,代码来源:SilverStripeNavigatorTest.php

示例13: updateCMSFields

 /**
  * Adds group select fields to CMS
  * 
  * @param FieldSet $fields
  * @return void
  */
 public function updateCMSFields(FieldSet &$fields)
 {
     // Only modify folder objects with parent nodes
     if (!$this->owner instanceof Folder || !$this->owner->ID) {
         return;
     }
     // Only allow ADMIN and SECURE_FILE_SETTINGS members to edit these options
     if (!Permission::checkMember(Member::currentUser(), array('ADMIN', 'SECURE_FILE_SETTINGS'))) {
         return;
     }
     // Update Security Tab
     $secureFilesTab = $fields->findOrMakeTab('Root.' . _t('SecureFiles.SECUREFILETABNAME', 'Security'));
     $secureFilesTab->push(new HeaderField(_t('SecureFiles.GROUPACCESSTITLE', 'Group Access')));
     $secureFilesTab->push(new TreeMultiselectField('GroupPermissions', _t('SecureFiles.GROUPACCESSFIELD', 'Group Access Permissions')));
     if ($this->owner->InheritSecured()) {
         $permissionGroups = $this->owner->InheritedGroupPermissions();
         if ($permissionGroups->Count()) {
             $fieldText = implode(", ", $permissionGroups->map());
         } else {
             $fieldText = _t('SecureFiles.NONE', "(None)");
         }
         $InheritedGroupsField = new ReadonlyField("InheritedGroupPermissionsText", _t('SecureFiles.GROUPINHERITEDPERMS', 'Inherited Group Permissions'), $fieldText);
         $InheritedGroupsField->addExtraClass('prependUnlock');
         $secureFilesTab->push($InheritedGroupsField);
     }
 }
开发者ID:hamishcampbell,项目名称:silverstripe-securefiles,代码行数:32,代码来源:SecureFileGroupPermissionDecorator.php

示例14: canCreate

 /**
  * Inherits from the parent blog or can be overwritten using a DataExtension.
  *
  * @param null|Member $member
  *
  * @return bool
  */
 public function canCreate($member = null)
 {
     $extended = $this->extendedCan(__FUNCTION__, $member);
     if ($extended !== null) {
         return $extended;
     }
     $permission = Blog::config()->grant_user_permission;
     return Permission::checkMember($member, $permission);
 }
开发者ID:unclecheese,项目名称:silverstripe-blog,代码行数:16,代码来源:BlogTag.php

示例15: canView

 function canView($member = null)
 {
     if ($member = Member::currentUser()) {
         if ($member->inGroup("ADMIN") || Permission::checkMember($member, self::$permission_code)) {
             return true;
         }
     }
     return false;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-membersonlypages,代码行数:9,代码来源:MembersOnlyPage.php


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