Skip to content

Commit

Permalink
Revert "MDL-39876 Change get_record('course') calls to get_course"
Browse files Browse the repository at this point in the history
This reverts commit ab7632b.
  • Loading branch information
Damyon Wiese committed Aug 21, 2013
1 parent a101c7f commit 74df295
Show file tree
Hide file tree
Showing 189 changed files with 233 additions and 231 deletions.
2 changes: 1 addition & 1 deletion admin/roles/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/override.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/usersroles.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

// Validate them and get the corresponding objects.
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
$course = get_course($courseid);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);

$usercontext = context_user::instance($user->id);
$coursecontext = context_course::instance($course->id);
Expand Down
2 changes: 1 addition & 1 deletion backup/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

$id = $courseid;
$cm = null;
$course = get_course($courseid);
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
$type = backup::TYPE_1COURSE;
if (!is_null($sectionid)) {
$section = $DB->get_record('course_sections', array('course'=>$course->id, 'id'=>$sectionid), '*', MUST_EXIST);
Expand Down
4 changes: 2 additions & 2 deletions backup/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$restoretarget = optional_param('target', backup::TARGET_CURRENT_ADDING, PARAM_INT);

// Load the course and context
$course = get_course($courseid);
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
$context = context_course::instance($courseid);

// Must pass login
Expand Down Expand Up @@ -51,7 +51,7 @@
}

// Load the course +context to import from
$importcourse = get_course($importcourseid);
$importcourse = $DB->get_record('course', array('id'=>$importcourseid), '*', MUST_EXIST);
$importcontext = context_course::instance($importcourseid);

// Make sure the user can backup from that course
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/backup_section_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected function define_settings() {
// All these are common settings to be shared by all sections

$section = $DB->get_record('course_sections', array('id' => $this->sectionid), '*', MUST_EXIST);
$course = get_course($section->course);
$course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST);

