|
|
@@ -1419,6 +1419,9 @@ class TableAcl extends Core_AclBase {
|
|
|
}
|
|
|
|
|
|
public function getHistItems($id) {
|
|
|
+ if ($this->_schemaClass && method_exists($this->_schemaClass, 'hasGetHistItems') && $this->_schemaClass->hasGetHistItems()) {
|
|
|
+ return $this->_schemaClass->getHistItems($id);
|
|
|
+ }
|
|
|
$ds = $this->getDataSource();
|
|
|
return $ds->getHistItems($id);
|
|
|
}
|
|
|
@@ -1490,21 +1493,14 @@ class TableAcl extends Core_AclBase {
|
|
|
return 0;// nothing to change
|
|
|
}
|
|
|
|
|
|
- $ds = $this->getDataSource();
|
|
|
- $primaryKeyField = $ds->getPrimaryKeyField();
|
|
|
- if (empty($itemPatch[$primaryKeyField])) {
|
|
|
- throw new HttpException("Item Primary Key not set!", 400);
|
|
|
- }
|
|
|
+ $primaryKeyField = $this->getPrimaryKeyField();
|
|
|
+ if (empty($itemPatch[$primaryKeyField])) throw new HttpException("Item Primary Key not set!", 400);
|
|
|
|
|
|
$primaryKey = $itemPatch[$primaryKeyField];
|
|
|
$itemOld = $this->getItem($primaryKey);
|
|
|
- if (!$itemOld) {
|
|
|
- throw new HttpException("Item not exists!", 404);
|
|
|
- }
|
|
|
+ if (!$itemOld) throw new HttpException("Item not exists!", 404);
|
|
|
|
|
|
- if (!$this->canWriteRecord($itemOld) && !$this->hasPermSuperWrite()) {
|
|
|
- throw new HttpException("Brak dostępu do rekordu", 403);
|
|
|
- }
|
|
|
+ if (!$this->canWriteRecord($itemOld) && !$this->hasPermSuperWrite()) throw new HttpException("Brak dostępu do rekordu", 403);
|
|
|
|
|
|
// $itemPatch from user input to $itemPatchChecked
|
|
|
$itemPatchChecked = array();
|
|
|
@@ -1536,7 +1532,12 @@ class TableAcl extends Core_AclBase {
|
|
|
}
|
|
|
$itemPatchChecked[$primaryKeyField] = $primaryKey;
|
|
|
|
|
|
- $affected = $ds->updateItem($itemPatchChecked);
|
|
|
+ if ($this->_schemaClass && method_exists($this->_schemaClass, 'hasUpdateItem') && $this->_schemaClass->hasUpdateItem()) {
|
|
|
+ $affected = $this->_schemaClass->updateItem($itemPatchChecked);
|
|
|
+ } else {
|
|
|
+ $ds = $this->getDataSource();
|
|
|
+ $affected = $ds->updateItem($itemPatchChecked);
|
|
|
+ }
|
|
|
|
|
|
return $affected;
|
|
|
}
|
|
|
@@ -1595,7 +1596,10 @@ class TableAcl extends Core_AclBase {
|
|
|
}
|
|
|
|
|
|
public function getPrimaryKeyField() {
|
|
|
- // TODO: if ($this->_schemaClass) return $this->_schemaClass->getPrimaryKeyField();
|
|
|
+ if ($this->_schemaClass) {
|
|
|
+ $pkField = $this->_schemaClass->getPrimaryKeyField();
|
|
|
+ if ($pkField) return $pkField;
|
|
|
+ }
|
|
|
$ds = $this->getDataSource();
|
|
|
return $ds->getPrimaryKeyField();
|
|
|
}
|