BxDolStudioRolesLevels.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. define('BX_DOL_STUDIO_ROLES_ROLE_ID_INT_MAX', round(log(BX_DOL_INT_MAX, 2)));
  10. class BxDolStudioRolesLevels extends BxTemplStudioGrid
  11. {
  12. protected $aNonDeletable;
  13. public function __construct ($aOptions, $oTemplate = false)
  14. {
  15. parent::__construct ($aOptions, $oTemplate);
  16. $this->oDb = BxDolStudioRolesQuery::getInstance();
  17. $this->aNonDeletable = array(
  18. BX_DOL_STUDIO_ROLE_MASTER,
  19. BX_DOL_STUDIO_ROLE_OPERATOR
  20. );
  21. }
  22. protected function _delete($mixedId)
  23. {
  24. $iId = (int)$mixedId;
  25. $aRole = $this->oDb->getRoles(array('type' => 'by_id', 'id' => $iId));
  26. if(empty($aRole) || !is_array($aRole))
  27. return false;
  28. if(in_array($iId, $this->aNonDeletable) || $this->oDb->isRoleUsed($iId))
  29. return false;
  30. $isStopDeletion = false;
  31. bx_alert('roles', 'before_delete', $iId, 0, array('role' => $aRole, 'stop_deletion' => &$isStopDeletion, 'stop_deletion_ref' => &$isStopDeletion));
  32. if($isStopDeletion)
  33. return false;
  34. $oLanguage = BxDolStudioLanguagesUtils::getInstance();
  35. $oLanguage->deleteLanguageString($aRole['title']);
  36. $oLanguage->deleteLanguageString($aRole['description']);
  37. if(!parent::_delete($mixedId))
  38. return false;
  39. bx_alert('roles', 'deleted', $iId, 0, array('role' => $aRole));
  40. return true;
  41. }
  42. }
  43. /** @} */