|
|
@@ -4,6 +4,7 @@ Lib::loadClass('Api_WfsNs');
|
|
|
Lib::loadClass('Api_WfsException');
|
|
|
Lib::loadClass('User');
|
|
|
Lib::loadClass('Core_AclHelper');
|
|
|
+Lib::loadClass('ACL');
|
|
|
|
|
|
// TODO: replace every methods using $idZasob to use $fieldName
|
|
|
/* TODO: fetch ACL from acl tables:
|
|
|
@@ -188,6 +189,42 @@ class Core_AclBase {
|
|
|
public function getItems($params = array()) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }// TODO: use ParseOgcQuery
|
|
|
public function getTotal($params = array()) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }// TODO: use ParseOgcQuery
|
|
|
public function getItem($primaryKey, $params = []) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
|
|
|
+
|
|
|
+ public function itemsFetchRefs(&$items) {
|
|
|
+ $DBG = V::get('DBG_DS', 0, $_GET, 'int');
|
|
|
+ $refs = array();// fieldName => namespace
|
|
|
+ foreach ($this->getRealFieldListByIdZasob() as $id => $fieldName) {
|
|
|
+ $fieldType = $this->getXsdFieldType($fieldName);
|
|
|
+ if ('ref:' == substr($fieldType, 0, 4)) $refs[$fieldName] = substr($fieldType, 4);
|
|
|
+ else if ('alias_ref:' == substr($fieldType, 0, 10)) $refs[$fieldName] = substr($fieldType, 10);
|
|
|
+ // if ('ref:' == substr($fieldType, 0, 4)) $refs[$fieldName] = str_replace(':', '/', substr($fieldType, 4));
|
|
|
+ // else if ('alias_ref:' == substr($fieldType, 0, 10)) $refs[$fieldName] = str_replace(':', '/', substr($fieldType, 10));
|
|
|
+ // else if ('ref_uri:' == substr($fieldType, 0, 8)) $refs[$fieldName] = substr($fieldType, 8);
|
|
|
+ }
|
|
|
+ if (empty($refs)) return $items;
|
|
|
+ $pkList = array_keys($items);
|
|
|
+ $sqlPk = array(); foreach ($pkList as $pk) { $sqlPk[] = DB::getPDO()->quote($pk, PDO::PARAM_STR); } $sqlPk = implode(", ", $sqlPk);
|
|
|
+ $refRows = array();// $fieldName => [ pk, ... ]
|
|
|
+ foreach ($refs as $fieldName => $childNs) {
|
|
|
+ $acl = Core_AclHelper::getAclByTypeName($childNs);
|
|
|
+ // TODO: Core_AclBase->fetchRefs($fieldName, $pkList = array());// $refPk[$fieldName] = $this->fetchRefs($fieldName, $pkList);
|
|
|
+ $refTableName = Core_AclHelper::getRefTable($this->getName(), $fieldName);
|
|
|
+ $refRows[$fieldName] = DB::getPDO()->fetchAllByKey("
|
|
|
+ select r.*
|
|
|
+ from `{$refTableName}` r
|
|
|
+ where r.PRIMARY_KEY in({$sqlPk})
|
|
|
+ and r.A_STATUS != 'DELETED'
|
|
|
+ ", $key = 'PRIMARY_KEY');
|
|
|
+ if($DBG>2){echo 'C.'.get_class($this).' L.' . __LINE__ . " getItems loop(\$fieldName:{$fieldName}) \$refTableName:({$refTableName}), \$refRows[$fieldName]";print_r($refRows[$fieldName]);echo"\n";}
|
|
|
+ }
|
|
|
+ foreach ($refRows as $fieldName => $refList) {
|
|
|
+ foreach ($refList as $pk => $ref) {
|
|
|
+ $items[ $pk ][ $fieldName ][] = array('xlink' => "{$refs[$fieldName]}.{$ref['REMOTE_PRIMARY_KEY']}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $items;
|
|
|
+ }
|
|
|
+
|
|
|
public function addItem($todoItem) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
|
|
|
public function updateItem($itemPatch) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
|
|
|
public function getGeomFieldType($fieldName) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
|