]> git.mjollnir.org Git - moodle.git/commitdiff
After agreeing to site policy, you get redirected back to where you
authormoodler <moodler>
Mon, 29 Nov 2004 06:22:12 +0000 (06:22 +0000)
committermoodler <moodler>
Mon, 29 Nov 2004 06:22:12 +0000 (06:22 +0000)
were going.

Also, guests get asked to agree for EVERY SESSION.

lib/moodlelib.php
user/policy.php

index 08a5fd5138ec9b4c2bce79d6d13f4a1ea188f478..6f315a0ad041123cf7f40c873f6b102b94da2368 100644 (file)
@@ -788,6 +788,7 @@ function require_login($courseid=0, $autologinguest=true) {
     // Check that the user has agreed to a site policy if there is one
     if (!empty($CFG->sitepolicy)) {
         if (!$USER->policyagreed) {
+            $SESSION->wantsurl = $FULLME;
             redirect($CFG->wwwroot .'/user/policy.php');
             die;
         }
index 82feded4e7b5ee9b8075274b883fbfaeea7f1048..4efcfc0cb92014d1a0e69aec9f8908b3da130f3d 100644 (file)
     }
 
     if ($agree == 1 and confirm_sesskey()) {        // User has agreed
-        if (!set_field('user', 'policyagreed', 1, 'id', $USER->id)) {
-            error('Could not save your agreement');
+        if ($USER->username != 'guest') {           // Don't remember guests
+            if (!set_field('user', 'policyagreed', 1, 'id', $USER->id)) {
+                error('Could not save your agreement');
+            }
         }
         $USER->policyagreed = 1;
-        redirect($CFG->wwwroot);
+
+        if (!empty($SESSION->wantsurl)) {
+            $wantsurl = $SESSION->wantsurl;
+            unset($SESSION->wantsurl);
+            redirect($wantsurl);
+        } else {
+            redirect($CFG->wwwroot.'/');
+        }
         exit;
     }