BxDolStudioPermissionsActions.php 1.9 KB

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