Explorar el Código

Ticket #5641 - Allow to override redirect URL after entry deletion.

AntonLV hace 1 mes
padre
commit
764f852f67

+ 4 - 2
modules/base/general/classes/BxBaseModGeneralFormsEntryHelper.php

@@ -580,11 +580,13 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
             $this->redirectAfterDelete($aContentInfo);
             $this->redirectAfterDelete($aContentInfo);
     }
     }
 
 
-    protected function redirectAfterDelete($aContentInfo)
+    protected function redirectAfterDelete($aContentInfo, $sUrl = '')
     {
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
         $CNF = &$this->_oModule->_oConfig->CNF;
 
 
-        $sUrl = $CNF['URL_HOME'];
+        if ($sUrl == '')
+            $sUrl = $CNF['URL_HOME'];
+
         $aMarkers = array(
         $aMarkers = array(
             'account_id' => getLoggedId(),
             'account_id' => getLoggedId(),
             'profile_id' => bx_get_logged_profile_id(),
             'profile_id' => bx_get_logged_profile_id(),

+ 3 - 10
modules/boonex/classes/classes/BxClssFormsEntryHelper.php

@@ -19,21 +19,14 @@ class BxClssFormsEntryHelper extends BxBaseModTextFormsEntryHelper
         parent::__construct($oModule);
         parent::__construct($oModule);
     }
     }
 
 
-    protected function redirectAfterDelete($aContentInfo)
+    protected function redirectAfterDelete($aContentInfo, $sUrl = '')
     {
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
         $CNF = &$this->_oModule->_oConfig->CNF;
 
 
-        if ($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] < 0)
-            $oProfileContext = BxDolProfile::getInstance(abs($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]));
-        
-        $sUrl = BX_DOL_URL_ROOT;
-        if ($oProfileContext)
+        if ($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] < 0 && ($oProfileContext = BxDolProfile::getInstance(abs($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))) !== false)
             $sUrl = $oProfileContext->getUrl();
             $sUrl = $oProfileContext->getUrl();
 
 
-        $this->_redirectAndExit($sUrl, true, array(
-            'account_id' => getLoggedId(),
-            'profile_id' => bx_get_logged_profile_id(),
-        ));
+        return parent::redirectAfterDelete($aContentInfo, $sUrl);
     }
     }
 }
 }
 
 

+ 6 - 9
modules/boonex/files/classes/BxFilesFormsEntryHelper.php

@@ -22,17 +22,14 @@ class BxFilesFormsEntryHelper extends BxBaseModFilesFormsEntryHelper
         parent::__construct($oModule);
         parent::__construct($oModule);
     }
     }
 
 
-    protected function redirectAfterDelete($aContentInfo)
+    protected function redirectAfterDelete($aContentInfo, $sUrl = '')
     {
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
         $CNF = &$this->_oModule->_oConfig->CNF;
-        $oProfile = BxDolProfile::getInstance($aContentInfo[$CNF['FIELD_AUTHOR']]);
-        if ($oProfile)
-            $this->_redirectAndExit('page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id=' . $oProfile->id());
-        else
-            $this->_redirectAndExit($CNF['URL_HOME'], true, array(
-                'account_id' => getLoggedId(),
-                'profile_id' => bx_get_logged_profile_id(),
-            ));
+
+        if (($oProfile = BxDolProfile::getInstance($aContentInfo[$CNF['FIELD_AUTHOR']])) !== false)
+            $sUrl = 'page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id=' . $oProfile->id();
+
+        return parent::redirectAfterDelete($aContentInfo, $sUrl);
     }
     }
 }
 }
 
 

+ 2 - 6
modules/boonex/resources/classes/BxResourcesFormsEntryHelper.php

@@ -18,18 +18,14 @@ class BxResourcesFormsEntryHelper extends BxBaseModTextFormsEntryHelper
         parent::__construct($oModule);
         parent::__construct($oModule);
     }
     }
 
 
-    protected function redirectAfterDelete($aContentInfo)
+    protected function redirectAfterDelete($aContentInfo, $sUrl = '')
     {
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
         $CNF = &$this->_oModule->_oConfig->CNF;
 
 
-        $sUrl = BX_DOL_URL_ROOT;
         if((int)$aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] < 0)
         if((int)$aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] < 0)
             $sUrl = 'page.php?i=' . $CNF['URI_ENTRIES_BY_CONTEXT'] . '&profile_id=' . abs($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]);
             $sUrl = 'page.php?i=' . $CNF['URI_ENTRIES_BY_CONTEXT'] . '&profile_id=' . abs($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]);
 
 
-        $this->_redirectAndExit($sUrl, true, array(
-            'account_id' => getLoggedId(),
-            'profile_id' => bx_get_logged_profile_id(),
-        ));
+        return parent::redirectAfterDelete($aContentInfo, $sUrl);
     }
     }
 }
 }
 
 

+ 2 - 6
modules/boonex/tasks/classes/BxTasksFormsEntryHelper.php

@@ -73,18 +73,14 @@ class BxTasksFormsEntryHelper extends BxBaseModTextFormsEntryHelper
         return '';
         return '';
     }
     }
 
 
-    protected function redirectAfterDelete($aContentInfo)
+    protected function redirectAfterDelete($aContentInfo, $sUrl = '')
     {
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
         $CNF = &$this->_oModule->_oConfig->CNF;
 
 
-        $sUrl = BX_DOL_URL_ROOT;
         if((int)$aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] < 0)
         if((int)$aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] < 0)
             $sUrl = 'page.php?i=' . $CNF['URI_ENTRIES_BY_CONTEXT'] . '&profile_id=' . abs($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]);
             $sUrl = 'page.php?i=' . $CNF['URI_ENTRIES_BY_CONTEXT'] . '&profile_id=' . abs($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]);
 
 
-        $this->_redirectAndExit($sUrl, true, array(
-            'account_id' => getLoggedId(),
-            'profile_id' => bx_get_logged_profile_id(),
-        ));
+        return parent::redirectAfterDelete($aContentInfo, $sUrl);
     }
     }
 
 
     public function onDataDeleteAfter ($iContentId, $aContentInfo, $oProfile)
     public function onDataDeleteAfter ($iContentId, $aContentInfo, $oProfile)