Browse Source

Fixing deprecated functions

SABERES_37_STABLE
Carlos Shirasawa (Shiro) 10 years ago
parent
commit
39c04e0ced
  1. 12
      enroluser.php
  2. 6
      lib.php
  3. 7
      unenrolself.php
  4. 11
      unenroluser.php

12
enroluser.php

@ -104,7 +104,11 @@ if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
} }
//echo "<pre>";print_r($instance);exit(); //echo "<pre>";print_r($instance);exit();
$enrol_manual->enrol_user($instance, $adduser->id, $roleid, $timestart, $timeend); $enrol_manual->enrol_user($instance, $adduser->id, $roleid, $timestart, $timeend);
add_to_log($course->id, 'course', 'enrol', '../enrol/users.php?id='.$course->id, $course->id); //there should be userid somewhere!
// Deprecated fixed by Shiro <gigashiro@gmail.com>
//add_to_log($course->id, 'course', 'enrol', '../enrol/users.php?id='.$course->id, $course->id); //there should be userid somewhere!
$context = context_course::instance($course->id);
\core\event\user_enrolment_created::create(array('context' => $context))->trigger();
} }
$potentialuserselector->invalidate_selected_users(); $potentialuserselector->invalidate_selected_users();
@ -120,7 +124,11 @@ if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) {
if (!empty($userstounassign)) { if (!empty($userstounassign)) {
foreach($userstounassign as $removeuser) { foreach($userstounassign as $removeuser) {
$enrol_manual->unenrol_user($instance, $removeuser->id); $enrol_manual->unenrol_user($instance, $removeuser->id);
add_to_log($course->id, 'course', 'unenrol', '../enrol/users.php?id='.$course->id, $course->id); //there should be userid somewhere!
// Deprecated fixed by Shiro <gigashiro@gmail.com>
//add_to_log($course->id, 'course', 'unenrol', '../enrol/users.php?id='.$course->id, $course->id); //there should be userid somewhere!
$context = context_course::instance($course->id);
\core\event\user_enrolment_deleted::delete(array('context' => $context))->trigger();
} }
$potentialuserselector->invalidate_selected_users(); $potentialuserselector->invalidate_selected_users();

6
lib.php

@ -96,7 +96,11 @@ class enrol_apply_plugin extends enrol_plugin {
sendConfirmMailToTeachers($instance->courseid, $instance->id, $data->applydescription); sendConfirmMailToTeachers($instance->courseid, $instance->id, $data->applydescription);
sendConfirmMailToManagers($instance->courseid,$data->applydescription); sendConfirmMailToManagers($instance->courseid,$data->applydescription);
add_to_log($instance->courseid, 'course', 'enrol', '../enrol/users.php?id='.$instance->courseid, $instance->courseid); //there should be userid somewhere! // Deprecated fixed by Shiro <gigashiro@gmail.com>
//add_to_log($instance->courseid, 'course', 'enrol', '../enrol/users.php?id='.$instance->courseid, $instance->courseid); //there should be userid somewhere!
$context = context_course::instance($instance->courseid);
\core\event\user_enrolment_created::create(array('context' => $context))->trigger();
redirect("$CFG->wwwroot/course/view.php?id=$instance->courseid"); redirect("$CFG->wwwroot/course/view.php?id=$instance->courseid");
} }
} }

7
unenrolself.php

@ -49,7 +49,12 @@ $PAGE->set_title($plugin->get_instance_name($instance));
if ($confirm and confirm_sesskey()) { if ($confirm and confirm_sesskey()) {
$plugin->unenrol_user($instance, $USER->id); $plugin->unenrol_user($instance, $USER->id);
add_to_log($course->id, 'course', 'unenrol', '../enrol/users.php?id='.$course->id, $course->id); //TODO: there should be userid somewhere!
// Deprecated fixed by Shiro <gigashiro@gmail.com>
//add_to_log($course->id, 'course', 'unenrol', '../enrol/users.php?id='.$course->id, $course->id); //TODO: there should be userid somewhere!
$context = context_course::instance($course->id);
\core\event\user_enrolment_deleted::delete(array('context' => $context))->trigger();
redirect(new moodle_url('/index.php')); redirect(new moodle_url('/index.php'));
} }

11
unenroluser.php

@ -31,15 +31,16 @@ $ue = $DB->get_record('user_enrolments', array('id' => $ueid), '*', MUST_EXI
// Get the user for whom the enrolment is // Get the user for whom the enrolment is
$user = $DB->get_record('user', array('id'=>$ue->userid), '*', MUST_EXIST); $user = $DB->get_record('user', array('id'=>$ue->userid), '*', MUST_EXIST);
// Get the course the enrolment is to // Get the course the enrolment is to
list($ctxsql, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); //list($ctxsql, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
$sql = "SELECT c.* $ctxsql $ctxsql = context_helper::get_preload_record_columns_sql('ctx');
$sql = "SELECT c.*, $ctxsql
FROM {course} c FROM {course} c
LEFT JOIN {enrol} e ON e.courseid = c.id LEFT JOIN {enrol} e ON e.courseid = c.id
$ctxjoin LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextcourse)
WHERE e.id = :enrolid"; WHERE e.id = :enrolid";
$params = array('enrolid' => $ue->enrolid); $params = array('enrolid' => $ue->enrolid, 'contextcourse' => CONTEXT_COURSE);
$course = $DB->get_record_sql($sql, $params, MUST_EXIST); $course = $DB->get_record_sql($sql, $params, MUST_EXIST);
context_instance_preload($course); context_helper::preload_from_record($course);
// Make sure it's not the front page // Make sure it's not the front page

Loading…
Cancel
Save