AccessOwnerStorageAcl.php 3.5 KB

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