BxDolStudioPermissionsActions.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 DolphinStudio Dolphin Studio
  7. * @{
  8. */
  9. bx_import('BxTemplStudioGrid');
  10. bx_import('BxDolStudioTemplate');
  11. bx_import('BxDolStudioPermissionsQuery');
  12. class BxDolStudioPermissionsActions extends BxTemplStudioGrid {
  13. protected $iLevel = 0;
  14. public function __construct ($aOptions, $oTemplate = false) {
  15. parent::__construct ($aOptions, $oTemplate);
  16. $this->oDb = new BxDolStudioPermissionsQuery();
  17. $iLevel = (int)bx_get('level');
  18. if($iLevel > 0)
  19. $this->iLevel = $iLevel;
  20. $this->_aQueryAppend['level'] = $this->iLevel;
  21. }
  22. protected function _isRowDisabled($aRow) {
  23. return $aRow['Active'] == 0;
  24. }
  25. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage) {
  26. if(empty($this->iLevel))
  27. return array();
  28. $sModule = '';
  29. if(strpos($sFilter, $this->sParamsDivider) !== false)
  30. list($sModule, $sFilter) = explode($this->sParamsDivider, $sFilter);
  31. if($sModule != '')
  32. $this->_aOptions['source'] .= $this->oDb->prepare(" AND `Module`=?", $sModule);
  33. $this->_aOptions['source'] .= $this->oDb->prepare(" AND (`DisabledForLevels`='0' OR `DisabledForLevels`&?=0)", pow(2, ($this->iLevel - 1)));
  34. $aActions = parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  35. $aActionsActive = array();
  36. $iActionsActive = $this->oDb->getActions(array('type' => 'by_level_id_key_id', 'value' => $this->iLevel), $aActionsActive);
  37. foreach($aActions as $iKey => $aAction)
  38. $aActions[$iKey]['Active'] = array_key_exists($aAction['ID'], $aActionsActive) ? 1 : 0;
  39. return $aActions;
  40. }
  41. }
  42. /** @} */