BxAccntMenuManageTools.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 Accounts Accounts
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * 'Manage tools' menu.
  13. */
  14. class BxAccntMenuManageTools extends BxBaseModGeneralMenuManageTools
  15. {
  16. public function __construct($aObject, $oTemplate = false)
  17. {
  18. $this->MODULE = 'bx_accounts';
  19. parent::__construct($aObject, $oTemplate);
  20. }
  21. /**
  22. * Check if menu items is visible.
  23. * @param $a menu item array
  24. * @return boolean
  25. */
  26. protected function _isVisible ($a)
  27. {
  28. if(!parent::_isVisible($a))
  29. return false;
  30. $aDataEntry = BxDolAccountQuery::getInstance()->getInfoById($this->_iContentId);
  31. if(empty($aDataEntry) || !is_array($aDataEntry))
  32. return false;
  33. $sCheckFuncName = '';
  34. switch ($a['name']) {
  35. case 'delete':
  36. case 'delete-with-content':
  37. $sCheckFuncName = 'checkAllowedDelete';
  38. break;
  39. case 'set-operator-role':
  40. $sCheckFuncName = 'checkAllowedSetOperatorRole';
  41. break;
  42. case 'make-operator':
  43. $sCheckFuncName = 'checkAllowedMakeOperator';
  44. break;
  45. case 'unmake-operator':
  46. $sCheckFuncName = 'checkAllowedUnmakeOperator';
  47. break;
  48. case 'unlock-account':
  49. $sCheckFuncName = 'checkAllowedUnlockAccount';
  50. break;
  51. case 'confirm':
  52. $sCheckFuncName = 'checkAllowedConfirm';
  53. break;
  54. }
  55. if(!$sCheckFuncName || !method_exists($this->_oModule, $sCheckFuncName))
  56. return true;
  57. return $this->_oModule->{$sCheckFuncName}($aDataEntry) === CHECK_ACTION_RESULT_ALLOWED;
  58. }
  59. }
  60. /** @} */