BxAccntModule.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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->fillFilters(array(
  44. 'unconfirmed' => 1
  45. ));
  46. $o->unsetPaginate();
  47. return $o->getNum();
  48. }
  49. public function checkAllowedDelete(&$aDataEntry, $isPerformAction = false)
  50. {
  51. if(isAdmin() && (int)$aDataEntry['id'] == getLoggedId())
  52. return _t('_sys_txt_access_denied');
  53. // check ACL
  54. $aCheck = checkActionModule($this->_iProfileId, 'delete account', 'system', $isPerformAction);
  55. if($aCheck[CHECK_ACTION_RESULT] != CHECK_ACTION_RESULT_ALLOWED)
  56. return $aCheck[CHECK_ACTION_MESSAGE];
  57. return CHECK_ACTION_RESULT_ALLOWED;
  58. }
  59. public function checkAllowedMakeOperator(&$aDataEntry, $isPerformAction = false)
  60. {
  61. $bAdmin = isAdmin();
  62. if(!$bAdmin || (int)$aDataEntry['id'] == getLoggedId() || (int)$aDataEntry['role'] == 3)
  63. return _t('_sys_txt_access_denied');
  64. return CHECK_ACTION_RESULT_ALLOWED;
  65. }
  66. public function checkAllowedUnmakeOperator(&$aDataEntry, $isPerformAction = false)
  67. {
  68. $bAdmin = isAdmin();
  69. if(!$bAdmin || (int)$aDataEntry['id'] == getLoggedId() || (int)$aDataEntry['role'] != 3)
  70. return _t('_sys_txt_access_denied');
  71. return CHECK_ACTION_RESULT_ALLOWED;
  72. }
  73. public function checkAllowedUnlockAccount(&$aDataEntry, $isPerformAction = false)
  74. {
  75. if((int)$aDataEntry['locked'] != 1)
  76. return _t('_sys_txt_access_denied');
  77. return CHECK_ACTION_RESULT_ALLOWED;
  78. }
  79. }
  80. /** @} */