Merge branch 'wip-mdl-42557' of https://github.com/rajeshtaneja/moodle
authorDan Poltawski <dan@moodle.com>
Tue, 29 Oct 2013 05:16:44 +0000 (13:16 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 29 Oct 2013 05:16:44 +0000 (13:16 +0800)
1  2 
lib/moodlelib.php

diff --combined lib/moodlelib.php
@@@ -4131,9 -4131,6 +4131,9 @@@ function delete_user(stdClass $user) 
          return false;
      }
  
 +    // Keep user record before updating it, as we have to pass this to user_deleted event.
 +    $olduser = clone $user;
 +
      // Keep a copy of user context, we need it for event.
      $usercontext = context_user::instance($user->id);
  
              array(
                  'objectid' => $user->id,
                  'context' => $usercontext,
 -                'other' => array('user' => (array)clone $user)
 +                'other' => array(
 +                    'username' => $user->username,
 +                    'email' => $user->email,
 +                    'idnumber' => $user->idnumber,
 +                    'picture' => $user->picture,
 +                    'mnethostid' => $user->mnethostid
 +                    )
                  )
              );
 -    $event->add_record_snapshot('user', $updateuser);
 +    $event->add_record_snapshot('user', $olduser);
      $event->trigger();
  
      // We will update the user's timemodified, as it will be passed to the user_deleted event, which
@@@ -4814,7 -4805,6 +4814,7 @@@ function set_login_session_preferences(
      $SESSION->justloggedin = true;
  
      unset($SESSION->lang);
 +    unset($SESSION->load_navigation_admin);
  }
  
  
@@@ -4852,10 -4842,6 +4852,6 @@@ function delete_course($courseorid, $sh
      // Delete the course and related context instance.
      context_helper::delete_instance(CONTEXT_COURSE, $courseid);
  
-     // We will update the course's timemodified, as it will be passed to the course_deleted event,
-     // which should know about this updated property, as this event is meant to pass the full course record.
-     $course->timemodified = time();
      $DB->delete_records("course", array("id" => $courseid));
      $DB->delete_records("course_format_options", array("courseid" => $courseid));
  
      $event = \core\event\course_deleted::create(array(
          'objectid' => $course->id,
          'context' => $context,
-         'other' => array('shortname' => $course->shortname,
-                          'fullname' => $course->fullname)
+         'other' => array(
+             'shortname' => $course->shortname,
+             'fullname' => $course->fullname,
+             'idnumber' => $course->idnumber
+             )
      ));
      $event->add_record_snapshot('course', $course);
      $event->trigger();