Kaynağa Gözat

Ticket #2105 - Possibility to pass 'relocate' parameter.

AntonLV 7 yıl önce
ebeveyn
işleme
d4bd78bda1

+ 4 - 1
inc/classes/BxDolProfileForms.php

@@ -25,7 +25,10 @@ class BxDolProfileForms extends BxDolFactory
         if ($isPermalink)
             $sUrl = BxDolPermalinks::getInstance()->permalink($sUrl);
 
-        header('Location: ' . BX_DOL_URL_ROOT . $this->_replaceMarkers($sUrl, $aMarkers));
+        if(strncmp($sUrl, BX_DOL_URL_ROOT, strlen(BX_DOL_URL_ROOT)) !== 0)
+            $sUrl = BX_DOL_URL_ROOT . $sUrl;
+
+        header('Location: ' . $this->_replaceMarkers($sUrl, $aMarkers));
         exit;
     }
 

+ 11 - 3
template/scripts/BxBaseAccountForms.php

@@ -77,6 +77,9 @@ class BxBaseAccountForms extends BxDolProfileForms
 
         $iProfileId = $this->onAccountCreated($iAccountId, $oForm->isSetPendingApproval());
 
+        $sRelocateCustom = $oForm->getCleanValue('relocate');
+        $bRelocateCustom = !empty($sRelocateCustom);
+
         // perform action
         BxDolAccount::isAllowedCreate ($iProfileId, true);
 
@@ -106,16 +109,21 @@ class BxBaseAccountForms extends BxDolProfileForms
             $a = BxDolService::call($sProfileModule, 'entity_add', array($iProfileId, $aProfileInfo));
 
             // in case of successful profile add redirect to the page after profile creation
-            if (0 == $a['code']) { 
+            if (0 == $a['code']) {
+                if($bRelocateCustom)
+                    $this->_redirectAndExit($sRelocateCustom, false);
+
                 BxDolService::call($sProfileModule, 'redirect_after_add', array($a['content']));
                 return;
             }
             // if creation failed, redirect to create profile form
         }
 
-        $sRedirectUrl = !empty($sProfileModule) ? BxDolService::call($sProfileModule, 'profile_create_url', array(false)) : '';
+        $sRelocate = !empty($sProfileModule) ? BxDolService::call($sProfileModule, 'profile_create_url', array(false)) : '';
+        if(empty($sRelocate))
+            $sRelocate = $bRelocateCustom ? $sRelocateCustom : getParam('sys_redirect_after_account_added');
     
-        $this->_redirectAndExit(!empty($sRedirectUrl) ? $sRedirectUrl : getParam('sys_redirect_after_account_added'), true, array(
+        $this->_redirectAndExit($sRelocate, true, array(
             'account_id' => $iAccountId,
             'profile_id' => $iProfileId,
         ));