AccessOwnerStorageAcl.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. Lib::loadClass('Core_AclBase');
  3. Lib::loadClass('ParseOgcFilter');
  4. class Schema_AccessOwnerStorageAcl extends Core_AclBase {
  5. public function getSourceName() { return 'objects'; }
  6. public function init($force = false) {}
  7. public function isInitialized() { return true; }
  8. public function getName() { return 'AccessOwner'; }
  9. public function getRootTableName() { return 'ADMIN_USERS'; }// TODO: turn off - use getName for generating ref's
  10. public function getFieldListByIdZasob() { return $this->getRealFieldListByIdZasob(); }
  11. public function getVirtualFieldListByIdZasob() { return array(); }
  12. public function getRealFieldListByIdZasob($force = false) {
  13. $cols[100000] = 'id';// ADMIN_USERS.ID
  14. $cols[100001] = 'login';// ADMIN_USERS.ADM_ACCOUNT
  15. $cols[100002] = 'name';// ADMIN_USERS.ADM_NAME
  16. return $cols;
  17. }
  18. public function getFields() { return array_values($this->getRealFieldListByIdZasob()); }
  19. public function getFieldType($fieldName) { return null; }
  20. // TODO: replace legacy functions: isAllowed, hasFieldPerm, getFieldIdByName
  21. public function canCreateField($fieldName) { return false; }
  22. public function canReadField($fieldName) { return true; }
  23. public function canReadObjectField($fieldName, $record) {return true; }
  24. public function canWriteField($fieldName) { return false; }
  25. public function canWriteObjectField($fieldName, $record) { return false; }
  26. public function getItems($params = array()) {
  27. $DBG = V::get('DBG_DS', 0, $_GET, 'int');
  28. if($DBG>2){echo 'C.'.get_class($this).' L.' . __LINE__ . " getItems \$params:";print_r($params);echo "\n";}
  29. $items = DB::getPDO()->fetchAllByKey("
  30. select u.ID as id, u.ADM_ACCOUNT as login, u.ADM_NAME as name
  31. from ADMIN_USERS u
  32. where u.A_STATUS = 'NORMAL'
  33. and u.ADM_TECH_WORKER != 'NO'
  34. ", $key = 'id');
  35. if ($pk = V::get('primaryKey', '', $params, 'int')) {// [primaryKey] => 2948
  36. if (!array_key_exists($pk, $items)) return array();
  37. $items = array($pk => $items[$pk]);
  38. }
  39. if (!empty($params['ogc:Filter'])) {
  40. $parser = new ParseOgcFilter();
  41. $parser->loadOgcFilter($params['ogc:Filter']);
  42. $queryWhereBuilder = $parser->convertToSqlQueryWhereBuilder();
  43. DBG::_('DBG_DS', '>2', "ogc:Filter \$queryWhereBuilder", $queryWhereBuilder, __CLASS__, __FUNCTION__, __LINE__);
  44. if($DBG>2){echo 'C.'.get_class($this).' L.' . __LINE__ . " getItems \$items:";print_r($items);echo "\n";}
  45. $items = array_filter($items, array($queryWhereBuilder, 'filterRawArray'));
  46. }
  47. if($DBG>2){echo 'C.'.get_class($this).' L.' . __LINE__ . " getItems \$items:";print_r($items);echo "\n";}
  48. return $items;
  49. }
  50. public function addItem($itemTodo) { throw new Exception("Insert not allowed"); }
  51. public function updateItem($itemPatch) { throw new Exception("Update not allowed"); }
  52. public function getGeomFieldType($fieldName) { return null; }
  53. public function getPrimaryKeyField() { return 'id'; }
  54. public function getID() { return 0; }
  55. public function getAttributesFromZasoby() { return array(); }
  56. public function isEnumerationField($fieldName) { return false; }
  57. public function getEnumerations($fieldName) { return null; }
  58. public function getXsdFieldType($fieldName) {
  59. if ('id' == $fieldName) return 'xsd:string';
  60. if ('login' == $fieldName) return 'xsd:string';
  61. if ('name' == $fieldName) return 'xsd:string';
  62. }
  63. public function isGeomField($fldName) { return false; }
  64. }