Example #1
0
 public static function getByID($paID, PermissionKey $pk, $checkPA = true)
 {
     $cache = Core::make('cache/request');
     $identifier = sprintf('permission/access/%s/%s', $pk->getPermissionKeyID(), $paID);
     $item = $cache->getItem($identifier);
     if (!$item->isMiss()) {
         return $item->get();
     }
     $db = Database::connection();
     $handle = $pk->getPermissionKeyCategoryHandle();
     if ($pk->permissionKeyHasCustomClass()) {
         $handle = $pk->getPermissionKeyHandle() . '_' . $handle;
     }
     $class = '\\Core\\Permission\\Access\\' . Core::make('helper/text')->camelcase($handle) . 'Access';
     $class = core_class($class, $pk->getPackageHandle());
     $obj = null;
     if ($checkPA) {
         $row = $db->GetRow('select paID, paIsInUse from PermissionAccess where paID = ?', array($paID));
         if ($row && $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 (isset($obj)) {
         $obj->setPermissionKey($pk);
     }
     $item->set($obj);
     return $obj;
 }
Example #2
0
 /**
  * Returns whether a permission key has a custom class.
  */
 public function permissionKeyHasCustomClass()
 {
     return parent::permissionKeyHasCustomClass();
 }