hasField($remoteTypeName)) throw new Exception("Missing field in given object. Field '{$remoteTypeName}' not exists in '{$typeName}'"); if (!$acl->canCreateField($remoteTypeName)) throw new HttpException("Forbidden create relations from {$typeName} to {$remoteTypeName} ", 403); $item = $acl->getItem($primaryKey); if (!$item) throw new HttpException("Object not found {$typeName}.{$primaryKey}", 404); if (!$acl->canWriteObjectField($remoteTypeName, $item)) throw new HttpException("Forbidden create relations from {$typeName}.{$primaryKey} to {$remoteTypeName} ", 403); return true; } static function isAllowedToGetRelation($userLogin, $typeName, $primaryKey, $remoteTypeName) { if ($userLogin !== User::getLogin()) throw new Exception("Not Implemented - isAllowedToGetRelation for another user"); $acl = ACL::getAclByNamespace( Api_WfsNs::toNamespace($typeName) ); if (!$acl->hasField($remoteTypeName)) throw new Exception("Missing field in given object. Field '{$remoteTypeName}' not exists in '{$typeName}'"); if (!$acl->canReadField($remoteTypeName)) throw new HttpException("Forbidden reading relations from {$typeName} to {$remoteTypeName} ", 403); $item = $acl->getItem($primaryKey); if (!$item) throw new HttpException("Object not found {$typeName}.{$primaryKey}", 404); if (!$acl->canReadObjectField($remoteTypeName, $item)) throw new HttpException("Forbidden reading relations from {$typeName}.{$primaryKey} to {$remoteTypeName} ", 403); return true; } static function isAllowedToDeleteRelation($userLogin, $typeName, $primaryKey, $remoteTypeName) { DBG::log("TODO: Relations::isAllowedToDeleteRelation()..."); return false; } static function getRelations($typeName, $primaryKey, $remoteTypeName) { $namespace = Api_WfsNs::toNamespace($typeName); return ACL::fetchRefs($namespace, $primaryKey, $remoteTypeName); } static function createRelations($typeName, $primaryKey, $remoteTypeName, $listRemotePrimaryKeys) { $namespace = Api_WfsNs::toNamespace($typeName); $acl = ACL::getAclByNamespace($namespace); ACL::addListRef($namespace, $remoteTypeName, $primaryKey, $listRemotePrimaryKeys); } static function deleteRelations($typeName, $primaryKey, $remoteTypeName, $listRemotePrimaryKeys) { $namespace = Api_WfsNs::toNamespace($typeName); $acl = ACL::getAclByNamespace($namespace); ACL::removeListRef($namespace, $remoteTypeName, $primaryKey, $listRemotePrimaryKeys); } }