BxBaseStudioPermissions.php 2.8 KB

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