BxAccntModule.php 3.2 KB

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