BxDolStudioApiConfigs.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaStudio UNA Studio
  7. * @{
  8. */
  9. class BxDolStudioApiConfigs extends BxTemplStudioGrid
  10. {
  11. public function __construct ($aOptions, $oTemplate = false)
  12. {
  13. parent::__construct ($aOptions, $oTemplate);
  14. }
  15. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  16. {
  17. $this->_aOptions['source'] .= " AND `enabled`<>0 ";
  18. return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  19. }
  20. protected function _getQueriesPagesConfigApi($sModule = '')
  21. {
  22. $sResult = '';
  23. $sWhere = $sModule ? $this->oDb->prepareAsString(" AND `module`=?", $sModule) : "";
  24. $aPages = $this->oDb->getAll("SELECT `object`, `config_api` FROM `sys_objects_page` WHERE `config_api` <> ''" . $sWhere . " ORDER BY `id` ASC");
  25. if($aPages && is_array($aPages)) {
  26. $sResult = "\n\n-- PAGES:\n";
  27. foreach($aPages as $aPage)
  28. $sResult .= $this->oDb->prepareAsString("UPDATE `sys_objects_page` SET `config_api`=? WHERE `object`=?;\n", $aPage['config_api'], $aPage['object']);
  29. }
  30. $aBlocks = $this->oDb->getAll("SELECT `object`, `module`, `title_system`, `title`, `config_api` FROM `sys_pages_blocks` WHERE `config_api` <> ''" . $sWhere . " ORDER BY `id` ASC");
  31. if($aBlocks && is_array($aBlocks)) {
  32. $sResult .= "\n\n-- PAGE BLOCKS:\n";
  33. foreach($aBlocks as $aBlock)
  34. $sResult .= $this->oDb->prepareAsString("UPDATE `sys_pages_blocks` SET `config_api`=? WHERE `object`=? AND `module`=? AND `title_system`=? AND `title`=?;\n", $aBlock['config_api'], $aBlock['object'], $aBlock['module'], $aBlock['title_system'], $aBlock['title']);
  35. }
  36. return $sResult;
  37. }
  38. protected function _getQueriesPagesActiveApi($sModule = '')
  39. {
  40. $sResult = '';
  41. $sWhere = $sModule ? $this->oDb->prepareAsString(" AND `module`=?", $sModule) : "";
  42. $aBlocks = $this->oDb->getAll("SELECT `object`, `module`, `title_system`, `title`, `active_api` FROM `sys_pages_blocks` WHERE `active_api` <> '0'" . $sWhere . " ORDER BY `id` ASC");
  43. if($aBlocks && is_array($aBlocks)) {
  44. $sResult = "\n\n-- PAGE BLOCKS:\n";
  45. foreach($aBlocks as $aBlock)
  46. $sResult .= $this->oDb->prepareAsString("UPDATE `sys_pages_blocks` SET `active_api`=? WHERE `object`=? AND `module`=? AND `title_system`=? AND `title`=?;\n", $aBlock['active_api'], $aBlock['object'], $aBlock['module'], $aBlock['title_system'], $aBlock['title']);
  47. }
  48. return $sResult;
  49. }
  50. protected function _getQueriesMenusConfigApi($sModule = '')
  51. {
  52. $sResult = '';
  53. $sWhere = $sModule ? $this->oDb->prepareAsString(" AND `module`=?", $sModule) : "";
  54. $aMenus = $this->oDb->getAll("SELECT `object`, `config_api` FROM `sys_objects_menu` WHERE `config_api` <> ''" . $sWhere . " ORDER BY `id` ASC");
  55. if($aMenus && is_array($aMenus)) {
  56. $sResult = "\n\n-- MENUS:\n";
  57. foreach($aMenus as $aMenu)
  58. $sResult .= $this->oDb->prepareAsString("UPDATE `sys_objects_menu` SET `config_api`=? WHERE `object`=?;\n", $aMenu['config_api'], $aMenu['object']);
  59. }
  60. $aItems = $this->oDb->getAll("SELECT `set_name`, `module`, `name`, `config_api` FROM `sys_menu_items` WHERE `config_api` <> ''" . $sWhere . " ORDER BY `id` ASC");
  61. if($aItems && is_array($aItems)) {
  62. $sResult .= "\n\n-- MENU ITEMS:\n";
  63. foreach($aItems as $aItem)
  64. $sResult .= $this->oDb->prepareAsString("UPDATE `sys_menu_items` SET `config_api`=? WHERE `set_name`=? AND `module`=? AND `name`=?;\n", $aItem['config_api'], $aItem['set_name'], $aItem['module'], $aItem['name']);
  65. }
  66. return $sResult;
  67. }
  68. protected function _getQueriesMenusActiveApi($sModule = '')
  69. {
  70. $sResult = '';
  71. $sWhere = $sModule ? $this->oDb->prepareAsString(" AND `module`=?", $sModule) : "";
  72. $aItems = $this->oDb->getAll("SELECT `set_name`, `module`, `name`, `active_api` FROM `sys_menu_items` WHERE `active_api` <> '0'" . $sWhere . " ORDER BY `id` ASC");
  73. if($aItems && is_array($aItems)) {
  74. $sResult = "\n\n-- MENU ITEMS:\n";
  75. foreach($aItems as $aItem)
  76. $sResult .= $this->oDb->prepareAsString("UPDATE `sys_menu_items` SET `active_api`=? WHERE `set_name`=? AND `module`=? AND `name`=?;\n", $aItem['active_api'], $aItem['set_name'], $aItem['module'], $aItem['name']);
  77. }
  78. return $sResult;
  79. }
  80. }
  81. /** @} */