BxAccntGridAdministration.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup Accounts Accounts
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. class BxAccntGridAdministration extends BxBaseModProfileGridAdministration
  12. {
  13. public function __construct ($aOptions, $oTemplate = false)
  14. {
  15. $this->MODULE = 'bx_accounts';
  16. parent::__construct ($aOptions, $oTemplate);
  17. }
  18. public function performActionActivate()
  19. {
  20. $this->_performActionEnable(true);
  21. }
  22. public function performActionSuspend()
  23. {
  24. $this->_performActionEnable(false);
  25. }
  26. public function performActionResendCemail()
  27. {
  28. $CNF = &$this->_oModule->_oConfig->CNF;
  29. $aIds = bx_get('ids');
  30. if(!$aIds || !is_array($aIds)) {
  31. echoJson(array());
  32. return;
  33. }
  34. $oAccount = BxDolAccount::getInstance();
  35. $iAffected = 0;
  36. $aIdsAffected = array();
  37. foreach($aIds as $iId)
  38. if($oAccount->sendConfirmationEmail($iId)) {
  39. $aIdsAffected[] = $iId;
  40. $iAffected++;
  41. }
  42. echoJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t($CNF['T']['grid_action_err_perform'])));
  43. }
  44. public function resetQueryParams()
  45. {
  46. $aKeys = array('order_field', 'order_dir', $this->_aOptions['paginate_get_start'], $this->_aOptions['paginate_get_per_page']);
  47. foreach ($aKeys as $sKey) {
  48. unset($_GET[$sKey]);
  49. unset($_POST[$sKey]);
  50. }
  51. }
  52. protected function _performActionEnable($isChecked)
  53. {
  54. $CNF = &$this->_oModule->_oConfig->CNF;
  55. $aIds = bx_get('ids');
  56. if(!$aIds || !is_array($aIds)) {
  57. echoJson(array());
  58. return;
  59. }
  60. $iAffected = 0;
  61. $aIdsAffected = array();
  62. foreach($aIds as $iId)
  63. if($this->_enable($iId, $isChecked)) {
  64. $aIdsAffected[] = $iId;
  65. $iAffected++;
  66. }
  67. echoJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t($CNF['T']['grid_action_err_perform'])));
  68. }
  69. protected function _enable($mixedId, $isChecked)
  70. {
  71. $iAction = BX_PROFILE_ACTION_MANUAL;
  72. $oProfile = BxDolProfile::getInstanceAccountProfile($mixedId);
  73. return $isChecked ? $oProfile->activate($iAction) : $oProfile->suspend($iAction);
  74. }
  75. //--- Layout methods ---//
  76. protected function _getCellEmailConfirmed($mixedValue, $sKey, $aField, $aRow)
  77. {
  78. $mixedValue = (int)$mixedValue == 1 ? '_Yes' : '_No';
  79. return parent::_getCellDefault(_t($mixedValue), $sKey, $aField, $aRow);
  80. }
  81. protected function _getCellProfiles($mixedValue, $sKey, $aField, $aRow)
  82. {
  83. $s = $this->_oModule->_oTemplate->getProfilesByAccount($aRow);
  84. return parent::_getCellDefault ($s, $sKey, $aField, $aRow);
  85. }
  86. protected function _getCellLogged($mixedValue, $sKey, $aField, $aRow)
  87. {
  88. return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
  89. }
  90. protected function _isCheckboxDisabled($aRow)
  91. {
  92. return false;
  93. }
  94. protected function _getContentInfo($iId)
  95. {
  96. return BxDolAccountQuery::getInstance()->getInfoById($iId);
  97. }
  98. protected function _doDelete($iId, $aParams = array())
  99. {
  100. return BxDolAccount::getInstance($iId)->delete(isset($aParams['with_content']) && $aParams['with_content'] === true);
  101. }
  102. protected function _isVisibleGrid ($a)
  103. {
  104. return isAdmin();
  105. }
  106. }
  107. /** @} */