// Define section_included (to decide if the whole task must be really executed)
$settingname = $settingprefix . 'included';
Expand Down
4 changes: 2 additions & 2 deletions backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,7 @@ class restore_default_enrolments_step extends restore_execution_step {
public function define_execution() {
global $DB;

$course = get_course($this->get_courseid());
$course = $DB->get_record('course', array('id'=>$this->get_courseid()), '*', MUST_EXIST);

if ($DB->record_exists('enrol', array('courseid'=>$this->get_courseid(), 'enrol'=>'manual'))) {
// Something already added instances, do not add default instances.
Expand Down Expand Up @@ -1849,7 +1849,7 @@ protected function define_execution() {
return;
}
if (!$DB->record_exists('enrol', array('enrol'=>'manual', 'courseid'=>$courseid))) {
$course = get_course($courseid);
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
$fields = array('status'=>ENROL_INSTANCE_ENABLED, 'enrolperiod'=>$enrol->get_config('enrolperiod', 0), 'roleid'=>$enrol->get_config('roleid', 0));
$enrol->add_instance($course, $fields);
}
Expand Down
2 changes: 1 addition & 1 deletion backup/util/checks/backup_check.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static function check_security($backup_controller, $apply) {
$typecapstocheck = array();
switch ($type) {
case backup::TYPE_1COURSE :
get_course($id); // course exists
$DB->get_record('course', array('id' => $id), '*', MUST_EXIST); // course exists
$typecapstocheck['moodle/backup:backupcourse'] = $coursectx;
break;
case backup::TYPE_1SECTION :
Expand Down
2 changes: 1 addition & 1 deletion blocks/community/communitycourse.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

require_login();
$courseid = required_param('courseid', PARAM_INT); //if no courseid is given
$parentcourse = get_course($courseid);
$parentcourse = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);

$context = context_course::instance($courseid);
$PAGE->set_course($parentcourse);
Expand Down
2 changes: 1 addition & 1 deletion blocks/completionstatus/details.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
$userid = optional_param('user', 0, PARAM_INT);

// Load course.
$course = get_course($id);
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);

// Load user.
if ($userid) {
Expand Down
2 changes: 1 addition & 1 deletion blocks/rss_client/editfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static function autodiscover_feed_url($url){
$courseid = 0;
}
if ($courseid) {
$course = get_course($courseid);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$PAGE->set_course($course);
$context = $PAGE->context;
} else {
Expand Down
2 changes: 1 addition & 1 deletion blocks/rss_client/managefeeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$courseid = 0;
}
if ($courseid) {
$course = get_course($courseid);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$PAGE->set_course($course);
$context = $PAGE->context;
} else {
Expand Down
2 changes: 1 addition & 1 deletion blocks/rss_client/viewfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$courseid = 0;
}
if ($courseid) {
$course = get_course($courseid);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$PAGE->set_course($course);
$context = $PAGE->context;
} else {
Expand Down
2 changes: 1 addition & 1 deletion calendar/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
$PAGE->set_pagelayout('standard');

if ($courseid != SITEID && !empty($courseid)) {
$course = get_course($courseid);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$courses = array($course->id => $course);
$issite = false;
} else {
Expand Down
2 changes: 1 addition & 1 deletion calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ function calendar_get_allowed_types(&$allowed, $course = null) {

if (!empty($course)) {
if (!is_object($course)) {
$course = get_course($course);
$course = $DB->get_record('course', array('id' => $course), '*', MUST_EXIST);
}
if ($course->id != SITEID) {
$coursecontext = context_course::instance($course->id);
Expand Down
2 changes: 1 addition & 1 deletion calendar/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once($CFG->dirroot.'/calendar/preferences_form.php');

$courseid = required_param('course', PARAM_INT);
$course = get_course($courseid);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);

$PAGE->set_url(new moodle_url('/calendar/preferences.php', array('course' => $courseid)));
$PAGE->set_pagelayout('standard');
Expand Down
2 changes: 1 addition & 1 deletion course/changenumsections.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

$courseid = required_param('courseid', PARAM_INT);
$increase = optional_param('increase', true, PARAM_BOOL);
$course = get_course($courseid);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$courseformatoptions = course_get_format($course)->get_format_options();

$PAGE->set_url('/course/changenumsections.php', array('courseid' => $courseid));
Expand Down
2 changes: 1 addition & 1 deletion course/dnduploadlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public function __construct($courseid, $section, $type, $modulename) {
throw new coding_exception('dndupload_ajax_processor should only be used within AJAX requests');
}

$this->course = get_course($courseid);
$this->course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);

require_login($this->course, false);
$this->context = context_course::instance($this->course->id);
Expand Down
2 changes: 1 addition & 1 deletion course/editsection.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$PAGE->set_url('/course/editsection.php', array('id'=>$id, 'sr'=> $sectionreturn));

$section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST);
$course = get_course($section->course);
$course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST);
$sectionnum = $section->section;

require_login($course);
Expand Down
8 changes: 4 additions & 4 deletions course/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ public static function get_course_contents_parameters() {
* @since Moodle 2.2
*/
public static function get_course_contents($courseid, $options = array()) {
global $CFG;
global $CFG, $DB;
require_once($CFG->dirroot . "/course/lib.php");

//validate parameter
$params = self::validate_parameters(self::get_course_contents_parameters(),
array('courseid' => $courseid, 'options' => $options));

//retrieve the course
$course = get_course($params['courseid']);
$course = $DB->get_record('course', array('id' => $params['courseid']), '*', MUST_EXIST);

//check course format exist
if (!file_exists($CFG->dirroot . '/course/format/' . $course->format . '/lib.php')) {
Expand Down Expand Up @@ -848,7 +848,7 @@ public static function delete_courses($courseids) {
$transaction = $DB->start_delegated_transaction();

foreach ($params['courseids'] as $courseid) {
$course = get_course($courseid);
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);

// Check if the context is valid.
$coursecontext = context_course::instance($course->id);
Expand Down Expand Up @@ -1077,7 +1077,7 @@ public static function duplicate_course($courseid, $fullname, $shortname, $categ
$rc->execute_plan();
$rc->destroy();

$course = get_course($newcourseid);
$course = $DB->get_record('course', array('id' => $newcourseid), '*', MUST_EXIST);
$course->fullname = $params['fullname'];
$course->shortname = $params['shortname'];
$course->visible = $params['visible'];
Expand Down
8 changes: 4 additions & 4 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3085,7 +3085,7 @@ function course_get_url($courseorid, $section = null, $options = array()) {
* @return object the created module info
*/
function create_module($moduleinfo) {
global $CFG;
global $DB, $CFG;

require_once($CFG->dirroot . '/course/modlib.php');

Expand All @@ -3101,7 +3101,7 @@ function create_module($moduleinfo) {
}

// Some additional checks (capability / existing instances).
$course = get_course($moduleinfo->course);
$course = $DB->get_record('course', array('id'=>$moduleinfo->course), '*', MUST_EXIST);
list($module, $context, $cw) = can_add_moduleinfo($course, $moduleinfo->modulename, $moduleinfo->section);

// Load module library.
Expand All @@ -3125,15 +3125,15 @@ function create_module($moduleinfo) {
* @return object the updated module info
*/
function update_module($moduleinfo) {
global $CFG;
global $DB, $CFG;

require_once($CFG->dirroot . '/course/modlib.php');

// Check the course module exists.
$cm = get_coursemodule_from_id('', $moduleinfo->coursemodule, 0, false, MUST_EXIST);

// Check the course exists.
$course = get_course($cm->course);
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);

// Some checks (capaibility / existing instances).
list($cm, $context, $module, $data, $cw) = can_update_moduleinfo($cm);
Expand Down
2 changes: 1 addition & 1 deletion course/loginas.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$userid = required_param('user', PARAM_INT);

require_sesskey();
$course = get_course($id);
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);

// User must be logged in.

Expand Down
4 changes: 2 additions & 2 deletions course/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@
if ((!empty($hide) or !empty($show)) && confirm_sesskey()) {
// Hide or show a course.
if (!empty($hide)) {
$course = get_course($hide);
$course = $DB->get_record('course', array('id' => $hide), '*', MUST_EXIST);
$visible = 0;
} else {
$course = get_course($show);
$course = $DB->get_record('course', array('id' => $show), '*', MUST_EXIST);
$visible = 1;
}
$coursecontext = context_course::instance($course->id);
Expand Down
18 changes: 9 additions & 9 deletions course/mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

} else if (!empty($duplicate)) {
$cm = get_coursemodule_from_id('', $duplicate, 0, true, MUST_EXIST);
$course = get_course($cm->course);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);

require_login($course, false, $cm);
$coursecontext = context_course::instance($course->id);
Expand Down Expand Up @@ -117,7 +117,7 @@

} else if (!empty($delete)) {
$cm = get_coursemodule_from_id('', $delete, 0, true, MUST_EXIST);
$course = get_course($cm->course);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);

require_login($course, false, $cm);
$modcontext = context_module::instance($cm->id);
Expand Down Expand Up @@ -158,7 +158,7 @@

if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
$cm = get_coursemodule_from_id('', $USER->activitycopy, 0, true, MUST_EXIST);
$course = get_course($cm->course);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);

require_login($course, false, $cm);
$coursecontext = context_course::instance($course->id);
Expand Down Expand Up @@ -198,7 +198,7 @@
$id = required_param('id', PARAM_INT);

$cm = get_coursemodule_from_id('', $id, 0, true, MUST_EXIST);
$course = get_course($cm->course);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);

require_login($course, false, $cm);
$coursecontext = context_course::instance($course->id);
Expand All @@ -219,7 +219,7 @@

} else if (!empty($hide) and confirm_sesskey()) {
$cm = get_coursemodule_from_id('', $hide, 0, true, MUST_EXIST);
$course = get_course($cm->course);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);

require_login($course, false, $cm);
$coursecontext = context_course::instance($course->id);
Expand All @@ -232,7 +232,7 @@

} else if (!empty($show) and confirm_sesskey()) {
$cm = get_coursemodule_from_id('', $show, 0, true, MUST_EXIST);
$course = get_course($cm->course);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);

require_login($course, false, $cm);
$coursecontext = context_course::instance($course->id);
Expand All @@ -253,7 +253,7 @@
$id = required_param('id', PARAM_INT);

$cm = get_coursemodule_from_id('', $id, 0, true, MUST_EXIST);
$course = get_course($cm->course);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);

require_login($course, false, $cm);
$coursecontext = context_course::instance($course->id);
Expand All @@ -266,7 +266,7 @@

} else if (!empty($copy) and confirm_sesskey()) { // value = course module
$cm = get_coursemodule_from_id('', $copy, 0, true, MUST_EXIST);
$course = get_course($cm->course);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);

require_login($course, false, $cm);
$coursecontext = context_course::instance($course->id);
Expand All @@ -285,7 +285,7 @@
} else if (!empty($cancelcopy) and confirm_sesskey()) { // value = course module

$courseid = $USER->activitycopycourse;
$course = get_course($courseid);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);

$cm = get_coursemodule_from_id('', $USER->activitycopy, 0, true, IGNORE_MISSING);
$sectionreturn = $USER->activitycopysectionreturn;
Expand Down
2 changes: 1 addition & 1 deletion course/modduplicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$courseid = required_param('course', PARAM_INT);
$sectionreturn = optional_param('sr', null, PARAM_INT);

$course = get_course($courseid);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$cm = get_coursemodule_from_id('', $cmid, $course->id, true, MUST_EXIST);
$cmcontext = context_module::instance($cm->id);
$context = context_course::instance($courseid);
Expand Down
Loading

0 comments on commit 74df295

Please sign in to comment.