BxBaseStudioPermissions.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinView Dolphin Studio Representation classes
  7. * @ingroup DolphinStudio
  8. * @{
  9. */
  10. bx_import('BxDolStudioPermissions');
  11. class BxBaseStudioPermissions extends BxDolStudioPermissions
  12. {
  13. protected $sSubpageUrl;
  14. function __construct($sPage = '')
  15. {
  16. parent::__construct($sPage);
  17. $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'builder_permissions.php?page=';
  18. }
  19. function getPageCss()
  20. {
  21. return array_merge(parent::getPageCss(), array('forms.css', 'paginate.css', 'permissions.css'));
  22. }
  23. function getPageJs()
  24. {
  25. return array_merge(parent::getPageJs(), array('permissions.js'));
  26. }
  27. function getPageJsObject()
  28. {
  29. return 'oBxDolStudioPermissions';
  30. }
  31. function getPageMenu($aMenu = array(), $aMarkers = array())
  32. {
  33. $sJsObject = $this->getPageJsObject();
  34. $aMenu = array();
  35. $aMenuItems = array(
  36. BX_DOL_STUDIO_PRM_TYPE_LEVELS => array('icon' => 'sliders'),
  37. BX_DOL_STUDIO_PRM_TYPE_ACTIONS => array('icon' => 'exchange')
  38. );
  39. foreach($aMenuItems as $sMenuItem => $aItem)
  40. $aMenu[] = array(
  41. 'name' => $sMenuItem,
  42. 'icon' => $aItem['icon'],
  43. 'link' => $this->sSubpageUrl . $sMenuItem,
  44. 'title' => _t('_adm_lmi_cpt_' . $sMenuItem),
  45. 'selected' => $sMenuItem == $this->sPage
  46. );
  47. return parent::getPageMenu($aMenu);
  48. }
  49. function getPageCode($bHidden = false)
  50. {
  51. $sMethod = 'get' . ucfirst($this->sPage);
  52. if(!method_exists($this, $sMethod))
  53. return '';
  54. return $this->$sMethod();
  55. }
  56. protected function getLevels()
  57. {
  58. return $this->getGrid('sys_studio_acl');
  59. }
  60. protected function getActions()
  61. {
  62. return $this->getGrid('sys_studio_acl_actions');
  63. }
  64. protected function getPrices()
  65. {
  66. return $this->getGrid('sys_studio_acl_prices');
  67. }
  68. protected function getGrid($sObjectName)
  69. {
  70. $oTemplate = BxDolStudioTemplate::getInstance();
  71. bx_import('BxDolGrid');
  72. $oGrid = BxDolGrid::getObjectInstance($sObjectName);
  73. if(!$oGrid)
  74. return '';
  75. $aTmplVars = array(
  76. 'js_object' => $this->getPageJsObject(),
  77. 'bx_repeat:blocks' => array(
  78. array(
  79. 'caption' => '',
  80. 'panel_top' => '',
  81. 'items' => $oGrid->getCode(),
  82. 'panel_bottom' => ''
  83. )
  84. )
  85. );
  86. return $oTemplate->parseHtmlByName('permissions.html', $aTmplVars);
  87. }
  88. }
  89. /** @} */