public function assignPermissions($userOrGroup, $permissions = [], $accessType = Key::ACCESS_TYPE_INCLUDE, $cascadeToChildren = true) { if (!$cascadeToChildren) { $this->setChildPermissionsToOverride(); } $this->setPermissionsToOverride(); if (is_array($userOrGroup)) { $pe = GroupCombinationEntity::getOrCreate($userOrGroup); // group combination } elseif ($userOrGroup instanceof User || $userOrGroup instanceof \Concrete\Core\User\UserInfo || $userOrGroup instanceof \Concrete\Core\User\User) { $pe = UserEntity::getOrCreate($userOrGroup); } elseif ($userOrGroup instanceof Entity) { $pe = $userOrGroup; } else { // group; $pe = GroupEntity::getOrCreate($userOrGroup); } foreach ($permissions as $pkHandle) { $pk = Key::getByHandle($pkHandle); $pk->setPermissionObject($this); $pa = $pk->getPermissionAccessObject(); if (!is_object($pa)) { $pa = Access::create($pk); } elseif ($pa->isPermissionAccessInUse()) { $pa = $pa->duplicate(); } $pa->addListItem($pe, false, $accessType); $pt = $pk->getPermissionAssignmentObject(); $pt->assignPermissionAccess($pa); } }
public function removePermissions($userOrGroup, $permissions = array()) { if ($this->cInheritPermissionsFrom != 'OVERRIDE') { return; } if (is_array($userOrGroup)) { $pe = GroupCombinationPermissionAccessEntity::getOrCreate($userOrGroup); // group combination } elseif ($userOrGroup instanceof User || $userOrGroup instanceof UserInfo) { $pe = UserPermissionAccessEntity::getOrCreate($userOrGroup); } else { // group; $pe = GroupPermissionAccessEntity::getOrCreate($userOrGroup); } foreach ($permissions as $pkHandle) { $pk = PagePermissionKey::getByHandle($pkHandle); $pk->setPermissionObject($this); $pa = $pk->getPermissionAccessObject(); if (is_object($pa)) { if ($pa->isPermissionAccessInUse()) { $pa = $pa->duplicate(); } $pa->removeListItem($pe); $pt = $pk->getPermissionAssignmentObject(); $pt->assignPermissionAccess($pa); } } }
<?php defined('C5_EXECUTE') or die("Access Denied."); use Concrete\Core\Permission\Access\Entity\GroupCombinationEntity as GroupCombinationPermissionAccessEntity; if (Loader::helper('validation/token')->validate('process')) { $js = Loader::helper('json'); $obj = new stdClass(); if (count($_POST['gID']) > 0) { $groups = array(); foreach ($_POST['gID'] as $gID) { $g = Group::getByID($gID); if (is_object($g)) { $groups[] = $g; } } $pae = GroupCombinationPermissionAccessEntity::getOrCreate($groups); $obj->peID = $pae->getAccessEntityID(); $obj->label = $pae->getAccessEntityLabel(); } print $js->encode($obj); }
public function assignPermissions($userOrGroup, $permissions = array(), $accessType = FileSetPermissionKey::ACCESS_TYPE_INCLUDE) { $db = Loader::db(); if ($this->fsID > 0) { $db->Execute("UPDATE FileSets SET fsOverrideGlobalPermissions = 1 WHERE fsID = ?", array($this->fsID)); $this->fsOverrideGlobalPermissions = true; } if (is_array($userOrGroup)) { $pe = GroupCombinationPermissionAccessEntity::getOrCreate($userOrGroup); // group combination } else { if ($userOrGroup instanceof User || $userOrGroup instanceof \UserInfo) { $pe = UserPermissionAccessEntity::getOrCreate($userOrGroup); } else { // group; $pe = GroupPermissionAccessEntity::getOrCreate($userOrGroup); } } foreach ($permissions as $pkHandle) { $pk = PermissionKey::getByHandle($pkHandle); $pk->setPermissionObject($this); $pa = $pk->getPermissionAccessObject(); if (!is_object($pa)) { $pa = PermissionAccess::create($pk); } else { if ($pa->isPermissionAccessInUse()) { $pa = $pa->duplicate(); } } $pa->addListItem($pe, false, $accessType); $pt = $pk->getPermissionAssignmentObject(); $pt->assignPermissionAccess($pa); } }
public function assignPermissions($userOrGroup, $permissions = array(), $accessType = PagePermissionKey::ACCESS_TYPE_INCLUDE) { if ($this->cInheritPermissionsFrom != 'OVERRIDE') { $this->setPermissionsToManualOverride(); $this->clearPagePermissions(); } if (is_array($userOrGroup)) { $pe = GroupCombinationPermissionAccessEntity::getOrCreate($userOrGroup); // group combination } else { if ($userOrGroup instanceof User || $userOrGroup instanceof UserInfo) { $pe = UserPermissionAccessEntity::getOrCreate($userOrGroup); } else { // group; $pe = GroupPermissionAccessEntity::getOrCreate($userOrGroup); } } foreach ($permissions as $pkHandle) { $pk = PagePermissionKey::getByHandle($pkHandle); $pk->setPermissionObject($this); $pa = $pk->getPermissionAccessObject(); if (!is_object($pa)) { $pa = PermissionAccess::create($pk); } else { if ($pa->isPermissionAccessInUse()) { $pa = $pa->duplicate(); } } $pa->addListItem($pe, false, $accessType); $pt = $pk->getPermissionAssignmentObject(); $pt->assignPermissionAccess($pa); } }