public function setAsset(Asset $asset) { $property = $this->getProperty(); $property->referencedAssetId = $asset->getId(); $property->referencedAssetPath = $asset->getPath(); $property->referencedAssetType = $asset->getType(); $asset = new \stdClass(); $asset->{$p = $this->getPropertyName()} = $property; // edit asset $service = $this->getService(); $service->edit($asset); if (!$service->isSuccessful()) { throw new e\EditingFailureException(S_SPAN . c\M::EDIT_ASSET_FAILURE . E_SPAN . $service->getMessage()); } return $this->reloadProperty(); }
private function setAccess(a\Asset $a, $level) { $type = $a->getType(); if ($type != c\T::USER && $type != c\T::GROUP) { throw new e\WrongAssetTypeException(c\M::ACCESS_TO_USERS_GROUPS); } if (!c\LevelValues::isLevel($level)) { throw new e\UnacceptableValueException("The level {$level} is unacceptable."); } $entry = $this->getEntry($a); // not exist if ($entry == NULL) { $entry_std = new \stdClass(); $entry_std->level = $level; $entry_std->type = $a->getType(); $entry_std->name = $a->getName(); $this->acl_entries[] = new AclEntry($entry_std); } else { $entry->setLevel($level); } }
public function grantAccess($type, $id_path, $site_name = NULL, $applied_to_children = false, Asset $a = NULL, $level = c\T::READ) { $ari = $this->getAccessRights($type, $id_path, $site_name); if ($a == NULL || $a->getType() != Group::TYPE && $a->getType() != User::TYPE) { throw new e\WrongAssetTypeException(S_SPAN . c\M::ACCESS_TO_USERS_GROUPS . E_SPAN); } if (!c\LevelValues::isLevel($level)) { throw new e\UnacceptableValueException(S_SPAN . "The level {$level} is unacceptable." . E_SPAN); } if ($a->getType() == Group::TYPE && $level == c\T::READ) { if (self::DEBUG) { u\DebugUtility::out("Granting " . $a->getName() . " read access to " . $id_path); } $func_name = 'grantGroupReadAccess'; } else { if ($a->getType() == Group::TYPE && $level == c\T::WRITE) { if (self::DEBUG) { u\DebugUtility::out("Granting " . $a->getName() . " write access to " . $id_path); } $func_name = 'grantGroupWriteAccess'; } else { if ($a->getType() == User::TYPE && $level == c\T::READ) { if (self::DEBUG) { u\DebugUtility::out("Granting " . $a->getName() . " read access to " . $id_path); } $func_name = 'grantUserReadAccess'; } else { if ($a->getType() == User::TYPE && $level == c\T::WRITE) { if (self::DEBUG) { u\DebugUtility::out("Granting " . $a->getName() . " write access to " . $id_path); } $func_name = 'grantUserWriteAccess'; } } } } if (isset($func_name)) { $ari->{$func_name}($a); $this->setAccessRights($ari, $applied_to_children); } else { if (self::DEBUG) { u\DebugUtility::out("The function name is not set."); } } return $this; }
public function setBaseAsset(Asset $a = NULL) { if (isset($a)) { $type = $a->getType(); if (u\StringUtility::startsWith(strtolower($type), 'block')) { $type = 'block'; } else { if (u\StringUtility::startsWith(strtolower($type), 'format')) { $type = 'format'; } } $this->getProperty()->assetType = $type; $this->getProperty()->baseAssetId = $a->getId(); $this->getProperty()->baseAssetPath = $a->getPath(); } else { $this->getProperty()->assetType = File::TYPE; // dummpy type $this->getProperty()->baseAssetId = NULL; $this->getProperty()->baseAssetPath = NULL; } return $this; }