From: martin <martin>
Date: Sun, 8 Sep 2002 15:39:44 +0000 (+0000)
Subject: Fixed a bug.  When replying to an email copy, you would be forwarded
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=28e1e8b912721898857d74961536d212709d1496;p=moodle.git

Fixed a bug.  When replying to an email copy, you would be forwarded
to the login screen to login first.  However, this was being saved
as the place to go back to after replying.

I added a check for this so now it behaves as you'd expect.
---

diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index 2f27c45c58..08e9f0fba5 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -413,11 +413,14 @@ function forum_count_unrated_posts($discussionid, $userid) {
 
 
 function forum_set_return() {
-    global $SESSION, $HTTP_REFERER;
+    global $CFG, $SESSION, $HTTP_REFERER;
 
-    if (! $SESSION->fromdiscussion) {
-        $SESSION->fromdiscussion = $HTTP_REFERER;
-        save_session("SESSION");
+    if (! isset($SESSION->fromdiscussion)) {
+        // If the referer is NOT a login screen then save it.
+        if (! strncasecmp("$CFG->wwwroot/login", $HTTP_REFERER, 300)) {
+            $SESSION->fromdiscussion = $HTTP_REFERER;
+            save_session("SESSION");
+        }
     }
 }