BxBaseStudioPermissions.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 UnaView UNA Studio Representation classes
  7. * @ingroup UnaStudio
  8. * @{
  9. */
  10. class BxBaseStudioPermissions extends BxDolStudioPermissions
  11. {
  12. protected $sSubpageUrl;
  13. function __construct($sPage = '')
  14. {
  15. parent::__construct($sPage);
  16. $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'builder_permissions.php?page=';
  17. }
  18. function getPageCss()
  19. {
  20. return array_merge(parent::getPageCss(), array('forms.css', 'paginate.css', 'permissions.css'));
  21. }
  22. function getPageJs()
  23. {
  24. return array_merge(parent::getPageJs(), array('permissions.js'));
  25. }
  26. function getPageJsObject()
  27. {
  28. return 'oBxDolStudioPermissions';
  29. }
  30. function getPageMenu($aMenu = array(), $aMarkers = array())
  31. {
  32. $sJsObject = $this->getPageJsObject();
  33. $aMenu = array();
  34. $aMenuItems = array(
  35. BX_DOL_STUDIO_PRM_TYPE_LEVELS => array('icon' => 'sliders-h'),
  36. BX_DOL_STUDIO_PRM_TYPE_ACTIONS => array('icon' => 'exchange-alt')
  37. );
  38. foreach($aMenuItems as $sMenuItem => $aItem)
  39. $aMenu[] = array(
  40. 'name' => $sMenuItem,
  41. 'icon' => $aItem['icon'],
  42. 'link' => $this->sSubpageUrl . $sMenuItem,
  43. 'title' => _t('_adm_lmi_cpt_' . $sMenuItem),
  44. 'selected' => $sMenuItem == $this->sPage
  45. );
  46. return parent::getPageMenu($aMenu);
  47. }
  48. function getPageCode($bHidden = false)
  49. {
  50. $sMethod = 'get' . ucfirst($this->sPage);
  51. if(!method_exists($this, $sMethod))
  52. return '';
  53. return $this->$sMethod();
  54. }
  55. protected function getLevels()
  56. {
  57. return $this->getGrid('sys_studio_acl');
  58. }
  59. protected function getActions()
  60. {
  61. return $this->getGrid('sys_studio_acl_actions');
  62. }
  63. protected function getPrices()
  64. {
  65. return $this->getGrid('sys_studio_acl_prices');
  66. }
  67. protected function getGrid($sObjectName)
  68. {
  69. $oGrid = BxDolGrid::getObjectInstance($sObjectName);
  70. if(!$oGrid)
  71. return '';
  72. return BxDolStudioTemplate::getInstance()->parseHtmlByName('permissions.html', array(
  73. 'js_object' => $this->getPageJsObject(),
  74. 'content' => $this->getBlockCode(array(
  75. 'items' => $oGrid->getCode()
  76. ))
  77. ));
  78. }
  79. }
  80. /** @} */