]> git.mjollnir.org Git - moodle.git/commitdiff
Bug #5941 - Myriad of problems with Paypal enrollmemts, part 3 - fixed 'login as...
authorskodak <skodak>
Wed, 28 Jun 2006 15:38:04 +0000 (15:38 +0000)
committerskodak <skodak>
Wed, 28 Jun 2006 15:38:04 +0000 (15:38 +0000)
course/enrol.php

index 19a154f2bf818b6d9fd0ef0792071f9ef6f8e256..521aca26c3d82d88a6461318e382ddeaac6e4c6d 100644 (file)
     if ($form = data_submitted()) {
       //User is not enrolled in the course, wants to access course content
       //as a guest, and course setting allow unlimited guest access
-      //Code cribbed from course/loginas.php
-      if ($loginasguest and ($course->guest==1)) {
-        $realuser = $USER->id;
-        $realname = fullname($USER, true);
-        $USER = guest_user();
-        $USER->loggedin = true;
-        $USER->site = $CFG->wwwroot;
-        $USER->realuser = $realuser;
-        $USER->sessionIP = md5(getremoteaddr());   // Store the current IP in the session
-        if (isset($SESSION->currentgroup)) {    // Remember current cache setting for later
-            $SESSION->oldcurrentgroup = $SESSION->currentgroup;
+      //
+      //the original idea was to use "loginas" feature, but require_login() would have to be changed
+      //and we would have to explain it to all users - it is now plain login action
+      if ($loginasguest and !empty($CFG->guestloginbutton) and ($course->guest==1 or $course->guest==2)) {
+        if (isset($SESSION->currentgroup)) {
             unset($SESSION->currentgroup);
         }
-        $guest_name = fullname($USER, true);
-        add_to_log($course->id, "course", "loginas", "../user/view.php?id=$course->id&$USER->id$", "$realname -> $guest_name");
+        $USER = get_complete_user_data('username', 'guest');    // get full guest user data
+        add_to_log(SITEID, 'user', 'login', "view.php?id=$USER->id&course=".SITEID, $USER->id, 0, $USER->id);
         if ($SESSION->wantsurl) {
             $destination = $SESSION->wantsurl;
             unset($SESSION->wantsurl);