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


PHP Permission::get_codes方法代码示例

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


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

示例1: __construct

 /**
  * @param String $name
  * @param String $title
  * @param String $managedClass
  * @param String $filterField
  * @param Group|SS_List $records One or more {@link Group} or {@link PermissionRole} records 
  *  used to determine permission checkboxes.
  *  Caution: saveInto() can only be used with a single record, all inherited permissions will be marked readonly.
  *  Setting multiple groups only makes sense in a readonly context. (Optional)
  */
 public function __construct($name, $title, $managedClass, $filterField, $records = null)
 {
     $this->filterField = $filterField;
     $this->managedClass = $managedClass;
     if ($records instanceof SS_List) {
         $this->records = $records;
     } elseif ($records instanceof Group) {
         $this->records = new ArrayList(array($records));
     } elseif ($records) {
         throw new InvalidArgumentException('$record should be either a Group record, or a SS_List of Group records');
     }
     // Get all available codes in the system as a categorized nested array
     $this->source = Permission::get_codes(true);
     parent::__construct($name, $title);
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:25,代码来源:PermissionCheckboxSetField.php

示例2: __construct

 /**
  * @param String $name
  * @param String $title
  * @param String $managedClass
  * @param String $filterField
  * @param Group|DataObjectSet $records One or more {@link Group} or {@link PermissionRole} records 
  *  used to determine permission checkboxes.
  *  Caution: saveInto() can only be used with a single record, all inherited permissions will be marked readonly.
  *  Setting multiple groups only makes sense in a readonly context. (Optional)
  */
 function __construct($name, $title, $managedClass, $filterField, $records = null)
 {
     $this->filterField = $filterField;
     $this->managedClass = $managedClass;
     if (is_a($records, 'DataObjectSet')) {
         $this->records = $records;
     } elseif (is_a($records, 'DataObject')) {
         $this->records = new DataObjectSet($records);
     } elseif ($records) {
         throw new InvalidArgumentException('$record should be either a Group record, or a DataObjectSet of Group records');
     }
     // Get all available codes in the system as a categorized nested array
     $this->source = Permission::get_codes(true);
     parent::__construct($name, $title);
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:25,代码来源:PermissionCheckboxSetField.php

示例3: onAfterWrite

 public function onAfterWrite()
 {
     parent::onAfterWrite();
     // TODO: should test if this is needed or not
     if (!$this->owner->ID) {
         return;
     }
     // Apply the subsite title to config
     $siteconfig = $this->getSiteConfig();
     if ($siteconfig) {
         if ($siteconfig->Title == _t('Subsite.SiteConfigTitle', 'Your Site Name') && $this->owner->Title) {
             $siteconfig->Title = $this->owner->Title;
             $siteconfig->write();
         }
     }
     // Make sure we have groups for this subsite
     $groupName = $this->getAdministratorGroupName();
     $group = self::getGroupByName($groupName);
     if ($groupName && !$group) {
         $group = new Group();
         $group->Title = $groupName;
         $group->AccessAllSubsites = false;
         $group->write();
         $group->Subsites()->add($this->owner);
         // Apply default permissions to this group
         $codes = array_unique(array_keys(Permission::get_codes(false)));
         $default_permissions = Config::inst()->get('SubsiteExtension', 'admin_default_permissions');
         foreach ($default_permissions as $p) {
             if (in_array($p, $codes)) {
                 $po = new Permission(array('Code' => $p));
                 $po->write();
                 $group->Permissions()->add($po);
             }
         }
         $group->write();
     }
     $membersGroupName = $this->getMembersGroupName();
     $membersGroup = self::getGroupByName($membersGroupName);
     if ($membersGroupName && !$membersGroup) {
         $membersGroup = new Group();
         $membersGroup->Title = $membersGroupName;
         $membersGroup->AccessAllSubsites = true;
         $membersGroup->write();
         $membersGroup->Subsites()->add($this->owner);
         $membersGroup->write();
     }
 }
开发者ID:lekoala,项目名称:silverstripe-subsites-extras,代码行数:47,代码来源:SubsiteExtension.php

示例4: getPermissionsDescription

 /**
  * Builds a comma separated list of human-readbale permissions for a given Member.
  * 
  * @return string
  */
 public function getPermissionsDescription()
 {
     if (class_exists('Subsite')) {
         Subsite::disable_subsite_filter(true);
     }
     $permissionsUsr = Permission::permissions_for_member($this->owner->ID);
     $permissionsSrc = Permission::get_codes(true);
     sort($permissionsUsr);
     $permissionNames = array();
     foreach ($permissionsUsr as $code) {
         $code = strtoupper($code);
         foreach ($permissionsSrc as $k => $v) {
             if (isset($v[$code])) {
                 $name = empty($v[$code]['name']) ? _t('MemberReportExtension.UNKNOWN', 'Unknown') : $v[$code]['name'];
                 $permissionNames[] = $name;
             }
         }
     }
     $result = $permissionNames ? implode(', ', $permissionNames) : _t('MemberReportExtension.NOPERMISSIONS', 'No Permissions');
     if (class_exists('Subsite')) {
         Subsite::disable_subsite_filter(false);
     }
     return $result;
 }
开发者ID:mandrew,项目名称:silverstripe-securityreport,代码行数:29,代码来源:MemberReportExtension.php

示例5: testGetCodesUngrouped

 public function testGetCodesUngrouped()
 {
     $codes = Permission::get_codes(false);
     $this->assertArrayHasKey('SITETREE_VIEW_ALL', $codes);
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:5,代码来源:PermissionTest.php

示例6: __construct

 function __construct($name, $title = "")
 {
     parent::__construct($name, $title, Permission::get_codes(true));
 }
开发者ID:ramziammar,项目名称:websites,代码行数:4,代码来源:PermissionDropdownField.php

示例7: stepCreateGroupWithPermissions

 /**
  * Example: Given a "group" "Admin" with permissions "Access to 'Pages' section" and "Access to 'Files' section"
  * 
  * @Given /^(?:(an|a|the) )"group" "(?<id>[^"]+)" (?:(with|has)) permissions (?<permissionStr>.*)$/
  */
 public function stepCreateGroupWithPermissions($id, $permissionStr)
 {
     // Convert natural language permissions to codes
     preg_match_all('/"([^"]+)"/', $permissionStr, $matches);
     $permissions = $matches[1];
     $codes = \Permission::get_codes(false);
     $group = $this->fixtureFactory->get('Group', $id);
     if (!$group) {
         $group = $this->fixtureFactory->createObject('Group', $id);
     }
     foreach ($permissions as $permission) {
         $found = false;
         foreach ($codes as $code => $details) {
             if ($permission == $code || $permission == $details['name']) {
                 \Permission::grant($group->ID, $code);
                 $found = true;
             }
         }
         if (!$found) {
             throw new \InvalidArgumentException(sprintf('No permission found for "%s"', $permission));
         }
     }
 }
开发者ID:jeffreyguo,项目名称:silverstripe-behat-extension,代码行数:28,代码来源:FixtureContext.php


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