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