public function assignPermissionAccess(PermissionAccess $pa) { $db = Loader::db(); $db->Replace('PagePermissionAssignments', array('cID' => $this->getPermissionObject()->getPermissionsCollectionID(), 'paID' => $pa->getPermissionAccessID(), 'pkID' => $this->pk->getPermissionKeyID()), array('cID', 'pkID'), true); $pa->markAsInUse(); PermissionCache::clearAccessObject($this->pk, $this->getPermissionObject()); }
public function validate() { $u = new User(); if ($u->isSuperUser()) { return true; } $r = PermissionCache::validate($this); if ($r !== -1) { return $r; } $pae = $this->getPermissionAccessObject(); if (is_object($pae)) { $valid = $pae->validate(); } else { $valid = false; } PermissionCache::addValidate($this, $valid); return $valid; }
public static function getByID($paID, PermissionKey $pk, $checkPA = true) { $db = Loader::db(); $pa = PermissionCache::getPermissionAccessObject($paID, $pk); if (is_object($pa)) { return $pa; } $handle = $pk->getPermissionKeyCategoryHandle(); if ($pk->permissionKeyHasCustomClass()) { $handle = $pk->getPermissionKeyHandle() . '_' . $handle; } $class = '\\Concrete\\Core\\Permission\\Access\\' . Loader::helper('text')->camelcase($handle) . 'Access'; if ($checkPA) { $row = $db->GetRow('select paID, paIsInUse from PermissionAccess where paID = ?', array($paID)); if ($row['paID']) { $obj = Core::make($class); $obj->setPropertiesFromArray($row); } } else { // we got here from an assignment object so we already know its in use. $obj = Core::make($class); $obj->paID = $paID; $obj->paIsInUse = true; } if (is_object($obj)) { $obj->setPermissionKey($pk); } PermissionCache::addPermissionAccessObject($paID, $pk, $obj); return $obj; }