Просмотр исходного кода

Ticket #4971 - Build-in API support: Different.

AntonLV 4 месяцев назад
Родитель
Сommit
55b67b2fd8
1 измененных файлов с 7 добавлено и 5 удалено
  1. 7 5
      template/scripts/BxBaseServiceAccount.php

+ 7 - 5
template/scripts/BxBaseServiceAccount.php

@@ -849,32 +849,34 @@ class BxBaseServiceAccount extends BxDol
         $oForm->initChecker();
         $oForm->initChecker();
         if($oForm->isSubmittedAndValid()) {
         if($oForm->isSubmittedAndValid()) {
             $sErrorUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password'));
             $sErrorUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password'));
+            if($bApi)
+                $sErrorUrl = bx_api_get_relative_url($sErrorUrl);
 
 
             // check if key exists
             // check if key exists
             $oKey = BxDolKey::getInstance();
             $oKey = BxDolKey::getInstance();
             $sKey = $oForm->getCleanValue('key');
             $sKey = $oForm->getCleanValue('key');
             if(!$oKey || !$oKey->isKeyExists($sKey))
             if(!$oKey || !$oKey->isKeyExists($sKey))
-                return $bApi ? bx_api_get_msg(_t('_sys_txt_reset_pasword_error_invalid_key', $sErrorUrl)) : MsgBox(_t('_sys_txt_reset_pasword_error_invalid_key', $sErrorUrl));
+                return ($sMsg = _t('_sys_txt_reset_pasword_error_invalid_key', $sErrorUrl)) && $bApi ? [bx_api_get_msg($sMsg)] : MsgBox($sMsg);
 
 
             // check if key data exists
             // check if key data exists
             $aKeyData = $oKey->getKeyData($sKey);
             $aKeyData = $oKey->getKeyData($sKey);
             if(empty($aKeyData['email']))
             if(empty($aKeyData['email']))
-                return $bApi ? [bx_api_get_msg(_t('_sys_txt_reset_pasword_error_invalid_key', $sErrorUrl))] : MsgBox(_t('_sys_txt_reset_pasword_error_invalid_key', $sErrorUrl));
+                return ($sMsg = _t('_sys_txt_reset_pasword_error_invalid_key', $sErrorUrl)) && $bApi ? [bx_api_get_msg($sMsg)] : MsgBox($sMsg);
 
 
             // check if account with such email exists
             // check if account with such email exists
             $iAccountId = $this->_oAccountQuery->getIdByEmail($aKeyData['email']);
             $iAccountId = $this->_oAccountQuery->getIdByEmail($aKeyData['email']);
             if(empty($iAccountId))
             if(empty($iAccountId))
-                return $bApi ? [bx_api_get_msg(_t('_sys_txt_reset_pasword_error_not_found', $sErrorUrl))] : MsgBox(_t('_sys_txt_reset_pasword_error_not_found', $sErrorUrl));;
+                return ($sMsg = _t('_sys_txt_reset_pasword_error_not_found', $sErrorUrl)) && $bApi ? [bx_api_get_msg($sMsg)] : MsgBox($sMsg);
 
 
             $sPassword = $oForm->getCleanValue('password');
             $sPassword = $oForm->getCleanValue('password');
             $oAccount = BxDolAccount::getInstance($iAccountId);
             $oAccount = BxDolAccount::getInstance($iAccountId);
             if (!$oAccount || !$oAccount->updatePassword($sPassword))
             if (!$oAccount || !$oAccount->updatePassword($sPassword))
-                return $bApi ?[ bx_api_get_msg(_t('_sys_txt_reset_pasword_error_occured', $sErrorUrl))] : MsgBox(_t('_sys_txt_reset_pasword_error_occured', $sErrorUrl));
+                return ($sMsg = _t('_sys_txt_reset_pasword_error_occured', $sErrorUrl)) && $bApi ?[ bx_api_get_msg($sMsg)] : MsgBox($sMsg);
 
 
             $this->_oAccountQuery->unlockAccount($iAccountId);
             $this->_oAccountQuery->unlockAccount($iAccountId);
             $oKey->removeKey($sKey);
             $oKey->removeKey($sKey);
 
 
-            return $bApi ? [bx_api_get_msg(_t('_sys_txt_reset_pasword_success', $sErrorUrl))] : MsgBox(_t('_sys_txt_reset_pasword_success'), 3) . bx_srv('system', 'login_form_only', array('', bx_get_reset_password_redirect($iAccountId)), 'TemplServiceLogin');
+            return ($sMsg = _t('_sys_txt_reset_pasword_success')) && $bApi ? [bx_api_get_msg($sMsg)] : MsgBox($sMsg, 3) . bx_srv('system', 'login_form_only', array('', bx_get_reset_password_redirect($iAccountId)), 'TemplServiceLogin');
         }
         }
 
 
         $sTitleReset = _t('_sys_page_title_forgot_password_reset');
         $sTitleReset = _t('_sys_page_title_forgot_password_reset');