BxAccntModule.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. class BxAccntModule extends BxBaseModGeneralModule
  12. {
  13. /**
  14. * Constructor
  15. */
  16. function __construct($aModule)
  17. {
  18. parent::__construct($aModule);
  19. $this->_oConfig->init($this->_oDb);
  20. }
  21. public function serviceGetSafeServices()
  22. {
  23. return array ();
  24. }
  25. /**
  26. * @page service Service Calls
  27. * @section bx_accounts Accounts
  28. * @subsection bx_accounts-other Other
  29. * @subsubsection bx_accounts-get_menu_addon_manage_tools get_menu_addon_manage_tools
  30. *
  31. * @code bx_srv('bx_accounts', 'get_menu_addon_manage_tools', [...]); @endcode
  32. *
  33. * Get number of 'unconfirmed' accounts for User End -> Dasboard page -> Manage block.
  34. *
  35. * @return integer number of 'unconfirmed' accounts
  36. *
  37. * @see BxAccntModule::serviceGetMenuAddonManageTools
  38. */
  39. /**
  40. * @ref bx_accounts-get_menu_addon_manage_tools "get_menu_addon_manage_tools"
  41. */
  42. public function serviceGetMenuAddonManageTools()
  43. {
  44. bx_import('SearchResult', $this->_aModule);
  45. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  46. $o = new $sClass();
  47. $o->unsetPaginate();
  48. $iNumTotal = $o->getNum();
  49. $o->fillFilters(array(
  50. 'unconfirmed' => 1
  51. ));
  52. return array('counter1_value' => $o->getNum(),'counter3_value' => $iNumTotal, 'counter1_caption' => _t('_bx_accnt_menu_dashboard_manage_tools_addon_counter1_caption'));
  53. }
  54. public function checkAllowedConfirm(&$aDataEntry, $isPerformAction = false)
  55. {
  56. $bAdmin = isAdmin();
  57. if(!$bAdmin || BxDolAccount::getInstance($aDataEntry['id'])->isConfirmed())
  58. return _t('_sys_txt_access_denied');
  59. return CHECK_ACTION_RESULT_ALLOWED;
  60. }
  61. public function checkAllowedDelete(&$aDataEntry, $isPerformAction = false)
  62. {
  63. if(isAdmin() && (int)$aDataEntry['id'] == getLoggedId())
  64. return _t('_sys_txt_access_denied');
  65. // check ACL
  66. $aCheck = checkActionModule($this->_iProfileId, 'delete account', 'system', $isPerformAction);
  67. if($aCheck[CHECK_ACTION_RESULT] != CHECK_ACTION_RESULT_ALLOWED)
  68. return $aCheck[CHECK_ACTION_MESSAGE];
  69. return CHECK_ACTION_RESULT_ALLOWED;
  70. }
  71. public function checkAllowedSetOperatorRole(&$aDataEntry, $isPerformAction = false)
  72. {
  73. $bAdmin = isAdmin();
  74. $iAccountId = getLoggedId();
  75. if(!$bAdmin || !BxDolStudioRolesUtils::getInstance()->isActionAllowed(BX_SRA_MANAGE_ROLES, $iAccountId) || (int)$aDataEntry['id'] == $iAccountId)
  76. return _t('_sys_txt_access_denied');
  77. return CHECK_ACTION_RESULT_ALLOWED;
  78. }
  79. public function checkAllowedMakeOperator(&$aDataEntry, $isPerformAction = false)
  80. {
  81. $bAdmin = isAdmin();
  82. $iAccountId = getLoggedId();
  83. if(!$bAdmin || !BxDolStudioRolesUtils::getInstance()->isActionAllowed(BX_SRA_MANAGE_ROLES, $iAccountId) || (int)$aDataEntry['id'] == $iAccountId || (int)$aDataEntry['role'] == 3)
  84. return _t('_sys_txt_access_denied');
  85. return CHECK_ACTION_RESULT_ALLOWED;
  86. }
  87. public function checkAllowedUnmakeOperator(&$aDataEntry, $isPerformAction = false)
  88. {
  89. $bAdmin = isAdmin();
  90. $iAccountId = getLoggedId();
  91. if(!$bAdmin || !BxDolStudioRolesUtils::getInstance()->isActionAllowed(BX_SRA_MANAGE_ROLES, $iAccountId) || (int)$aDataEntry['id'] == $iAccountId || (int)$aDataEntry['role'] != 3)
  92. return _t('_sys_txt_access_denied');
  93. return CHECK_ACTION_RESULT_ALLOWED;
  94. }
  95. public function checkAllowedUnlockAccount(&$aDataEntry, $isPerformAction = false)
  96. {
  97. if((int)$aDataEntry['locked'] != 1)
  98. return _t('_sys_txt_access_denied');
  99. return CHECK_ACTION_RESULT_ALLOWED;
  100. }
  101. }
  102. /** @} */