UrlAction.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. Lib::loadClass('RouteBase');
  3. /*
  4. ## Url Actions (to replace Typespecial's):
  5. - new Zasob type: 'URL_ACTION'
  6. ## Config in Zasoby tree (TODO: upload from gui xml file or php):
  7. [100] - TYPESPECIALS
  8. [110] - URL_ACTION ProjektyKosztyWstepnychRobot
  9. [111] - PARAM_IN ID_PROJECT
  10. [200] - TABELA IN7_MK_BAZA_DYSTRYBUCJI Projekty
  11. [210] - KOMORKA ID
  12. [220] - (ALIAS to [110]) URL_ACTION action name/label
  13. [221] - (ALIAS to [210]) PARAM_IN ID_PROJECT
  14. class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {
  15. public function defaultAction() {
  16. $args = array();
  17. $args['ID_PROJECT'] = V::get('ID_PROJECT', '', $_REQUEST);// [111]
  18. }
  19. }
  20. ## Process - Create:
  21. - 1. define action name in Zasoby tree (URL_ACTION) and expected args (PARAM_IN) - `ActionDefinition`
  22. - 2. create action alias inside TABLE - `ActionInstance`
  23. - 3. set perms for `ActionInstance`
  24. ## Process - Install ActionDefinitio's:
  25. - class UrlActionBase :: installZasobAction
  26. - create required Zasoby in Zasob Tree if not exists
  27. */
  28. class Route_UrlAction extends RouteBase {// TODO: UrlActionBase
  29. public function handleAuth() {
  30. if (!User::logged()) {
  31. throw new HttpException('Unauthorized', 401);
  32. }
  33. }
  34. public function defaultAction() {
  35. SE_Layout::gora();
  36. ?>
  37. <div class="container">
  38. <h1>UrlActions system</h1>
  39. ...
  40. </div>
  41. <?php
  42. SE_Layout::dol();
  43. }
  44. public function getArgsList() {
  45. $args = array();
  46. return $args;
  47. }
  48. public function reinstallAction() {
  49. $jsonData = new stdClass();
  50. $jsonData->type = 'success';
  51. $jsonData->msg = 'Gotowe';
  52. try {
  53. $this->reinstall();
  54. } catch (Exception $e) {
  55. $jsonData->type = 'danger';
  56. $jsonData->msg = $e->getMessage();
  57. }
  58. echo json_encode($jsonData);
  59. }
  60. public function reinstall() {
  61. $sqlList = array();
  62. // alter table enum add URL_ACTION
  63. //$sqlList['RemoveTable'] = "DROP TABLE IF EXISTS `CRM_UI_MSGS`";
  64. $pdo = DB::getPDO();
  65. foreach ($sqlList as $sqlName => $sql) {
  66. $pdo->exec($sql);
  67. }
  68. }
  69. }