]> git.mjollnir.org Git - moodle.git/commitdiff
made sure that the guest autologin does not happen when user replies to post
authorgustav_delius <gustav_delius>
Thu, 1 Jul 2004 22:29:04 +0000 (22:29 +0000)
committergustav_delius <gustav_delius>
Thu, 1 Jul 2004 22:29:04 +0000 (22:29 +0000)
lib/moodlelib.php
mod/forum/post.php

index cd1b7bdc5dd011704bd70531c8c9456df1b58102..b7cc39d9125d6570dc168d123bddf80f788e9a00 100644 (file)
@@ -351,10 +351,12 @@ function get_user_timezone($tz = 99) {
 
 /// USER AUTHENTICATION AND LOGIN ////////////////////////////////////////
 
-function require_login($courseid=0) {
+function require_login($courseid=0, $autologinguest=true) {
 /// This function checks that the current user is logged in, and optionally
 /// whether they are "logged in" or allowed to be in a particular course.
 /// If not, then it redirects them to the site login or course enrolment.
+/// $autologinguest determines whether visitors should automatically be
+/// logged in as guests provide $CFG->autologinguests is set to 1
 
     global $CFG, $SESSION, $USER, $FULLME, $MoodleSession;
 
@@ -365,8 +367,10 @@ function require_login($courseid=0) {
             $SESSION->fromurl  = $_SERVER["HTTP_REFERER"];
         }
         $USER = NULL;
-        if (!empty($CFG->autologinguests)) {
-            $loginguest = ($courseid and get_field('course','guest','id',$courseid)) ? '?loginguest=true' : '';
+        if ($autologinguest and $CFG->autologinguests and $courseid and get_field('course','guest','id',$courseid)) {
+            $loginguest = '?loginguest=true';
+        } else {
+            $loginguest = '';
         }
         if (empty($CFG->loginhttps)) {
             redirect("$CFG->wwwroot/login/index.php$loginguest");
index 49eda30e31a96533867448dfea10f1bbc54fa106..6ae9abd1d867331a0744309129547adcc7dda923 100644 (file)
@@ -10,7 +10,7 @@
         error(get_string("noguestpost", "forum"), $_SERVER["HTTP_REFERER"]);
     }
 
-    require_login();   // Script is useless unless they're logged in
+    require_login(0, false);   // Script is useless unless they're logged in
 
     if ($post = data_submitted()) {