1
0

BxTasksMenuSubmenu.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. * @defgroup Tasks Tasks
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. class BxTasksMenuSubmenu extends BxTemplMenuCustom
  11. {
  12. protected $_sModule;
  13. protected $_oModule;
  14. protected $_iProfileId;
  15. public function __construct($aObject, $oTemplate = false)
  16. {
  17. $this->_sModule = 'bx_tasks';
  18. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  19. parent::__construct($aObject, $oTemplate);
  20. $this->_iProfileId = bx_get_logged_profile_id();
  21. }
  22. public function getCodeAPI ()
  23. {
  24. $aResult = parent::getCodeAPI();
  25. $aItems = [];
  26. foreach($aResult['items'] as $aItem)
  27. if(($aData = $aItem['data']['items'] ?? false) && is_array($aData))
  28. $aItems = array_merge($aItems, $aData);
  29. if($aItems)
  30. $aResult['items'] = $aItems;
  31. return $aResult;
  32. }
  33. protected function _getMenuItemUse ($aItem)
  34. {
  35. $CNF = &$this->_oModule->_oConfig->CNF;
  36. $oMenu = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_USE_TOOLS_SUBMENU']);
  37. if(!$this->_bIsApi || !$oMenu)
  38. return false;
  39. return [
  40. 'id' => $aItem['id'],
  41. 'name' => $aItem['name'],
  42. 'display_type' => 'menu',
  43. 'data' => $oMenu->getCodeAPI()
  44. ];
  45. }
  46. protected function _getMenuItemBrowse ($aItem)
  47. {
  48. $CNF = &$this->_oModule->_oConfig->CNF;
  49. $oMenu = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_BROWSE']);
  50. if(!$this->_bIsApi || !$oMenu)
  51. return false;
  52. $oMenu->setProfileId($this->_iProfileId);
  53. return [
  54. 'id' => $aItem['id'],
  55. 'name' => $aItem['name'],
  56. 'display_type' => 'menu',
  57. 'data' => $oMenu->getCodeAPI()
  58. ];
  59. }
  60. protected function _getMenuItemManage ($aItem)
  61. {
  62. $CNF = &$this->_oModule->_oConfig->CNF;
  63. $oMenu = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_MANAGE_TOOLS_SUBMENU']);
  64. if(!$this->_bIsApi || !$oMenu)
  65. return false;
  66. return [
  67. 'id' => $aItem['id'],
  68. 'name' => $aItem['name'],
  69. 'display_type' => 'menu',
  70. 'data' => $oMenu->getCodeAPI()
  71. ];
  72. }
  73. }
  74. /** @} */