| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- Lib::loadClass('RouteBase');
- /*
- ## Url Actions (to replace Typespecial's):
- - new Zasob type: 'URL_ACTION'
- ## Config in Zasoby tree (TODO: upload from gui xml file):
- [100] - TYPESPECIALS
- [110] - URL_ACTION ProjektyKosztyWstepnychRobot
- [111] - PARAM_IN ID_PROJECT
- [200] - TABELA IN7_MK_BAZA_DYSTRYBUCJI Projekty
- [210] - KOMORKA ID
- [220] - (ALIAS to [110]) URL_ACTION action name/label
- [221] - (ALIAS to [210]) PARAM_IN ID_PROJECT
- class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {
- public function defaultAction() {
- $args = array();
- $args['ID_PROJECT'] = V::get('ID_PROJECT', '', $_REQUEST);// [111]
- }
- }
- ## Process - Create:
- - 1. define action name in Zasoby tree (URL_ACTION) and expected args (PARAM_IN) - `ActionDefinition`
- - 2. create action alias inside TABLE - `ActionInstance`
- - 3. set perms for `ActionInstance`
- ## Process - Install ActionDefinitio's:
- - class UrlActionBase :: installZasobAction
- - create required Zasoby in Zasob Tree if not exists
- */
- class Route_UrlAction extends RouteBase {// TODO: UrlActionBase
- public function handleAuth() {
- if (!User::logged()) {
- throw new HttpException('Unauthorized', 401);
- }
- }
- public function defaultAction() {
- SE_Layout::gora();
- ?>
- <div class="container">
- <h1>UrlActions system</h1>
- ...
- </div>
- <?php
- SE_Layout::dol();
- }
- public function getArgsList() {
- $args = array();
- $args[] = 'ID_PROJECT';
- return $args;
- }
- public function reinstallAction() {
- $jsonData = new stdClass();
- $jsonData->type = 'success';
- $jsonData->msg = 'Gotowe';
- try {
- $this->reinstall();
- } catch (Exception $e) {
- $jsonData->type = 'danger';
- $jsonData->msg = $e->getMessage();
- }
- echo json_encode($jsonData);
- }
- public function runAction() {
- $jsonData = new stdClass();
- $jsonData->type = 'success';
- $jsonData->msg = 'Gotowe';
- try {
- $idAction = V::get('_idAction', 0, $_REQUEST, 'int');
- if ($idAction > 0) {
- $this->runActionById($idAction);
- }
- } catch (Exception $e) {
- $jsonData->type = 'danger';
- $jsonData->msg = $e->getMessage();
- }
- echo json_encode($jsonData);
- }
- public function reinstall() {
- $sqlList = array();
- //$sqlList['RemoveTable'] = "DROP TABLE IF EXISTS `CRM_UI_MSGS`";
- $pdo = DB::getPDO();
- foreach ($sqlList as $sqlName => $sql) {
- $pdo->exec($sql);
- }
- }
- public function runActionById($id) {
- $msgRow = $this->getActiveMessage($id);
- $execNotes = '';
- if (!empty($msgRow->app_className)) {
- $route = Router::getRoute($msgRow->app_className);
- $route->runByMessageFromMsgsSystem($msgRow->msg, $execNotes);
- }
- $this->forceFinishMessage($id, $execNotes);
- }
- }
|