<?php print_string("configextendedusernamechars") ?>
</td>
</tr>
+<tr valign=top>
+ <td align=right><p>autologinguests:</td>
+ <td>
+ <?php
+ unset($options);
+ $options[0] = get_string('no');
+ $options[1] = get_string('yes');
+
+ choose_from_menu ($options, "autologinguests", $config->autologinguests, "", "", "");
+ ?>
+ </td>
+ <td>
+ <?php print_string("configautologinguests") ?>
+ </td>
+</tr>
<tr valign=top>
<td align=right><p>forcelogin:</td>
<td>
$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.';
$defaults = array (
"auth" => "email",
+ "autologinguests" => 0,
"allowunenroll" => true,
"cachetext" => 60,
"changepassword" => true,
$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;
}
<?PHP // $Id$
require_once("../config.php");
+ optional_variable($loginguest, false); // determines whether visitors are logged in as guest automatically
// Check if the guest user exists. If not, create one.
if (! record_exists("user", "username", "guest")) {
}
$frm = false;
- if (!empty($SESSION->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";