]> git.mjollnir.org Git - moodle.git/commitdiff
introduced $CFG->autologinguests, see http://moodle.org/mod/forum/discuss.php?d=9161
authorgustav_delius <gustav_delius>
Wed, 30 Jun 2004 12:09:29 +0000 (12:09 +0000)
committergustav_delius <gustav_delius>
Wed, 30 Jun 2004 12:09:29 +0000 (12:09 +0000)
admin/config.html
lang/en/moodle.php
lib/defaults.php
lib/moodlelib.php
login/index.php

index 1e98aad0f4eca3c0f4b50592933a6e88c45e8269..6bee63eaaf81e338e127f3e8c3d46239c4ea1dc6 100644 (file)
     <?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>
index 93b8d16473684db2f1af633087aeacd1c23b7aa9..ab1b6aefc6d4477080a412c537760ec69e692a26 100644 (file)
@@ -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.';
index efcc33d96f2aa1dfd1f27cc4f55446ad9ea7aaba..56abb7d80046c4575a5226f5b29a2dcc33274640 100644 (file)
@@ -5,6 +5,7 @@
 
    $defaults = array (
        "auth"             => "email",
+       "autologinguests"  => 0,
        "allowunenroll"    =>  true,
        "cachetext"        =>  60,
        "changepassword"   =>  true,
index cccac66c8b0cde10c13968e1cff33c555f9a3075..cfbda7171f3de93c9eb780f5efa6098438118ab1 100644 (file)
@@ -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;
     }
index b70e72e31bb20ad7702efeafc331d2a96c5eaa9e..95185f47c2cd6a60de1d7e41e049679797f6b8a8 100644 (file)
@@ -1,6 +1,7 @@
 <?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")) {
@@ -20,7 +21,7 @@
     }
 
     $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";