本文整理汇总了PHP中Permission::permissions_for_member方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::permissions_for_member方法的具体用法?PHP Permission::permissions_for_member怎么用?PHP Permission::permissions_for_member使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::permissions_for_member方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPermissionsForMember
public function testPermissionsForMember()
{
$member = $this->objFromFixture('Member', 'access');
$permissions = Permission::permissions_for_member($member->ID);
$this->assertEquals(4, count($permissions));
$this->assertTrue(in_array('CMS_ACCESS_MyAdmin', $permissions));
$this->assertTrue(in_array('CMS_ACCESS_AssetAdmin', $permissions));
$this->assertTrue(in_array('CMS_ACCESS_SecurityAdmin', $permissions));
$this->assertTrue(in_array('EDIT_PERMISSIONS', $permissions));
$group = $this->objFromFixture("Group", "access");
Permission::deny($group->ID, "CMS_ACCESS_MyAdmin");
$permissions = Permission::permissions_for_member($member->ID);
$this->assertEquals(3, count($permissions));
$this->assertFalse(in_array('CMS_ACCESS_MyAdmin', $permissions));
}
示例2: init
public function init()
{
if (!Controller::has_curr()) {
return;
}
/* @var $ctrl Controller */
$ctrl = Controller::curr();
/* @ var $req SS_HTTPRequest */
$req = $ctrl->getRequest();
// Otherwise it will get excluded if it does not have access to all subsites...
if (class_exists('Subsite')) {
Subsite::$disable_subsite_filter = true;
}
$base = AdminRootController::config()->url_base;
$defaultPanel = AdminRootController::config()->default_panel;
$currentSegment = $req->getURL();
// We will fail if we are redirected to a panel without the proper permission
if (($currentSegment == $base || $currentSegment == $base . '/pages') && $defaultPanel == 'CMSPagesController' && !Permission::check('CMS_ACCESS_CMSMain')) {
// Instead, let's redirect to something we can access
if (Permission::check('CMS_ACCESS')) {
$member = Member::currentUser();
$permissions = Permission::permissions_for_member($member->ID);
foreach ($permissions as $permission) {
if (strpos($permission, 'CMS_ACCESS_') === 0) {
$class = str_replace('CMS_ACCESS_', '', $permission);
$segment = Config::inst()->get($class, 'url_segment');
$url = Director::absoluteBaseURL() . $base . '/' . $segment;
header('Location:' . $url);
exit;
}
}
}
}
if (class_exists('Subsite')) {
Subsite::$disable_subsite_filter = false;
}
}
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-devtoolkit,代码行数:37,代码来源:DevToolkitLeftAndMainExtension.php
示例3: 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;
}