From: gustav_delius Date: Wed, 30 Jun 2004 12:09:29 +0000 (+0000) Subject: introduced $CFG->autologinguests, see http://moodle.org/mod/forum/discuss.php?d=9161 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=fe6571366c63abbe1357b7bb9cb524d88cf55565;p=moodle.git introduced $CFG->autologinguests, see http://moodle.org/mod/forum/discuss.php?d=9161 --- diff --git a/admin/config.html b/admin/config.html index 1e98aad0f4..6bee63eaaf 100644 --- a/admin/config.html +++ b/admin/config.html @@ -428,6 +428,21 @@ + +

autologinguests: + + autologinguests, "", "", ""); + ?> + + + + +

forcelogin: diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 93b8d16473..ab1b6aefc6 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -139,6 +139,7 @@ $string['closewindow'] = 'Close this window'; $string['comparelanguage'] = 'Compare and edit current language'; $string['complete'] = 'Complete'; $string['configallowunenroll'] = 'If this is set \'Yes\', then students are allowed to unenroll themselves from courses whenever they like. Otherwise they are not allowed, and this process will be solely controlled by the teachers and administrators.'; +$string['configautologinguests'] = 'Should visitors be logged in as guests automatically when entering courses with guest access?'; $string['configcachetext'] = 'For larger sites or sites that use text filters, this setting can really speed things up. Copies of texts will be retained in their processed form for the time specified here. Setting this too small may actually slow things down slightly, but setting it too large may mean texts take too long to refresh (with new links, for example).'; $string['configcountry'] = 'If you set a country here, then this country will be selected by default on new user accounts. To force users to choose a country, just leave this unset.'; $string['configdebug'] = 'If you turn this on, then PHP\'s error_reporting will be increased so that more warnings are printed. This is only useful for developers.'; diff --git a/lib/defaults.php b/lib/defaults.php index efcc33d96f..56abb7d800 100644 --- a/lib/defaults.php +++ b/lib/defaults.php @@ -5,6 +5,7 @@ $defaults = array ( "auth" => "email", + "autologinguests" => 0, "allowunenroll" => true, "cachetext" => 60, "changepassword" => true, diff --git a/lib/moodlelib.php b/lib/moodlelib.php index cccac66c8b..cfbda7171f 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -365,11 +365,13 @@ function require_login($courseid=0) { $SESSION->fromurl = $_SERVER["HTTP_REFERER"]; } $USER = NULL; + $loginguest = (isset($CFG->loginguests) and $CFG->autologinguests + and $courseid and get_field('course','guest','id',$courseid)) ? '?loginguest=true' : ''; if (empty($CFG->loginhttps)) { - redirect("$CFG->wwwroot/login/index.php"); + redirect("$CFG->wwwroot/login/index.php$loginguest"); } else { $wwwroot = str_replace('http','https',$CFG->wwwroot); - redirect("$wwwroot/login/index.php"); + redirect("$wwwroot/login/index.php$loginguest"); } die; } diff --git a/login/index.php b/login/index.php index b70e72e31b..95185f47c2 100644 --- a/login/index.php +++ b/login/index.php @@ -1,6 +1,7 @@ wantsurl) and strstr($SESSION->wantsurl,"username=guest")) { + if ((!empty($SESSION->wantsurl) and strstr($SESSION->wantsurl,"username=guest")) or $loginguest) { /// Log in as guest automatically (idea from Zbigniew Fiedorowicz) $frm->username = "guest"; $frm->password = "guest";