Commit ab7632b7 authored by sam marshall's avatar sam marshall
Browse files

MDL-39876 Change get_record('course') calls to get_course

parent 838d78a9
......@@ -39,7 +39,7 @@ if ($course) {
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
......
......@@ -35,7 +35,7 @@ if ($course) {
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
......
......@@ -36,7 +36,7 @@ if ($course) {
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
......
......@@ -43,7 +43,7 @@ if ($course) {
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
......
......@@ -32,7 +32,7 @@ $courseid = required_param('courseid', PARAM_INT);
// Validate them and get the corresponding objects.
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$course = get_course($courseid);
$usercontext = context_user::instance($user->id);
$coursecontext = context_course::instance($course->id);
......
......@@ -40,7 +40,7 @@ $PAGE->set_pagelayout('admin');
$id = $courseid;
$cm = null;
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
$course = get_course($courseid);
$type = backup::TYPE_1COURSE;
if (!is_null($sectionid)) {
$section = $DB->get_record('course_sections', array('course'=>$course->id, 'id'=>$sectionid), '*', MUST_EXIST);
......
......@@ -17,7 +17,7 @@ $searchcourses = optional_param('searchcourses', false, PARAM_BOOL);
$restoretarget = optional_param('target', backup::TARGET_CURRENT_ADDING, PARAM_INT);
// Load the course and context
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
$course = get_course($courseid);
$context = context_course::instance($courseid);
// Must pass login
......@@ -51,7 +51,7 @@ if ($importcourseid === false || $searchcourses) {
}
// Load the course +context to import from
$importcourse = $DB->get_record('course', array('id'=>$importcourseid), '*', MUST_EXIST);
$importcourse = get_course($importcourseid);
$importcontext = context_course::instance($importcourseid);
// Make sure the user can backup from that course
......
......@@ -148,7 +148,7 @@ class backup_section_task extends backup_task {
// All these are common settings to be shared by all sections
$section = $DB->get_record('course_sections', array('id' => $this->sectionid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST);
$course = get_course($section->course);
// Define section_included (to decide if the whole task must be really executed)
$settingname = $settingprefix . 'included';
......
......@@ -1632,7 +1632,7 @@ class restore_default_enrolments_step extends restore_execution_step {
public function define_execution() {
global $DB;
$course = $DB->get_record('course', array('id'=>$this->get_courseid()), '*', MUST_EXIST);
$course = get_course($this->get_courseid());
if ($DB->record_exists('enrol', array('courseid'=>$this->get_courseid(), 'enrol'=>'manual'))) {
// Something already added instances, do not add default instances.
......@@ -1849,7 +1849,7 @@ class restore_fix_restorer_access_step extends restore_execution_step {
return;
}
if (!$DB->record_exists('enrol', array('enrol'=>'manual', 'courseid'=>$courseid))) {
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
$course = get_course($courseid);
$fields = array('status'=>ENROL_INSTANCE_ENABLED, 'enrolperiod'=>$enrol->get_config('enrolperiod', 0), 'roleid'=>$enrol->get_config('roleid', 0));
$enrol->add_instance($course, $fields);
}
......
......@@ -109,7 +109,7 @@ abstract class backup_check {
$typecapstocheck = array();
switch ($type) {
case backup::TYPE_1COURSE :
$DB->get_record('course', array('id' => $id), '*', MUST_EXIST); // course exists
get_course($id); // course exists
$typecapstocheck['moodle/backup:backupcourse'] = $coursectx;
break;
case backup::TYPE_1SECTION :
......
......@@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
require_login();
$courseid = required_param('courseid', PARAM_INT); //if no courseid is given
$parentcourse = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$parentcourse = get_course($courseid);
$context = context_course::instance($courseid);
$PAGE->set_course($parentcourse);
......
......@@ -32,7 +32,7 @@ $id = required_param('course', PARAM_INT);
$userid = optional_param('user', 0, PARAM_INT);
// Load course.
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
$course = get_course($id);
// Load user.
if ($userid) {
......
......@@ -154,7 +154,7 @@ if ($courseid == SITEID) {
$courseid = 0;
}
if ($courseid) {
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$course = get_course($courseid);
$PAGE->set_course($course);
$context = $PAGE->context;
} else {
......
......@@ -36,7 +36,7 @@ if ($courseid == SITEID) {
$courseid = 0;
}
if ($courseid) {
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$course = get_course($courseid);
$PAGE->set_course($course);
$context = $PAGE->context;
} else {
......
......@@ -39,7 +39,7 @@ if ($courseid = SITEID) {
$courseid = 0;
}
if ($courseid) {
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$course = get_course($courseid);
$PAGE->set_course($course);
$context = $PAGE->context;
} else {
......
......@@ -81,7 +81,7 @@ $PAGE->set_url($url);
$PAGE->set_pagelayout('standard');
if ($courseid != SITEID && !empty($courseid)) {
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$course = get_course($courseid);
$courses = array($course->id => $course);
$issite = false;
} else {
......
......@@ -1817,7 +1817,7 @@ function calendar_get_allowed_types(&$allowed, $course = null) {
if (!empty($course)) {
if (!is_object($course)) {
$course = $DB->get_record('course', array('id' => $course), '*', MUST_EXIST);
$course = get_course($course);
}
if ($course->id != SITEID) {
$coursecontext = context_course::instance($course->id);
......
......@@ -7,7 +7,7 @@ require_once($CFG->dirroot.'/calendar/lib.php');
require_once($CFG->dirroot.'/calendar/preferences_form.php');
$courseid = required_param('course', PARAM_INT);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$course = get_course($courseid);
$PAGE->set_url(new moodle_url('/calendar/preferences.php', array('course' => $courseid)));
$PAGE->set_pagelayout('standard');
......
......@@ -30,7 +30,7 @@ require_once($CFG->dirroot.'/course/lib.php');
$courseid = required_param('courseid', PARAM_INT);
$increase = optional_param('increase', true, PARAM_BOOL);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$course = get_course($courseid);
$courseformatoptions = course_get_format($course)->get_format_options();
$PAGE->set_url('/course/changenumsections.php', array('courseid' => $courseid));
......
......@@ -460,7 +460,7 @@ class dndupload_ajax_processor {
throw new coding_exception('dndupload_ajax_processor should only be used within AJAX requests');
}
$this->course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$this->course = get_course($courseid);
require_login($this->course, false);
$this->context = context_course::instance($this->course->id);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment