* @since Version 3.0 */ class cmsDelivery { public $controller; public function __construct($uriData) { $DIR = __DIR__ ?: dirname(__FILE__); $this->controller = new cmsDeliveryController($uriData, $DIR, basename($DIR)); } public function run() { switch (getV('action')) { case 'edit': $this->controller->run(true); break; case 'filter_table': cJSON::sendok($this->controller->createCmsTable(getP('page'), getP('filter'), getP('headers'))); break; case 'selfLoad': cJSON::sendok($this->controller->editCmsTableRecord(getV('id'))); break; case 'selfSave': if (getV('id')) { if ($this->controller->oUser->chkPermission('CMS_APP_DELIVERY_EDIT', false, false)) { cJSON::sendok($this->controller->saveRecordData(getV('id'), getP('fields'))); } cJSON::senderror(['data' => $this->controller->gM("No access rights to edit")]); } else { if ($this->controller->oUser->chkPermission('CMS_APP_DELIVERY_ADD_NEW', false, false)) { cJSON::sendok($this->controller->saveRecordData(getV('id'), getP('fields'))); } cJSON::senderror(['data' => $this->controller->gM("No access rights to save new")]); } break; case 'deleteRecords': if ($this->controller->oUser->chkPermission('CMS_APP_DELIVERY_DELETE')) { cJSON::sendok($this->controller->delete(getP('fields'))); } break; case 'changeRecordsStatus': if ($this->controller->oUser->chkPermission('CMS_APP_DELIVERY_EDIT')) { cJSON::sendok($this->controller->changeEnumFields(getP('baseField'), getP('fields'))); } break; default: $this->controller->run(); break; } } }