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. 13
      unenroluser.php

12
enroluser.php

@ -104,7 +104,11 @@ if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
}
//echo "<pre>";print_r($instance);exit();
$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();
@ -120,7 +124,11 @@ if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) {
if (!empty($userstounassign)) {
foreach($userstounassign as $removeuser) {
$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();

6
lib.php

@ -96,7 +96,11 @@ class enrol_apply_plugin extends enrol_plugin {
sendConfirmMailToTeachers($instance->courseid, $instance->id, $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");
}
}

7
unenrolself.php

@ -49,7 +49,12 @@ $PAGE->set_title($plugin->get_instance_name($instance));
if ($confirm and confirm_sesskey()) {
$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'));
}

13
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
$user = $DB->get_record('user', array('id'=>$ue->userid), '*', MUST_EXIST);
// Get the course the enrolment is to
list($ctxsql, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
$sql = "SELECT c.* $ctxsql
//list($ctxsql, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
$ctxsql = context_helper::get_preload_record_columns_sql('ctx');
$sql = "SELECT c.*, $ctxsql
FROM {course} c
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";
$params = array('enrolid' => $ue->enrolid);
$params = array('enrolid' => $ue->enrolid, 'contextcourse' => CONTEXT_COURSE);
$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
@ -94,4 +95,4 @@ $PAGE->navbar->add($fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($fullname);
echo $OUTPUT->confirm($message, $yesurl, $returnurl);
echo $OUTPUT->footer();
echo $OUTPUT->footer();

Loading…
Cancel
Save