BxDolStudioRolesActions.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaStudio UNA Studio
  7. * @{
  8. */
  9. class BxDolStudioRolesActions extends BxTemplStudioGrid
  10. {
  11. protected $iRole = 0;
  12. public function __construct ($aOptions, $oTemplate = false)
  13. {
  14. parent::__construct ($aOptions, $oTemplate);
  15. $this->oDb = BxDolStudioRolesQuery::getInstance();
  16. $iLevel = (int)bx_get('role');
  17. if($iLevel > 0)
  18. $this->iRole = $iLevel;
  19. $this->_aQueryAppend['role'] = $this->iRole;
  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->iRole))
  28. return array();
  29. $aActions = parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  30. $aActionsActive = $this->oDb->getActions(array('type' => 'by_role_id_key_id', 'role_id' => $this->iRole));
  31. foreach($aActions as $iKey => $aAction)
  32. $aActions[$iKey]['active'] = array_key_exists($aAction['id'], $aActionsActive) ? 1 : 0;
  33. return $aActions;
  34. }
  35. }
  36. /** @} */