From 8e8d0524afedbde17935656db5441a9e1b049666 Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Thu, 1 Jul 2004 22:29:04 +0000 Subject: [PATCH] made sure that the guest autologin does not happen when user replies to post --- lib/moodlelib.php | 10 +++++++--- mod/forum/post.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index cd1b7bdc5d..b7cc39d912 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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"); diff --git a/mod/forum/post.php b/mod/forum/post.php index 49eda30e31..6ae9abd1d8 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -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()) { -- 2.39.5