| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- class Core_AclHelper {// Helper class for Acl
- public static function hasCreatePerms($acl) {
- foreach ($acl->getFieldListByIdZasob() as $fieldName) {// TODO: use getFieldList
- // echo"<p>\$acl->canCreateField({$fieldName}): (".$acl->canCreateField($fieldName).")</p>";
- if ($acl->canCreateField($fieldName)) return true;
- }
- return false;
- }
- public static function hasGeomFields($acl) {
- foreach ($acl->getFieldListByIdZasob() as $fieldName) {
- // echo"<p>\$acl->isGeomField({$fieldName}): (".$acl->isGeomField($fieldName).") \$acl->canReadField({$fieldName}): (".$acl->canReadField($fieldName).")</p>";
- if ($acl->isGeomField($fieldName) && $acl->canReadField($fieldName)) return true;
- }
- return false;
- }
- public static function getAclByNamespace($namespace, $forceTblAclInit) {
- if ('http' != substr($namespace, 0, 4)) $namespace = Api_WfsNs::getBaseWfsUri() . '/' . $namespace;//Request::getHostUri() . '/' . $namespace;
- $baseNsUri = Api_WfsNs::getBaseWfsUri();
- if ("{$baseNsUri}/" == substr($namespace, 0, strlen($baseNsUri) + 1)) {
- $schemaNs = substr($namespace, strlen($baseNsUri) + 1);
- $ns = explode('/', $schemaNs);// "http://biuro.biall-net.pl/wfs/ default_db/{$nazwa_tabeli}/{$nazwa_obj}
- $sourceName = array_shift($ns);// remove first element - source name
- if ('default_db' == $sourceName || 'p5_default_db' == $sourceName) {
- $sourceName = 'default_db';
- $objName = $ns[0];
- if (1 == count($ns)) {
- $acl = User::getAcl()->getObjectAcl($sourceName, $objName);
- if (!$acl) throw new Exception("Could not get acl for '{$schemaNs}'");
- $acl->init($forceTblAclInit);
- return $acl;
- }
- else throw new Exception("Nieznany namespace default_db: '{$schemaNs}'", 501);
- }
- else if ('default_objects' == $sourceName || 'SystemObjects' == $sourceName || 'p5_objects' == $sourceName) {
- $sourceName = 'objects';
- $objName = $ns[0];
- if (1 == count($ns)) {
- $acl = User::getAcl()->getObjectAcl($sourceName, $objName);
- if (!$acl) throw new Exception("Could not get acl for '{$schemaNs}'");
- $acl->init($forceTblAclInit);
- return $acl;
- }
- else throw new Exception("Nieznany namespace SystemObjects: '{$schemaNs}'", 501);
- }
- else if ('zasob_' == substr($sourceName, 0, 6)) {
- $dbName = substr($sourceName, 6);
- throw new Exception("TODO db[{$dbName}] namespace '{$schemaNs}'", 501);
- }
- else throw new Exception("Nieznany namespace '{$schemaNs}'", 501);
- }
- else throw new HttpException("Zasoby zewnętrzenj systemu nie są jeszcze zaimplementowane", 501);
- throw new HttpException("TODO L.".__LINE__." ns({$namespace})", 501);
- }
- }
|