| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- Lib::loadClass('Api_WfsNs');
- Lib::loadClass('Api_WfsException');
- Lib::loadClass('User');
- Lib::loadClass('Core_AclHelper');
- class Core_AclSimpleSchemaBase extends Core_AclBase {
- public $_simpleSchema = array();
- public $_xsdTypes = null;
- public function getSimpleSchema() { return $this->_simpleSchema; }
- public function getNamespace() { return 'default_objects/' . $this->getName(); }
- public function getSourceName() { return 'default_objects'; }
- public function init($force = false) {}
- public function isInitialized() { return true; }
- public function getFieldListByIdZasob() { return $this->getRealFieldListByIdZasob(); }
- public function getVisibleFieldListByIdZasob() { return $this->getRealFieldListByIdZasob(); }
- public function getVirtualFieldListByIdZasob() { return array(); }
- public function getRealFieldListByIdZasob($force = false) {
- $cols = array();
- foreach ($this->getFields() as $idField => $field) {
- $cols[$idField] = $field['name'];
- }
- return $cols;
- }
- public function getXsdTypes() {
- if (null !== $this->_xsdTypes) return $this->_xsdTypes;
- $this->_xsdTypes = array();
- $generatedIdZasob = 10000;
- foreach ($this->_simpleSchema as $key => $value) {
- if ('@' == substr($key, 0, 1)) continue;// skip attributes
- if (is_array($value)) {
- $fieldName = $key;
- $field = [ 'name' => $fieldName, 'perms' => 'R', 'idZasob' => $generatedIdZasob ];
- if (!empty($value['@baseTypeName'])) $field['xsdType'] = "alias_ref:{$value['@baseTypeName']}";
- else if (!empty($value['@ref'])) $field['xsdType'] = "alias_ref:{$value['@ref']}";
- else throw new Exception("StorageAcl - field type not defined '{$key}'");
- if (!empty($value['@maxOccurs'])) $field['maxOccurs'] = $value['@maxOccurs'];
- $this->_xsdTypes[$fieldName] = $field;
- } else if (is_scalar($value)) {
- $fieldName = $key;
- $field = [ 'name' => $fieldName, 'perms' => 'R', 'idZasob' => $generatedIdZasob ];
- $field['xsdType'] = $value;
- $this->_xsdTypes[$fieldName] = $field;
- } else {
- throw new Exception("StorageAcl - TODO: Unimplemented value type in simpleSchema: " . json_encode($value));
- }
- $generatedIdZasob++;
- }
- return $this->_xsdTypes;
- }
- public function getFields() {// @returns array - $this->_fields
- $fieldsById = array();
- foreach ($this->getXsdTypes() as $fieldName => $field) {
- $field['name'] = $fieldName;
- $fieldsById[ $field['idZasob'] ] = $field;
- }
- return $fieldsById;
- }
- public function getFieldType($fieldName) {
- foreach ($this->getFields() as $field) {
- if ($fieldName == $field['name']) return $field;
- }
- return null;
- }
- // TODO: replace legacy functions: isAllowed, hasFieldPerm, getFieldIdByName
- public function canCreateField($fieldName) {
- return false;// TODO: perms from Procesy
- }
- public function canReadField($fieldName) {
- return true;// TODO: perms from Procesy
- }
- public function canReadObjectField($fieldName, $record) {
- return true;// TODO: perms from Procesy
- }
- public function canWriteField($fieldName) {
- return false;// TODO: perms from Procesy
- }
- public function canWriteObjectField($fieldName, $record) {
- return false;// TODO: perms from Procesy
- }
- public function getTotal($params = array()) {// TODO: use ParseOgcQuery
- throw new Exception("Unimplemented - TODO: F." . __FUNCTION__);
- }
- public function getItem($primaryKey) {
- throw new Exception("Unimplemented - TODO: F." . __FUNCTION__);
- }
- public function getItems($params = array()) {// TODO: use ParseOgcQuery
- throw new Exception("Unimplemented - TODO: F." . __FUNCTION__);
- }
- public function fetchItemRef(&$items) {
- throw new Exception("Unimplemented - TODO: F." . __FUNCTION__);
- }
- public function addItem($itemTodo) {
- throw new Exception("Unimplemented - TODO: F." . __FUNCTION__);
- // return $this->parentAcl->addItem($itemTodo);
- }
- public function updateItem($itemPatch) {
- throw new Exception("Unimplemented - TODO: F." . __FUNCTION__);
- // return $this->parentAcl->updateItem($itemPatch);
- }
- public function getGeomFieldType($fieldName) { return null; }
- public function getPrimaryKeyField() { return 'ID'; }
- public function getID() { return 0; }
- public function getAttributesFromZasoby() { return array(); }
- public function isEnumerationField($fieldName) { return false; }
- public function getEnumerations($fieldName) { return null; }
- public function getXsdFieldType($fieldName) {
- $xsdTypes = $this->getXsdTypes();
- if (empty($xsdTypes[$fieldName])) throw new Exception("Field '{$fieldName}' not exists");
- return $xsdTypes[$fieldName]['xsdType'];
- }
- public function isGeomField($fldName) {
- if ('File' == $fieldName) return false;
- if ('AccessGroupRead' == $fieldName) return false;
- if ('AccessGroupWrite' == $fieldName) return false;
- if ('AccessOwner' == $fieldName) return false;
- // if ('NestedObjectTest' == $fieldName) return false;
- // return $this->parentAcl->isGeomField($fldName);
- }
- }
|