80 lines
2.6 KiB
PHP
80 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace BRSystems\Core\App\MODULE_NAME_SAMPLE;
|
|
|
|
use BRSystems\Core\Library\cJSON\cJSON;
|
|
use BRSystems\Core\App\MODULE_NAME_SAMPLE\inc\MODULE_NAME_SAMPLEController;
|
|
|
|
/**
|
|
* MODULE_NAME_SAMPLE
|
|
*
|
|
* @category MODULE_NAME_SAMPLE
|
|
* @author Aivars Žukovskis <mareks.keiss@brsystems.lv>
|
|
* @since Version 1.0
|
|
*/
|
|
class MODULE_NAME_SAMPLE
|
|
{
|
|
public $DIR;
|
|
public $uriData;
|
|
public $controller;
|
|
|
|
/**
|
|
* Class constructor
|
|
*/
|
|
public function __construct($uriData) {
|
|
|
|
$this->uriData = $uriData;
|
|
$this->DIR = __DIR__ ? __DIR__ : dirname(__FILE__);
|
|
$this->controller = new MODULE_NAME_SAMPLEController($this->uriData, $this->DIR, basename($this->DIR));
|
|
|
|
}
|
|
|
|
/**
|
|
* Default function to run
|
|
* Skip if other callback defined
|
|
*/
|
|
public function run() {
|
|
|
|
$action = getV('action');
|
|
if(!$action)
|
|
$action = getV('a');
|
|
|
|
if($action){
|
|
switch ($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':
|
|
if($this->controller->oUser->chkPermission('SAMPLE_MODULE_EDIT'))
|
|
cJSON::sendOk($this->controller->editCmsTableRecord(getV('id')));
|
|
break;
|
|
case 'selfSave':
|
|
if(getV('id')){
|
|
if($this->controller->oUser->chkPermission('SAMPLE_MODULE_EDIT'))
|
|
cJSON::sendOk($this->controller->saveRecordData(getV('id'), getP('fields')));
|
|
}else{
|
|
if($this->controller->oUser->chkPermission('SAMPLE_MODULE_ADD_NEW'))
|
|
cJSON::sendOk($this->controller->saveRecordData(getV('id'), getP('fields')));
|
|
}
|
|
break;
|
|
case 'deleteRecords':
|
|
if($this->controller->oUser->chkPermission('SAMPLE_MODULE_DELETE'))
|
|
cJSON::sendOk($this->controller->delete(getP('fields')));
|
|
break;
|
|
case 'changeRecordsStatus':
|
|
if($this->controller->oUser->chkPermission('SAMPLE_MODULE_EDIT'))
|
|
cJSON::sendOk($this->controller->changeEnumFields(getP('baseField'), getP('fields')));
|
|
break;
|
|
default:
|
|
$this->controller->run();
|
|
break;
|
|
}
|
|
}else{
|
|
$this->controller->run();
|
|
}
|
|
}
|
|
}
|