BxDolStudioPermissionsActions.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  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. defined('BX_DOL') or die('hack attempt');
  10. bx_import('BxTemplStudioGrid');
  11. bx_import('BxDolStudioTemplate');
  12. bx_import('BxDolStudioPermissionsQuery');
  13. class BxDolStudioPermissionsActions extends BxTemplStudioGrid {
  14. protected $iLevel = 0;
  15. public function __construct ($aOptions, $oTemplate = false) {
  16. parent::__construct ($aOptions, $oTemplate);
  17. $this->oDb = new BxDolStudioPermissionsQuery();
  18. $iLevel = (int)bx_get('level');
  19. if($iLevel > 0)
  20. $this->iLevel = $iLevel;
  21. $this->_aQueryAppend['level'] = $this->iLevel;
  22. }
  23. protected function _isRowDisabled($aRow) {
  24. return $aRow['Active'] == 0;
  25. }
  26. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage) {
  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->prepare(" AND `Module`=?", $sModule);
  34. $this->_aOptions['source'] .= $this->oDb->prepare(" 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. /** @} */