Browse Source

Replaced deprecated function get_context_instance() with context_XXX::instance()

develop_fields
Johannes Burk 11 years ago
parent
commit
3cd9c557ab
  1. 4
      apply.php
  2. 2
      edit.php
  3. 2
      enroluser.php
  4. 6
      lib.php
  5. 2
      manage.php
  6. 2
      unenroluser.php

4
apply.php

@ -16,11 +16,11 @@ require_once($CFG->dirroot.'/lib/outputcomponents.php');
require_once ('lib.php'); require_once ('lib.php');
$site = get_site (); $site = get_site ();
$systemcontext = get_context_instance ( CONTEXT_SYSTEM ); $systemcontext = context_system::instance();
$id = required_param ( 'id', PARAM_INT ); // course id $id = required_param ( 'id', PARAM_INT ); // course id
$course = $DB->get_record ( 'course', array ('id' => $id ), '*', MUST_EXIST ); $course = $DB->get_record ( 'course', array ('id' => $id ), '*', MUST_EXIST );
$context = get_context_instance ( CONTEXT_COURSE, $course->id, MUST_EXIST ); $context = context_course::instance($course->id, MUST_EXIST);
require_login ( $course ); require_login ( $course );
require_capability ( 'moodle/course:enrolreview', $context ); require_capability ( 'moodle/course:enrolreview', $context );

2
edit.php

@ -17,7 +17,7 @@ $courseid = required_param('courseid', PARAM_INT);
$instanceid = optional_param('id', 0, PARAM_INT); // instanceid $instanceid = optional_param('id', 0, PARAM_INT); // instanceid
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
$context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST);
require_login($course); require_login($course);
require_capability('enrol/self:config', $context); require_capability('enrol/self:config', $context);

2
enroluser.php

@ -20,7 +20,7 @@ $extendbase = optional_param('extendbase', 3, PARAM_INT);
$instance = $DB->get_record('enrol', array('id'=>$enrolid, 'enrol'=>'apply'), '*', MUST_EXIST); $instance = $DB->get_record('enrol', array('id'=>$enrolid, 'enrol'=>'apply'), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST); $course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST);
$context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST);
require_login($course); require_login($course);
//require_capability('enrol/manual:enrol', $context); //require_capability('enrol/manual:enrol', $context);

6
lib.php

@ -17,7 +17,7 @@ class enrol_apply_plugin extends enrol_plugin {
} }
public function get_newinstance_link($courseid) { public function get_newinstance_link($courseid) {
$context = get_context_instance(CONTEXT_COURSE, $courseid, MUST_EXIST); $context = context_course::instance($courseid, MUST_EXIST);
if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/manual:config', $context)) { if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/manual:config', $context)) {
return NULL; return NULL;
@ -101,7 +101,7 @@ class enrol_apply_plugin extends enrol_plugin {
if ($instance->enrol !== 'apply') { if ($instance->enrol !== 'apply') {
throw new coding_exception('invalid enrol instance!'); throw new coding_exception('invalid enrol instance!');
} }
$context = get_context_instance(CONTEXT_COURSE, $instance->courseid); $context = context_course::instance($instance->courseid);
$icons = array(); $icons = array();
@ -216,7 +216,7 @@ function sendConfirmMailToTeachers($courseid,$desc){
if($apply_setting['sendmailtoteacher']->value == 1){ if($apply_setting['sendmailtoteacher']->value == 1){
$course = $DB->get_record('course',array('id'=>$courseid)); $course = $DB->get_record('course',array('id'=>$courseid));
$context = get_context_instance(CONTEXT_COURSE, $courseid, MUST_EXIST); $context = context_course::instance($courseid, MUST_EXIST);
$teacherType = $DB->get_record('role',array("shortname"=>"editingteacher")); $teacherType = $DB->get_record('role',array("shortname"=>"editingteacher"));
$teachers = $DB->get_records('role_assignments', array('contextid'=>$context->id,'roleid'=>$teacherType->id)); $teachers = $DB->get_records('role_assignments', array('contextid'=>$context->id,'roleid'=>$teacherType->id));
foreach($teachers as $teacher){ foreach($teachers as $teacher){

2
manage.php

@ -15,7 +15,7 @@ require_login();
require_capability('enrol/apply:manage', context_system::instance()); require_capability('enrol/apply:manage', context_system::instance());
$site = get_site (); $site = get_site ();
$systemcontext = get_context_instance ( CONTEXT_SYSTEM ); $systemcontext = context_system::instance();
$PAGE->set_url ( '/enrol/manage.php'); $PAGE->set_url ( '/enrol/manage.php');
$PAGE->set_context($systemcontext); $PAGE->set_context($systemcontext);

2
unenroluser.php

@ -50,7 +50,7 @@ if ($course->id == SITEID) {
// Obviously // Obviously
require_login($course); require_login($course);
// Make sure the user can unenrol self enrolled users. // Make sure the user can unenrol self enrolled users.
require_capability("enrol/self:unenrol", get_context_instance(CONTEXT_COURSE, $course->id)); require_capability("enrol/self:unenrol", context_course::instance($course->id));
// Get the enrolment manager for this course // Get the enrolment manager for this course
$manager = new course_enrolment_manager($PAGE, $course, $filter); $manager = new course_enrolment_manager($PAGE, $course, $filter);

Loading…
Cancel
Save