From 74df2951d1e718391b1b31d6e9ea394ab0b0b1ac Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Wed, 21 Aug 2013 13:42:30 +0800 Subject: [PATCH] Revert "MDL-39876 Change get_record('course') calls to get_course" This reverts commit ab7632b74c331540c90229bf03d13aa2e6bdd9be. --- admin/roles/assign.php | 2 +- admin/roles/check.php | 2 +- admin/roles/override.php | 2 +- admin/roles/permissions.php | 2 +- admin/roles/usersroles.php | 2 +- backup/backup.php | 2 +- backup/import.php | 4 ++-- backup/moodle2/backup_section_task.class.php | 2 +- backup/moodle2/restore_stepslib.php | 4 ++-- backup/util/checks/backup_check.class.php | 2 +- blocks/community/communitycourse.php | 2 +- blocks/completionstatus/details.php | 2 +- blocks/rss_client/editfeed.php | 2 +- blocks/rss_client/managefeeds.php | 2 +- blocks/rss_client/viewfeed.php | 2 +- calendar/event.php | 2 +- calendar/lib.php | 2 +- calendar/preferences.php | 2 +- course/changenumsections.php | 2 +- course/dnduploadlib.php | 2 +- course/editsection.php | 2 +- course/externallib.php | 8 ++++---- course/lib.php | 8 ++++---- course/loginas.php | 2 +- course/manage.php | 4 ++-- course/mod.php | 18 +++++++++--------- course/modduplicate.php | 2 +- course/modedit.php | 4 ++-- course/publish/backup.php | 2 +- course/publish/hubselector.php | 2 +- course/publish/index.php | 2 +- course/publish/metadata.php | 2 +- course/report.php | 2 +- course/resources.php | 2 +- course/rest.php | 2 +- course/togglecompletion.php | 4 ++-- course/user.php | 2 +- enrol/ajax.php | 2 +- enrol/bulkchange.php | 2 +- enrol/cohort/ajax.php | 2 +- enrol/cohort/edit.php | 2 +- enrol/editenrolment.php | 2 +- enrol/externallib.php | 4 ++-- enrol/guest/addinstance.php | 2 +- enrol/index.php | 2 +- enrol/instances.php | 2 +- enrol/manual/ajax.php | 2 +- enrol/manual/edit.php | 2 +- enrol/manual/locallib.php | 2 +- enrol/manual/manage.php | 2 +- enrol/manual/unenrolself.php | 2 +- enrol/meta/addinstance.php | 2 +- enrol/mnet/addinstance.php | 2 +- enrol/otherusers.php | 2 +- enrol/paypal/edit.php | 2 +- enrol/paypal/unenrolself.php | 2 +- enrol/self/edit.php | 2 +- enrol/self/lib.php | 2 +- enrol/self/unenrolself.php | 2 +- enrol/unenroluser.php | 2 +- enrol/users.php | 2 +- file.php | 2 +- grade/edit/outcome/course.php | 2 +- grade/edit/outcome/edit.php | 2 +- grade/edit/outcome/index.php | 2 +- group/import.php | 2 +- group/index.php | 2 +- group/lib.php | 2 +- group/members.php | 2 +- lib/accesslib.php | 10 ++++++---- lib/db/install.php | 2 +- lib/modinfolib.php | 2 +- lib/moodlelib.php | 4 ++-- lib/navigationlib.php | 2 +- lib/pagelib.php | 2 +- lib/tests/accesslib_test.php | 4 ++-- mod/assign/index.php | 2 +- mod/assign/lib.php | 2 +- mod/assign/locallib.php | 2 +- mod/assign/mod_form.php | 4 ++-- mod/assign/view.php | 2 +- mod/book/delete.php | 2 +- mod/book/edit.php | 2 +- mod/book/index.php | 2 +- mod/book/move.php | 2 +- mod/book/show.php | 2 +- mod/book/tool/exportimscp/index.php | 2 +- mod/book/tool/importhtml/index.php | 2 +- mod/book/tool/print/index.php | 2 +- mod/book/view.php | 4 ++-- mod/chat/gui_ajax/index.php | 2 +- mod/data/import.php | 4 ++-- mod/data/lib.php | 2 +- mod/data/preset.php | 4 ++-- mod/feedback/ajax.php | 2 +- mod/folder/edit.php | 2 +- mod/folder/index.php | 2 +- mod/folder/view.php | 2 +- mod/forum/discuss.php | 2 +- mod/forum/lib.php | 2 +- mod/forum/subscribe.php | 2 +- mod/forum/subscribers.php | 2 +- mod/forum/user.php | 2 +- mod/glossary/approve.php | 2 +- mod/glossary/rsslib.php | 2 +- mod/glossary/showentry.php | 6 +++--- mod/glossary/showentry_ajax.php | 6 +++--- mod/imscp/index.php | 2 +- mod/imscp/view.php | 2 +- mod/lesson/continue.php | 2 +- mod/lesson/edit.php | 2 +- mod/lesson/editpage.php | 2 +- mod/lesson/essay.php | 2 +- mod/lesson/grade.php | 2 +- mod/lesson/highscores.php | 2 +- mod/lesson/import.php | 2 +- mod/lesson/lesson.php | 2 +- mod/lesson/mediafile.php | 2 +- mod/lesson/report.php | 2 +- mod/lesson/view.php | 2 +- mod/lti/grade.php | 2 +- mod/lti/index.php | 2 +- mod/lti/launch.php | 2 +- mod/lti/view.php | 2 +- mod/page/index.php | 2 +- mod/page/view.php | 2 +- mod/quiz/attemptlib.php | 4 ++-- mod/quiz/cronlib.php | 2 +- mod/quiz/grade.php | 2 +- mod/quiz/overridedelete.php | 2 +- mod/quiz/overrideedit.php | 2 +- mod/quiz/overrides.php | 2 +- mod/resource/index.php | 2 +- mod/resource/view.php | 2 +- mod/scorm/datamodels/sequencinghandler.php | 4 ++-- mod/scorm/loaddatamodel.php | 4 ++-- mod/scorm/report.php | 2 +- mod/scorm/report/graphs/graph.php | 2 +- mod/scorm/userreport.php | 4 ++-- mod/url/index.php | 2 +- mod/url/lib.php | 2 +- mod/url/view.php | 2 +- mod/wiki/admin.php | 2 +- mod/wiki/comments.php | 2 +- mod/wiki/create.php | 2 +- mod/wiki/diff.php | 2 +- mod/wiki/edit.php | 2 +- mod/wiki/editcomments.php | 2 +- mod/wiki/files.php | 2 +- mod/wiki/filesedit.php | 2 +- mod/wiki/history.php | 2 +- mod/wiki/instancecomments.php | 2 +- mod/wiki/lock.php | 2 +- mod/wiki/map.php | 2 +- mod/wiki/overridelocks.php | 2 +- mod/wiki/prettyview.php | 2 +- mod/wiki/restoreversion.php | 2 +- mod/wiki/view.php | 8 ++++---- mod/wiki/viewversion.php | 2 +- mod/workshop/aggregate.php | 2 +- mod/workshop/allocation.php | 2 +- mod/workshop/allocation/scheduled/lib.php | 2 +- mod/workshop/assessment.php | 2 +- mod/workshop/editform.php | 2 +- mod/workshop/editformpreview.php | 2 +- mod/workshop/exassessment.php | 2 +- mod/workshop/excompare.php | 2 +- mod/workshop/exsubmission.php | 2 +- mod/workshop/index.php | 2 +- mod/workshop/lib.php | 2 +- mod/workshop/submission.php | 2 +- mod/workshop/switchphase.php | 2 +- mod/workshop/toolbox.php | 2 +- mod/workshop/view.php | 4 ++-- notes/index.php | 2 +- report/completion/index.php | 2 +- report/completion/user.php | 2 +- report/log/graph.php | 2 +- report/log/index.php | 2 +- report/log/user.php | 2 +- report/loglive/index.php | 2 +- report/outline/index.php | 2 +- report/outline/user.php | 2 +- report/stats/graph.php | 2 +- report/stats/user.php | 2 +- user/editadvanced.php | 2 +- user/index.php | 4 ++-- user/repository.php | 2 +- user/view.php | 2 +- 189 files changed, 233 insertions(+), 231 deletions(-) diff --git a/admin/roles/assign.php b/admin/roles/assign.php index 6549125c7f2a4..cce23341f3d28 100644 --- a/admin/roles/assign.php +++ b/admin/roles/assign.php @@ -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); diff --git a/admin/roles/check.php b/admin/roles/check.php index b1da3f5764cc3..0590165264dcd 100644 --- a/admin/roles/check.php +++ b/admin/roles/check.php @@ -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); diff --git a/admin/roles/override.php b/admin/roles/override.php index 35d81647c0c39..bc506f191ea03 100644 --- a/admin/roles/override.php +++ b/admin/roles/override.php @@ -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); diff --git a/admin/roles/permissions.php b/admin/roles/permissions.php index cacc6544ecf5c..cfff956177acd 100644 --- a/admin/roles/permissions.php +++ b/admin/roles/permissions.php @@ -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); diff --git a/admin/roles/usersroles.php b/admin/roles/usersroles.php index 184576596f033..c62c979a67336 100644 --- a/admin/roles/usersroles.php +++ b/admin/roles/usersroles.php @@ -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); diff --git a/backup/backup.php b/backup/backup.php index b8a52b967d340..cfe16efb36483 100644 --- a/backup/backup.php +++ b/backup/backup.php @@ -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); diff --git a/backup/import.php b/backup/import.php index 527d103f926e0..fbd919a583cb6 100644 --- a/backup/import.php +++ b/backup/import.php @@ -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 @@ -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 diff --git a/backup/moodle2/backup_section_task.class.php b/backup/moodle2/backup_section_task.class.php index 0144cffd818fa..b84d3388cd33a 100644 --- a/backup/moodle2/backup_section_task.class.php +++ b/backup/moodle2/backup_section_task.class.php @@ -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'; diff --git a/backup/moodle2/restore_stepslib.php b/backup/moodle2/restore_stepslib.php index 84f6b2322fb56..2b6cdabd6560d 100644 --- a/backup/moodle2/restore_stepslib.php +++ b/backup/moodle2/restore_stepslib.php @@ -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. @@ -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); } diff --git a/backup/util/checks/backup_check.class.php b/backup/util/checks/backup_check.class.php index dc510ac96b467..164da0b38569a 100644 --- a/backup/util/checks/backup_check.class.php +++ b/backup/util/checks/backup_check.class.php @@ -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 : diff --git a/blocks/community/communitycourse.php b/blocks/community/communitycourse.php index 62d18930c7044..fe21d76b15f19 100644 --- a/blocks/community/communitycourse.php +++ b/blocks/community/communitycourse.php @@ -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); diff --git a/blocks/completionstatus/details.php b/blocks/completionstatus/details.php index bcb17397ac4d9..be4cd2fd4c093 100644 --- a/blocks/completionstatus/details.php +++ b/blocks/completionstatus/details.php @@ -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) { diff --git a/blocks/rss_client/editfeed.php b/blocks/rss_client/editfeed.php index 2bafefe2cb141..110c4d2e555bc 100644 --- a/blocks/rss_client/editfeed.php +++ b/blocks/rss_client/editfeed.php @@ -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 { diff --git a/blocks/rss_client/managefeeds.php b/blocks/rss_client/managefeeds.php index 12126059d4c84..2252bc9874ecd 100644 --- a/blocks/rss_client/managefeeds.php +++ b/blocks/rss_client/managefeeds.php @@ -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 { diff --git a/blocks/rss_client/viewfeed.php b/blocks/rss_client/viewfeed.php index f269496f6bf00..1c287d703c58f 100644 --- a/blocks/rss_client/viewfeed.php +++ b/blocks/rss_client/viewfeed.php @@ -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 { diff --git a/calendar/event.php b/calendar/event.php index f0b1bd95fcc30..027527bf9dc05 100644 --- a/calendar/event.php +++ b/calendar/event.php @@ -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 { diff --git a/calendar/lib.php b/calendar/lib.php index 00e31741d8aaa..7fed0c0ee76b4 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -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); diff --git a/calendar/preferences.php b/calendar/preferences.php index 7114d711f81af..165466d6479ae 100644 --- a/calendar/preferences.php +++ b/calendar/preferences.php @@ -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'); diff --git a/course/changenumsections.php b/course/changenumsections.php index f11728b945f41..deed3670e85f7 100644 --- a/course/changenumsections.php +++ b/course/changenumsections.php @@ -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)); diff --git a/course/dnduploadlib.php b/course/dnduploadlib.php index 506a778553f35..917d67051f62d 100644 --- a/course/dnduploadlib.php +++ b/course/dnduploadlib.php @@ -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); diff --git a/course/editsection.php b/course/editsection.php index 08e0e1308db69..54db9394333bf 100644 --- a/course/editsection.php +++ b/course/editsection.php @@ -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); diff --git a/course/externallib.php b/course/externallib.php index 65881ea5c98ff..61232fd769c35 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -67,7 +67,7 @@ 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 @@ -75,7 +75,7 @@ public static function get_course_contents($courseid, $options = array()) { 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')) { @@ -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); @@ -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']; diff --git a/course/lib.php b/course/lib.php index d2c843158e925..e1e12409f756b 100644 --- a/course/lib.php +++ b/course/lib.php @@ -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'); @@ -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. @@ -3125,7 +3125,7 @@ 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'); @@ -3133,7 +3133,7 @@ function update_module($moduleinfo) { $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); diff --git a/course/loginas.php b/course/loginas.php index a608a728eb778..97f7d2a81efea 100644 --- a/course/loginas.php +++ b/course/loginas.php @@ -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. diff --git a/course/manage.php b/course/manage.php index ae94e07d8a2ab..4888c0a49603f 100644 --- a/course/manage.php +++ b/course/manage.php @@ -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); diff --git a/course/mod.php b/course/mod.php index 12f2dfc2249a7..1ea8b78cc8c59 100644 --- a/course/mod.php +++ b/course/mod.php @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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; diff --git a/course/modduplicate.php b/course/modduplicate.php index 6432b20fdf7d6..72476713468c6 100644 --- a/course/modduplicate.php +++ b/course/modduplicate.php @@ -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); diff --git a/course/modedit.php b/course/modedit.php index 5918614d04925..8cfe0a0afd74c 100644 --- a/course/modedit.php +++ b/course/modedit.php @@ -53,7 +53,7 @@ $url->param('course', $course); $PAGE->set_url($url); - $course = get_course($course); + $course = $DB->get_record('course', array('id'=>$course), '*', MUST_EXIST); require_login($course); list($module, $context, $cw) = can_add_moduleinfo($course, $add, $section); @@ -124,7 +124,7 @@ $cm = get_coursemodule_from_id('', $update, 0, false, MUST_EXIST); // Check the course exists. - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); // require_login require_login($course, false, $cm); // needed to setup proper $COURSE diff --git a/course/publish/backup.php b/course/publish/backup.php index d5cc3135e51dd..15e091ad7a2d5 100644 --- a/course/publish/backup.php +++ b/course/publish/backup.php @@ -45,7 +45,7 @@ $hubname = optional_param('hubname', '', PARAM_TEXT); //some permissions and parameters checking -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); require_login($course); if (!has_capability('moodle/course:publish', context_course::instance($id)) or !confirm_sesskey()) { diff --git a/course/publish/hubselector.php b/course/publish/hubselector.php index 74181c291f9dc..095e33be0e7c2 100644 --- a/course/publish/hubselector.php +++ b/course/publish/hubselector.php @@ -30,7 +30,7 @@ require_once($CFG->dirroot.'/course/publish/forms.php'); $id = required_param('id', PARAM_INT); -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); require_login($course); $PAGE->set_url('/course/publish/hubselector.php', array('id' => $course->id)); diff --git a/course/publish/index.php b/course/publish/index.php index b100fbe4fe372..2e11f5bdf7e38 100644 --- a/course/publish/index.php +++ b/course/publish/index.php @@ -34,7 +34,7 @@ $hubname = optional_param('hubname', 0, PARAM_TEXT); $huburl = optional_param('huburl', 0, PARAM_URL); -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); require_login($course); $context = context_course::instance($course->id); diff --git a/course/publish/metadata.php b/course/publish/metadata.php index 4e5e1fc4cd728..298e5f3e1d468 100644 --- a/course/publish/metadata.php +++ b/course/publish/metadata.php @@ -40,7 +40,7 @@ //check user access capability to this page $id = required_param('id', PARAM_INT); -$course = get_course($id); +$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); require_login($course); //page settings diff --git a/course/report.php b/course/report.php index d604d66c6ca43..90b51b800fea5 100644 --- a/course/report.php +++ b/course/report.php @@ -4,7 +4,7 @@ require_once('../config.php'); $id = required_param('id', PARAM_INT); // course id to import TO - $course = get_course($id); + $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $PAGE->set_pagelayout('standard'); require_login($course); diff --git a/course/resources.php b/course/resources.php index 45e94a9e96c7c..d0235f5496036 100644 --- a/course/resources.php +++ b/course/resources.php @@ -28,7 +28,7 @@ $id = required_param('id', PARAM_INT); // course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $PAGE->set_pagelayout('course'); require_course_login($course, true); diff --git a/course/rest.php b/course/rest.php index a9265115740fb..4bae0b0e596f8 100644 --- a/course/rest.php +++ b/course/rest.php @@ -49,7 +49,7 @@ //NOTE: when making any changes here please make sure it is using the same access control as course/mod.php !! -$course = get_course($courseid); +$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); // Check user is logged in and set contexts if we are dealing with resource if (in_array($class, array('resource'))) { $cm = get_coursemodule_from_id(null, $id, $course->id, false, MUST_EXIST); diff --git a/course/togglecompletion.php b/course/togglecompletion.php index 6c58d7bca4bd6..53992db8c6c4c 100644 --- a/course/togglecompletion.php +++ b/course/togglecompletion.php @@ -40,7 +40,7 @@ $PAGE->set_url(new moodle_url('/course/togglecompletion.php', array('course'=>$courseid))); // Check user is logged in - $course = get_course($courseid); + $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); $context = context_course::instance($course->id); require_login($course); @@ -129,7 +129,7 @@ // Get course-modules entry $cm = get_coursemodule_from_id(null, $cmid, null, true, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); // Check user is logged in require_login($course, false, $cm); diff --git a/course/user.php b/course/user.php index 49c5859feff76..73839e183b2c9 100644 --- a/course/user.php +++ b/course/user.php @@ -31,7 +31,7 @@ $url = new moodle_url('/course/user.php', array('id'=>$id,'user'=>$user, 'mode'=>$mode)); -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $user = $DB->get_record("user", array("id"=>$user, 'deleted'=>0), '*', MUST_EXIST); if ($mode === 'outline' or $mode === 'complete') { diff --git a/enrol/ajax.php b/enrol/ajax.php index 21c86c936e60f..2d41a9892c1c9 100644 --- a/enrol/ajax.php +++ b/enrol/ajax.php @@ -38,7 +38,7 @@ $PAGE->set_url(new moodle_url('/enrol/ajax.php', array('id'=>$id, 'action'=>$action))); -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); if ($course->id == SITEID) { diff --git a/enrol/bulkchange.php b/enrol/bulkchange.php index c5f1ea97c0e0a..1d451ae209806 100644 --- a/enrol/bulkchange.php +++ b/enrol/bulkchange.php @@ -34,7 +34,7 @@ $action = optional_param('action', '', PARAM_ALPHANUMEXT); $filter = optional_param('ifilter', 0, PARAM_INT); -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); if ($course->id == SITEID) { diff --git a/enrol/cohort/ajax.php b/enrol/cohort/ajax.php index ec58e6594deeb..e987f87fb372b 100644 --- a/enrol/cohort/ajax.php +++ b/enrol/cohort/ajax.php @@ -38,7 +38,7 @@ $PAGE->set_url(new moodle_url('/enrol/cohort/ajax.php', array('id'=>$id, 'action'=>$action))); -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); if ($course->id == SITEID) { diff --git a/enrol/cohort/edit.php b/enrol/cohort/edit.php index 99c90b8971eb1..050bdff56c027 100644 --- a/enrol/cohort/edit.php +++ b/enrol/cohort/edit.php @@ -30,7 +30,7 @@ $courseid = required_param('courseid', PARAM_INT); $instanceid = optional_param('id', 0, PARAM_INT); -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login($course); diff --git a/enrol/editenrolment.php b/enrol/editenrolment.php index 6fa1016e57e17..8b6f54efe1153 100644 --- a/enrol/editenrolment.php +++ b/enrol/editenrolment.php @@ -38,7 +38,7 @@ $ue = $DB->get_record('user_enrolments', array('id' => $ueid), '*', MUST_EXIST); $user = $DB->get_record('user', array('id'=>$ue->userid), '*', MUST_EXIST); $instance = $DB->get_record('enrol', array('id'=>$ue->enrolid), '*', MUST_EXIST); -$course = get_course($instance->courseid); +$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST); // The URL of the enrolled users page for the course. $usersurl = new moodle_url('/enrol/users.php', array('id' => $course->id)); diff --git a/enrol/externallib.php b/enrol/externallib.php index 980e3d5ccc300..ddfb976b384c2 100644 --- a/enrol/externallib.php +++ b/enrol/externallib.php @@ -124,7 +124,7 @@ public static function get_enrolled_users_with_capability($coursecapabilities, $ foreach ($params['coursecapabilities'] as $coursecapability) { $courseid = $coursecapability['courseid']; - $course = get_course($courseid); + $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $coursecontext = context_course::instance($courseid); if (!$coursecontext) { throw new moodle_exception('cannotfindcourse', 'error', '', null, @@ -423,7 +423,7 @@ public static function get_enrolled_users($courseid, $options = array()) { } } - $course = get_course($courseid); + $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $coursecontext = context_course::instance($courseid, IGNORE_MISSING); if ($courseid == SITEID) { $context = context_system::instance(); diff --git a/enrol/guest/addinstance.php b/enrol/guest/addinstance.php index 51770dc882cad..faa0531a4c29f 100644 --- a/enrol/guest/addinstance.php +++ b/enrol/guest/addinstance.php @@ -26,7 +26,7 @@ $id = required_param('id', PARAM_INT); // course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login($course); diff --git a/enrol/index.php b/enrol/index.php index 6bf65c3661d7c..d0e91b5344395 100644 --- a/enrol/index.php +++ b/enrol/index.php @@ -33,7 +33,7 @@ redirect(get_login_url()); } -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); // Everybody is enrolled on the frontpage diff --git a/enrol/instances.php b/enrol/instances.php index bdc233832acf5..0ad5d2c427dad 100644 --- a/enrol/instances.php +++ b/enrol/instances.php @@ -29,7 +29,7 @@ $instanceid = optional_param('instance', 0, PARAM_INT); $confirm = optional_param('confirm', 0, PARAM_BOOL); -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); if ($course->id == SITEID) { diff --git a/enrol/manual/ajax.php b/enrol/manual/ajax.php index 18f4a25ac686e..c1a6f80c9b374 100644 --- a/enrol/manual/ajax.php +++ b/enrol/manual/ajax.php @@ -36,7 +36,7 @@ $PAGE->set_url(new moodle_url('/enrol/ajax.php', array('id'=>$id, 'action'=>$action))); -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); if ($course->id == SITEID) { diff --git a/enrol/manual/edit.php b/enrol/manual/edit.php index 12c8aeee37f4a..d6d01e2d12304 100644 --- a/enrol/manual/edit.php +++ b/enrol/manual/edit.php @@ -28,7 +28,7 @@ $courseid = required_param('courseid', PARAM_INT); -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login($course); diff --git a/enrol/manual/locallib.php b/enrol/manual/locallib.php index 067131f79f529..5c3e3459361c4 100644 --- a/enrol/manual/locallib.php +++ b/enrol/manual/locallib.php @@ -389,7 +389,7 @@ function enrol_manual_migrate_plugin_enrolments($enrol) { $minstance = false; if (!$e->mid) { // Manual instance does not exist yet, add a new one. - $course = get_course($e->courseid); + $course = $DB->get_record('course', array('id'=>$e->courseid), '*', MUST_EXIST); if ($minstance = $DB->get_record('enrol', array('courseid'=>$course->id, 'enrol'=>'manual'))) { // Already created by previous iteration. $e->mid = $minstance->id; diff --git a/enrol/manual/manage.php b/enrol/manual/manage.php index 76892cde4c7c2..7d91e4b6017ba 100644 --- a/enrol/manual/manage.php +++ b/enrol/manual/manage.php @@ -31,7 +31,7 @@ $extendbase = optional_param('extendbase', 3, PARAM_INT); $instance = $DB->get_record('enrol', array('id'=>$enrolid, 'enrol'=>'manual'), '*', MUST_EXIST); -$course = get_course($instance->courseid); +$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login($course); diff --git a/enrol/manual/unenrolself.php b/enrol/manual/unenrolself.php index 472fcf0fa354b..c7304fb5f5805 100644 --- a/enrol/manual/unenrolself.php +++ b/enrol/manual/unenrolself.php @@ -28,7 +28,7 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); $instance = $DB->get_record('enrol', array('id'=>$enrolid, 'enrol'=>'manual'), '*', MUST_EXIST); -$course = get_course($instance->courseid); +$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login(); diff --git a/enrol/meta/addinstance.php b/enrol/meta/addinstance.php index cfcb20b70c171..ac2f2ff3cec9e 100644 --- a/enrol/meta/addinstance.php +++ b/enrol/meta/addinstance.php @@ -28,7 +28,7 @@ $id = required_param('id', PARAM_INT); // course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); $PAGE->set_url('/enrol/meta/addinstance.php', array('id'=>$course->id)); diff --git a/enrol/mnet/addinstance.php b/enrol/mnet/addinstance.php index 2dbf0a938f373..9678b400bf5eb 100644 --- a/enrol/mnet/addinstance.php +++ b/enrol/mnet/addinstance.php @@ -28,7 +28,7 @@ $id = required_param('id', PARAM_INT); // course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login($course); diff --git a/enrol/otherusers.php b/enrol/otherusers.php index 7052bcdba56e7..063d5b4ec04f6 100644 --- a/enrol/otherusers.php +++ b/enrol/otherusers.php @@ -31,7 +31,7 @@ $action = optional_param('action', '', PARAM_ALPHANUMEXT); $filter = optional_param('ifilter', 0, PARAM_INT); -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login($course); diff --git a/enrol/paypal/edit.php b/enrol/paypal/edit.php index 52a111a471797..6175b3bc440c0 100644 --- a/enrol/paypal/edit.php +++ b/enrol/paypal/edit.php @@ -29,7 +29,7 @@ $courseid = required_param('courseid', PARAM_INT); $instanceid = optional_param('id', 0, PARAM_INT); // instanceid -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login($course); diff --git a/enrol/paypal/unenrolself.php b/enrol/paypal/unenrolself.php index a3050045bc5e0..8fd16d264c2e7 100644 --- a/enrol/paypal/unenrolself.php +++ b/enrol/paypal/unenrolself.php @@ -28,7 +28,7 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); $instance = $DB->get_record('enrol', array('id'=>$enrolid, 'enrol'=>'paypal'), '*', MUST_EXIST); -$course = get_course($instance->courseid); +$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login(); diff --git a/enrol/self/edit.php b/enrol/self/edit.php index c88553e827354..a339b8e4b1b63 100644 --- a/enrol/self/edit.php +++ b/enrol/self/edit.php @@ -29,7 +29,7 @@ $courseid = required_param('courseid', PARAM_INT); $instanceid = optional_param('id', 0, PARAM_INT); -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login($course); diff --git a/enrol/self/lib.php b/enrol/self/lib.php index c82359553ee74..9b0fa481fccd5 100644 --- a/enrol/self/lib.php +++ b/enrol/self/lib.php @@ -397,7 +397,7 @@ public function get_instance_defaults() { protected function email_welcome_message($instance, $user) { global $CFG, $DB; - $course = get_course($instance->courseid); + $course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST); $context = context_course::instance($course->id); $a = new stdClass(); diff --git a/enrol/self/unenrolself.php b/enrol/self/unenrolself.php index 906d0728d74c6..7e7d269042b05 100644 --- a/enrol/self/unenrolself.php +++ b/enrol/self/unenrolself.php @@ -28,7 +28,7 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); $instance = $DB->get_record('enrol', array('id'=>$enrolid, 'enrol'=>'self'), '*', MUST_EXIST); -$course = get_course($instance->courseid); +$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login(); diff --git a/enrol/unenroluser.php b/enrol/unenroluser.php index 8428dcb708090..99033919001d0 100644 --- a/enrol/unenroluser.php +++ b/enrol/unenroluser.php @@ -36,7 +36,7 @@ $ue = $DB->get_record('user_enrolments', array('id' => $ueid), '*', MUST_EXIST); $user = $DB->get_record('user', array('id'=>$ue->userid), '*', MUST_EXIST); $instance = $DB->get_record('enrol', array('id'=>$ue->enrolid), '*', MUST_EXIST); -$course = get_course($instance->courseid); +$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST); $context = context_course::instance($course->id); diff --git a/enrol/users.php b/enrol/users.php index 78d0d53f878ae..c01e361fe383e 100644 --- a/enrol/users.php +++ b/enrol/users.php @@ -41,7 +41,7 @@ redirect('users.php?id=' . $id); } -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); if ($course->id == SITEID) { diff --git a/file.php b/file.php index 410a835e13ad7..fce3f788ec18f 100644 --- a/file.php +++ b/file.php @@ -63,7 +63,7 @@ $relativepath = implode('/', $args); // security: limit access to existing course subdirectories -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); if ($course->legacyfiles != 2) { // course files disabled diff --git a/grade/edit/outcome/course.php b/grade/edit/outcome/course.php index 0bdcf8806c45f..b23dc998d9c2d 100644 --- a/grade/edit/outcome/course.php +++ b/grade/edit/outcome/course.php @@ -30,7 +30,7 @@ $PAGE->set_url('/grade/edit/outcome/course.php', array('id'=>$courseid)); -$course = get_course($courseid); +$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); /// Make sure they can even access this course require_login($course); diff --git a/grade/edit/outcome/edit.php b/grade/edit/outcome/edit.php index f5aa23450741f..2d2c670c68521 100644 --- a/grade/edit/outcome/edit.php +++ b/grade/edit/outcome/edit.php @@ -75,7 +75,7 @@ } else if ($courseid){ $heading = get_string('addoutcome', 'grades'); /// adding new outcome from course - $course = get_course($courseid); + $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); require_login($course); $context = context_course::instance($course->id); require_capability('moodle/grade:manage', $context); diff --git a/grade/edit/outcome/index.php b/grade/edit/outcome/index.php index 81bbe3f5a1cd4..658d5cea936fe 100644 --- a/grade/edit/outcome/index.php +++ b/grade/edit/outcome/index.php @@ -34,7 +34,7 @@ /// Make sure they can even access this course if ($courseid) { - $course = get_course($courseid); + $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); require_login($course); $context = context_course::instance($course->id); require_capability('moodle/grade:manageoutcomes', $context); diff --git a/group/import.php b/group/import.php index 756533fc6699a..a4d351bffdbeb 100644 --- a/group/import.php +++ b/group/import.php @@ -30,7 +30,7 @@ $id = required_param('id', PARAM_INT); // Course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $PAGE->set_url('/group/import.php', array('id'=>$id)); diff --git a/group/index.php b/group/index.php index e5fe0422f107d..15116190e2c32 100644 --- a/group/index.php +++ b/group/index.php @@ -42,7 +42,7 @@ // Get the course information so we can print the header and // check the course id is valid -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $url = new moodle_url('/group/index.php', array('id'=>$courseid)); if ($userid) { diff --git a/group/lib.php b/group/lib.php index 4477cff76ac5c..f3f2f7e797a31 100644 --- a/group/lib.php +++ b/group/lib.php @@ -218,7 +218,7 @@ function groups_create_group($data, $editform = false, $editoroptions = false) { global $CFG, $DB; //check that courseid exists - $course = get_course($data->courseid); + $course = $DB->get_record('course', array('id' => $data->courseid), '*', MUST_EXIST); $context = context_course::instance($course->id); $data->timecreated = time(); diff --git a/group/members.php b/group/members.php index 91a786f9b00a6..9a013bde6967f 100644 --- a/group/members.php +++ b/group/members.php @@ -32,7 +32,7 @@ $cancel = optional_param('cancel', false, PARAM_BOOL); $group = $DB->get_record('groups', array('id'=>$groupid), '*', MUST_EXIST); -$course = get_course($group->courseid); +$course = $DB->get_record('course', array('id'=>$group->courseid), '*', MUST_EXIST); $PAGE->set_url('/group/members.php', array('group'=>$groupid)); $PAGE->set_pagelayout('admin'); diff --git a/lib/accesslib.php b/lib/accesslib.php index 677e2ac2f9d12..386588a29a973 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1428,25 +1428,27 @@ function get_local_override($roleid, $contextid, $capability) { * @return array of ($context, $course, $cm) */ function get_context_info_array($contextid) { + global $DB; + $context = context::instance_by_id($contextid, MUST_EXIST); $course = null; $cm = null; if ($context->contextlevel == CONTEXT_COURSE) { - $course = get_course($context->instanceid); + $course = $DB->get_record('course', array('id'=>$context->instanceid), '*', MUST_EXIST); } else if ($context->contextlevel == CONTEXT_MODULE) { $cm = get_coursemodule_from_id('', $context->instanceid, 0, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); } else if ($context->contextlevel == CONTEXT_BLOCK) { $parent = $context->get_parent_context(); if ($parent->contextlevel == CONTEXT_COURSE) { - $course = get_course($parent->instanceid); + $course = $DB->get_record('course', array('id'=>$parent->instanceid), '*', MUST_EXIST); } else if ($parent->contextlevel == CONTEXT_MODULE) { $cm = get_coursemodule_from_id('', $parent->instanceid, 0, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); } } diff --git a/lib/db/install.php b/lib/db/install.php index 36bee1f37a6b1..c5e415062857a 100644 --- a/lib/db/install.php +++ b/lib/db/install.php @@ -96,7 +96,7 @@ function xmldb_main_install() { } // Make sure site course context exists context_course::instance($SITE->id); - // Update the global frontpage cache from database. + // Update the global frontpage cache $SITE = $DB->get_record('course', array('id'=>$newsite->id), '*', MUST_EXIST); diff --git a/lib/modinfolib.php b/lib/modinfolib.php index 07499cf911459..235e3bf4b23df 100644 --- a/lib/modinfolib.php +++ b/lib/modinfolib.php @@ -247,7 +247,7 @@ public function __construct($course, $userid) { // Check modinfo field is set. If not, build and load it. if (empty($course->modinfo) || empty($course->sectioncache)) { rebuild_course_cache($course->id); - $course = get_course($course->id); + $course = $DB->get_record('course', array('id'=>$course->id), '*', MUST_EXIST); } // Set initial values diff --git a/lib/moodlelib.php b/lib/moodlelib.php index e2548aca646f0..ad04ace16d11f 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2887,7 +2887,7 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $ } else if ($courseorid == SITEID) { $course = clone($SITE); } else { - $course = get_course($courseorid); + $course = $DB->get_record('course', array('id' => $courseorid), '*', MUST_EXIST); } if ($cm) { if ($cm->course != $course->id) { @@ -4912,7 +4912,7 @@ function remove_course_contents($courseid, $showfeedback = true, array $options // Some crazy wishlist of stuff we should skip during purging of course content. $options = (array)$options; - $course = get_course($courseid); + $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); $coursecontext = context_course::instance($courseid); $fs = get_file_storage(); diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 753d0ede63b12..3a897d78361e0 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2744,7 +2744,7 @@ public function initialise() { $this->load_category($this->instanceid, self::TYPE_MY_CATEGORY); break; case self::TYPE_COURSE : - $course = get_course($this->instanceid); + $course = $DB->get_record('course', array('id' => $this->instanceid), '*', MUST_EXIST); require_course_login($course, true, null, false, true); $this->page->set_context(context_course::instance($course->id)); $coursenode = $this->add_course($course); diff --git a/lib/pagelib.php b/lib/pagelib.php index 89bbd8515fd25..9c7db77892acd 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -950,7 +950,7 @@ public function set_cm($cm, $course = null, $module = null) { if (!$this->_course || $this->_course->id != $cm->course) { if (!$course) { - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); } if ($course->id != $cm->course) { throw new coding_exception('The course you passed to $PAGE->set_cm does not correspond to the $cm.'); diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index 5180bf726927a..d3c3c1e98b913 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -2120,8 +2120,8 @@ public function test_permission_evaluation() { $guestid = $CFG->siteguest; // Enrol some users into some courses. - $course1 = get_course($testcourses[22]); - $course2 = get_course($testcourses[7]); + $course1 = $DB->get_record('course', array('id'=>$testcourses[22]), '*', MUST_EXIST); + $course2 = $DB->get_record('course', array('id'=>$testcourses[7]), '*', MUST_EXIST); $cms = $DB->get_records('course_modules', array('course'=>$course1->id), 'id'); $cm1 = reset($cms); $blocks = $DB->get_records('block_instances', array('parentcontextid'=>context_module::instance($cm1->id)->id), 'id'); diff --git a/mod/assign/index.php b/mod/assign/index.php index 4e7c1c8b24a7a..f072009bbf251 100644 --- a/mod/assign/index.php +++ b/mod/assign/index.php @@ -27,7 +27,7 @@ // For this type of page this is the course id. $id = required_param('id', PARAM_INT); -$course = get_course($id); +$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); require_login($course); $PAGE->set_url('/mod/assign/index.php', array('id' => $id)); $PAGE->set_pagelayout('incourse'); diff --git a/mod/assign/lib.php b/mod/assign/lib.php index d8cd9ffc56376..49a13f102606b 100644 --- a/mod/assign/lib.php +++ b/mod/assign/lib.php @@ -69,7 +69,7 @@ function assign_reset_userdata($data) { $status = array(); $params = array('courseid'=>$data->courseid); $sql = "SELECT a.id FROM {assign} a WHERE a.course=:courseid"; - $course = get_course($data->courseid); + $course = $DB->get_record('course', array('id'=>$data->courseid), '*', MUST_EXIST); if ($assigns = $DB->get_records_sql($sql, $params)) { foreach ($assigns as $assign) { $cm = get_coursemodule_from_instance('assign', diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 9ac7a36af757b..be7eedb8a72ea 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -575,7 +575,7 @@ public function add_instance(stdClass $formdata, $callplugins) { $returnid = $DB->insert_record('assign', $update); $this->instance = $DB->get_record('assign', array('id'=>$returnid), '*', MUST_EXIST); // Cache the course record. - $this->course = get_course($formdata->course); + $this->course = $DB->get_record('course', array('id'=>$formdata->course), '*', MUST_EXIST); if ($callplugins) { // Call save_settings hook for submission plugins. diff --git a/mod/assign/mod_form.php b/mod/assign/mod_form.php index e49ae5308c5f1..edfe6ebe1e791 100644 --- a/mod/assign/mod_form.php +++ b/mod/assign/mod_form.php @@ -68,7 +68,7 @@ public function definition() { if (!$ctx) { $ctx = context_course::instance($this->current->course); } - $course = get_course($this->current->course); + $course = $DB->get_record('course', array('id'=>$this->current->course), '*', MUST_EXIST); $assignment->set_course($course); } @@ -259,7 +259,7 @@ public function data_preprocessing(&$defaultvalues) { if (!$ctx) { $ctx = context_course::instance($this->current->course); } - $course = get_course($this->current->course); + $course = $DB->get_record('course', array('id'=>$this->current->course), '*', MUST_EXIST); $assignment->set_course($course); } $assignment->plugin_data_preprocessing($defaultvalues); diff --git a/mod/assign/view.php b/mod/assign/view.php index 03dadc9182fd2..9fa7e24395d4a 100644 --- a/mod/assign/view.php +++ b/mod/assign/view.php @@ -34,7 +34,7 @@ $url = new moodle_url('/mod/assign/view.php', $urlparams); $cm = get_coursemodule_from_id('assign', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, true, $cm); $PAGE->set_url($url); diff --git a/mod/book/delete.php b/mod/book/delete.php index 4ea5a835a0327..63c9507064a56 100644 --- a/mod/book/delete.php +++ b/mod/book/delete.php @@ -30,7 +30,7 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); $cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST); require_login($course, false, $cm); diff --git a/mod/book/edit.php b/mod/book/edit.php index f68936e086ade..547a9d1092079 100644 --- a/mod/book/edit.php +++ b/mod/book/edit.php @@ -32,7 +32,7 @@ $subchapter = optional_param('subchapter', 0, PARAM_BOOL); $cm = get_coursemodule_from_id('book', $cmid, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST); require_login($course, false, $cm); diff --git a/mod/book/index.php b/mod/book/index.php index 53a51663a726d..754618894134d 100644 --- a/mod/book/index.php +++ b/mod/book/index.php @@ -27,7 +27,7 @@ $id = required_param('id', PARAM_INT); // Course ID. -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); unset($id); diff --git a/mod/book/move.php b/mod/book/move.php index 1d86c93e70152..7ae229b27f9fb 100644 --- a/mod/book/move.php +++ b/mod/book/move.php @@ -30,7 +30,7 @@ $up = optional_param('up', 0, PARAM_BOOL); $cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST); require_login($course, false, $cm); diff --git a/mod/book/show.php b/mod/book/show.php index 6918d4b343bc5..7af7de22dba9a 100644 --- a/mod/book/show.php +++ b/mod/book/show.php @@ -29,7 +29,7 @@ $chapterid = required_param('chapterid', PARAM_INT); // Chapter ID $cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST); require_login($course, false, $cm); diff --git a/mod/book/tool/exportimscp/index.php b/mod/book/tool/exportimscp/index.php index d49ad620cb181..29418edffd465 100644 --- a/mod/book/tool/exportimscp/index.php +++ b/mod/book/tool/exportimscp/index.php @@ -32,7 +32,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID $cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST); $PAGE->set_url('/mod/book/tool/exportimscp/index.php', array('id'=>$id)); diff --git a/mod/book/tool/importhtml/index.php b/mod/book/tool/importhtml/index.php index 3f1085e4460f7..25ee6f77fa47c 100644 --- a/mod/book/tool/importhtml/index.php +++ b/mod/book/tool/importhtml/index.php @@ -30,7 +30,7 @@ $chapterid = optional_param('chapterid', 0, PARAM_INT); // Chapter ID $cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST); require_login($course, false, $cm); diff --git a/mod/book/tool/print/index.php b/mod/book/tool/print/index.php index 3a7308fd7e0bc..cb258b08b791e 100644 --- a/mod/book/tool/print/index.php +++ b/mod/book/tool/print/index.php @@ -33,7 +33,7 @@ // ========================================================================= $cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST); require_course_login($course, true, $cm); diff --git a/mod/book/view.php b/mod/book/view.php index a712101c7515a..cf9ed5512b812 100644 --- a/mod/book/view.php +++ b/mod/book/view.php @@ -36,12 +36,12 @@ // ========================================================================= if ($id) { $cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST); } else { $book = $DB->get_record('book', array('id'=>$bid), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('book', $book->id, 0, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $id = $cm->id; } diff --git a/mod/chat/gui_ajax/index.php b/mod/chat/gui_ajax/index.php index 659aa629420e3..edd8e5a6534ab 100644 --- a/mod/chat/gui_ajax/index.php +++ b/mod/chat/gui_ajax/index.php @@ -14,7 +14,7 @@ $PAGE->set_popup_notification_allowed(false); // No popup notifications in the chat window $chat = $DB->get_record('chat', array('id'=>$id), '*', MUST_EXIST); -$course = get_course($chat->course); +$course = $DB->get_record('course', array('id'=>$chat->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('chat', $chat->id, $course->id, false, MUST_EXIST); $context = context_module::instance($cm->id); diff --git a/mod/data/import.php b/mod/data/import.php index f1dbd4122ab68..9b7425b7973dd 100644 --- a/mod/data/import.php +++ b/mod/data/import.php @@ -49,14 +49,14 @@ $url->param('id', $id); $PAGE->set_url($url); $cm = get_coursemodule_from_id('data', $id, 0, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $data = $DB->get_record('data', array('id'=>$cm->instance), '*', MUST_EXIST); } else { $url->param('d', $d); $PAGE->set_url($url); $data = $DB->get_record('data', array('id'=>$d), '*', MUST_EXIST); - $course = get_course($data->course); + $course = $DB->get_record('course', array('id'=>$data->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('data', $data->id, $course->id, false, MUST_EXIST); } diff --git a/mod/data/lib.php b/mod/data/lib.php index 02c83012eb6fc..8e108b9fc23c6 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -1439,7 +1439,7 @@ function data_rating_validate($params) { } } - $course = get_course($info->course); + $course = $DB->get_record('course', array('id'=>$info->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('data', $info->dataid, $course->id, false, MUST_EXIST); $context = context_module::instance($cm->id); diff --git a/mod/data/preset.php b/mod/data/preset.php index ac13d22e27dda..673d43ab50b55 100644 --- a/mod/data/preset.php +++ b/mod/data/preset.php @@ -36,12 +36,12 @@ $id = optional_param('id', 0, PARAM_INT); // course module id if ($id) { $cm = get_coursemodule_from_id('data', $id, null, null, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $data = $DB->get_record('data', array('id'=>$cm->instance), '*', MUST_EXIST); } else { $d = required_param('d', PARAM_INT); // database activity id $data = $DB->get_record('data', array('id'=>$d), '*', MUST_EXIST); - $course = get_course($data->course); + $course = $DB->get_record('course', array('id'=>$data->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('data', $data->id, $course->id, null, MUST_EXIST); } diff --git a/mod/feedback/ajax.php b/mod/feedback/ajax.php index 14d9c2fdad49c..a562690d19418 100644 --- a/mod/feedback/ajax.php +++ b/mod/feedback/ajax.php @@ -35,7 +35,7 @@ $itemorder = optional_param('itemorder', false, PARAM_SEQUENCE); $cm = get_coursemodule_from_id('feedback', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $feedback = $DB->get_record('feedback', array('id'=>$cm->instance), '*', MUST_EXIST); require_sesskey(); diff --git a/mod/folder/edit.php b/mod/folder/edit.php index 55e1cac88b2dd..473f8b8d17618 100644 --- a/mod/folder/edit.php +++ b/mod/folder/edit.php @@ -34,7 +34,7 @@ $cm = get_coursemodule_from_id('folder', $id, 0, true, MUST_EXIST); $context = context_module::instance($cm->id, MUST_EXIST); $folder = $DB->get_record('folder', array('id'=>$cm->instance), '*', MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); require_login($course, false, $cm); require_capability('mod/folder:managefiles', $context); diff --git a/mod/folder/index.php b/mod/folder/index.php index a95d1a32981ba..9cbe696bdc785 100644 --- a/mod/folder/index.php +++ b/mod/folder/index.php @@ -28,7 +28,7 @@ $id = required_param('id', PARAM_INT); // course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); require_course_login($course, true); $PAGE->set_pagelayout('incourse'); diff --git a/mod/folder/view.php b/mod/folder/view.php index 8672d3b81ae56..19c16a78405d8 100644 --- a/mod/folder/view.php +++ b/mod/folder/view.php @@ -41,7 +41,7 @@ $folder = $DB->get_record('folder', array('id'=>$cm->instance), '*', MUST_EXIST); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); require_course_login($course, true, $cm); $context = context_module::instance($cm->id); diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index 14bc28b2ac8a4..c387790549bd5 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -40,7 +40,7 @@ $PAGE->set_url($url); $discussion = $DB->get_record('forum_discussions', array('id' => $d), '*', MUST_EXIST); - $course = get_course($discussion->course); + $course = $DB->get_record('course', array('id' => $discussion->course), '*', MUST_EXIST); $forum = $DB->get_record('forum', array('id' => $discussion->forum), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST); diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 6a7ab622f365f..0349caba093c5 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -3628,7 +3628,7 @@ function forum_rating_validate($params) { $post = $DB->get_record('forum_posts', array('id' => $params['itemid'], 'userid' => $params['rateduserid']), '*', MUST_EXIST); $discussion = $DB->get_record('forum_discussions', array('id' => $post->discussion), '*', MUST_EXIST); $forum = $DB->get_record('forum', array('id' => $discussion->forum), '*', MUST_EXIST); - $course = get_course($forum->course); + $course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id , false, MUST_EXIST); $context = context_module::instance($cm->id); diff --git a/mod/forum/subscribe.php b/mod/forum/subscribe.php index c246257c4d0ef..1bd52774f61b4 100644 --- a/mod/forum/subscribe.php +++ b/mod/forum/subscribe.php @@ -53,7 +53,7 @@ $PAGE->set_url($url); $forum = $DB->get_record('forum', array('id' => $id), '*', MUST_EXIST); -$course = get_course($forum->course); +$course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST); $context = context_module::instance($cm->id); diff --git a/mod/forum/subscribers.php b/mod/forum/subscribers.php index 1dbfe6692dda1..87c3b5429ef1f 100644 --- a/mod/forum/subscribers.php +++ b/mod/forum/subscribers.php @@ -40,7 +40,7 @@ $PAGE->set_url($url); $forum = $DB->get_record('forum', array('id'=>$id), '*', MUST_EXIST); -$course = get_course($forum->course); +$course = $DB->get_record('course', array('id'=>$forum->course), '*', MUST_EXIST); if (! $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { $cm->id = 0; } diff --git a/mod/forum/user.php b/mod/forum/user.php index 5dfebebc59478..0059ae8a2899a 100644 --- a/mod/forum/user.php +++ b/mod/forum/user.php @@ -90,7 +90,7 @@ // Check whether a specific course has been requested if ($isspecificcourse) { // Get the requested course and its context - $course = get_course($courseid); + $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); $coursecontext = context_course::instance($courseid, MUST_EXIST); // We have a specific course to search, which we will also assume we are within. if ($hasparentaccess) { diff --git a/mod/glossary/approve.php b/mod/glossary/approve.php index 1a7685b90a112..4069376e742e9 100644 --- a/mod/glossary/approve.php +++ b/mod/glossary/approve.php @@ -14,7 +14,7 @@ $entry = $DB->get_record('glossary_entries', array('id'=> $eid), '*', MUST_EXIST); $glossary = $DB->get_record('glossary', array('id'=> $entry->glossaryid), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('glossary', $glossary->id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=> $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); diff --git a/mod/glossary/rsslib.php b/mod/glossary/rsslib.php index 4c22cb77a170a..6a51b2f360464 100644 --- a/mod/glossary/rsslib.php +++ b/mod/glossary/rsslib.php @@ -49,7 +49,7 @@ function glossary_rss_get_feed($context, $args) { if ($COURSE->id == $cm->course) { $course = $COURSE; } else { - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); } //context id from db should match the submitted one if ($context->id != $modcontext->id || !has_capability('mod/glossary:view', $modcontext)) { diff --git a/mod/glossary/showentry.php b/mod/glossary/showentry.php index 2623f49bad956..3c927a2b45349 100644 --- a/mod/glossary/showentry.php +++ b/mod/glossary/showentry.php @@ -23,7 +23,7 @@ $entry = $DB->get_record('glossary_entries', array('id'=>$eid), '*', MUST_EXIST); $glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('glossary', $glossary->id, 0, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); require_course_login($course, true, $cm); $entry->glossaryname = $glossary->name; $entry->cmid = $cm->id; @@ -31,7 +31,7 @@ $entries = array($entry); } else if ($concept) { - $course = get_course($courseid); + $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); require_course_login($course); $entries = glossary_get_entries_search($concept, $courseid); @@ -45,7 +45,7 @@ foreach ($entries as $key => $entry) { // Need to get the course where the entry is, // in order to check for visibility/approve permissions there - $entrycourse = get_course($entry->courseid); + $entrycourse = $DB->get_record('course', array('id' => $entry->courseid), '*', MUST_EXIST); $modinfo = get_fast_modinfo($entrycourse); // make sure the entry is visible if (empty($modinfo->cms[$entry->cmid]->uservisible)) { diff --git a/mod/glossary/showentry_ajax.php b/mod/glossary/showentry_ajax.php index e07ad210c1ea9..4e986d43fbd30 100644 --- a/mod/glossary/showentry_ajax.php +++ b/mod/glossary/showentry_ajax.php @@ -25,7 +25,7 @@ $entry = $DB->get_record('glossary_entries', array('id'=>$eid), '*', MUST_EXIST); $glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('glossary', $glossary->id, 0, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); require_course_login($course, true, $cm); $entry->glossaryname = $glossary->name; $entry->cmid = $cm->id; @@ -33,7 +33,7 @@ $entries = array($entry); } else if ($concept) { - $course = get_course($courseid); + $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); require_course_login($course); $entries = glossary_get_entries_search($concept, $courseid); @@ -45,7 +45,7 @@ foreach ($entries as $key => $entry) { // Need to get the course where the entry is, // in order to check for visibility/approve permissions there - $entrycourse = get_course($entry->courseid); + $entrycourse = $DB->get_record('course', array('id' => $entry->courseid), '*', MUST_EXIST); $modinfo = get_fast_modinfo($entrycourse); // make sure the entry is visible if (empty($modinfo->cms[$entry->cmid]->uservisible)) { diff --git a/mod/imscp/index.php b/mod/imscp/index.php index 10d45504d47b3..53505da6c4da1 100644 --- a/mod/imscp/index.php +++ b/mod/imscp/index.php @@ -28,7 +28,7 @@ $id = required_param('id', PARAM_INT); // course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); require_course_login($course, true); $PAGE->set_pagelayout('incourse'); diff --git a/mod/imscp/view.php b/mod/imscp/view.php index 975e102dcd806..7b59b0b62f74f 100644 --- a/mod/imscp/view.php +++ b/mod/imscp/view.php @@ -40,7 +40,7 @@ $imscp = $DB->get_record('imscp', array('id'=>$cm->instance), '*', MUST_EXIST); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); require_course_login($course, true, $cm); $context = context_module::instance($cm->id); diff --git a/mod/lesson/continue.php b/mod/lesson/continue.php index 4e6bfb295488e..79f3499aab3f2 100644 --- a/mod/lesson/continue.php +++ b/mod/lesson/continue.php @@ -31,7 +31,7 @@ $id = required_param('id', PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); diff --git a/mod/lesson/edit.php b/mod/lesson/edit.php index a55f65e71bfb0..aeeb201429783 100644 --- a/mod/lesson/edit.php +++ b/mod/lesson/edit.php @@ -30,7 +30,7 @@ $id = required_param('id', PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); diff --git a/mod/lesson/editpage.php b/mod/lesson/editpage.php index 93882f094fb2e..140de2e3b72a8 100644 --- a/mod/lesson/editpage.php +++ b/mod/lesson/editpage.php @@ -35,7 +35,7 @@ $edit = optional_param('edit', false, PARAM_BOOL); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); diff --git a/mod/lesson/essay.php b/mod/lesson/essay.php index 1a2e9454f916d..c824a63ac64d8 100644 --- a/mod/lesson/essay.php +++ b/mod/lesson/essay.php @@ -33,7 +33,7 @@ $mode = optional_param('mode', 'display', PARAM_ALPHA); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); diff --git a/mod/lesson/grade.php b/mod/lesson/grade.php index f5872816c2d8b..8a98406b297fa 100644 --- a/mod/lesson/grade.php +++ b/mod/lesson/grade.php @@ -32,7 +32,7 @@ $id = required_param('id', PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); diff --git a/mod/lesson/highscores.php b/mod/lesson/highscores.php index 36f1d27708c6a..c75dbbff47f2d 100644 --- a/mod/lesson/highscores.php +++ b/mod/lesson/highscores.php @@ -33,7 +33,7 @@ $link = optional_param('link', 0, PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); diff --git a/mod/lesson/import.php b/mod/lesson/import.php index ac0ba0e7ea43d..4f3814c72d3f7 100644 --- a/mod/lesson/import.php +++ b/mod/lesson/import.php @@ -36,7 +36,7 @@ $PAGE->set_url('/mod/lesson/import.php', array('id'=>$id, 'pageid'=>$pageid)); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); diff --git a/mod/lesson/lesson.php b/mod/lesson/lesson.php index 55c3620a6029c..75ee4bb288cea 100644 --- a/mod/lesson/lesson.php +++ b/mod/lesson/lesson.php @@ -37,7 +37,7 @@ $pageid = required_param('pageid', PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); diff --git a/mod/lesson/mediafile.php b/mod/lesson/mediafile.php index 5703ec792f276..7ad10af06e7fd 100644 --- a/mod/lesson/mediafile.php +++ b/mod/lesson/mediafile.php @@ -34,7 +34,7 @@ $printclose = optional_param('printclose', 0, PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); diff --git a/mod/lesson/report.php b/mod/lesson/report.php index 40cec6cf5740d..e48dea9fe5143 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -33,7 +33,7 @@ $nothingtodisplay = false; $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 0697ab92f6020..91e856ea0b4cb 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -36,7 +36,7 @@ $backtocourse = optional_param('backtocourse', false, PARAM_RAW); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); diff --git a/mod/lti/grade.php b/mod/lti/grade.php index 2e131b8ea7104..0fb22eb613467 100644 --- a/mod/lti/grade.php +++ b/mod/lti/grade.php @@ -65,7 +65,7 @@ $lti = $DB->get_record('lti', array('id' => $cm->instance), '*', MUST_EXIST); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); $context = context_module::instance($cm->id); diff --git a/mod/lti/index.php b/mod/lti/index.php index 17cdebf36ed25..346f6e1c3b854 100644 --- a/mod/lti/index.php +++ b/mod/lti/index.php @@ -51,7 +51,7 @@ $id = required_param('id', PARAM_INT); // course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); require_login($course); $PAGE->set_pagelayout('incourse'); diff --git a/mod/lti/launch.php b/mod/lti/launch.php index c016010c77aaa..fced3b41170fe 100644 --- a/mod/lti/launch.php +++ b/mod/lti/launch.php @@ -55,7 +55,7 @@ $cm = get_coursemodule_from_id('lti', $id, 0, false, MUST_EXIST); $lti = $DB->get_record('lti', array('id' => $cm->instance), '*', MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course); diff --git a/mod/lti/view.php b/mod/lti/view.php index 70b8e3022f432..c07408a1871f5 100644 --- a/mod/lti/view.php +++ b/mod/lti/view.php @@ -63,7 +63,7 @@ $lti = $DB->get_record('lti', array('id' => $cm->instance), '*', MUST_EXIST); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $tool = lti_get_tool_by_url_match($lti->toolurl); if ($tool) { diff --git a/mod/page/index.php b/mod/page/index.php index ac34897786773..9843372b9f647 100644 --- a/mod/page/index.php +++ b/mod/page/index.php @@ -28,7 +28,7 @@ $id = required_param('id', PARAM_INT); // course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); require_course_login($course, true); $PAGE->set_pagelayout('incourse'); diff --git a/mod/page/view.php b/mod/page/view.php index b778643b69534..e04a2ec3df40c 100644 --- a/mod/page/view.php +++ b/mod/page/view.php @@ -45,7 +45,7 @@ $page = $DB->get_record('page', array('id'=>$cm->instance), '*', MUST_EXIST); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); require_course_login($course, true, $cm); $context = context_module::instance($cm->id); diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index 90155b7478d4c..df659ae6818eb 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -108,7 +108,7 @@ public static function create($quizid, $userid) { global $DB; $quiz = quiz_access_manager::load_quiz_and_settings($quizid); - $course = get_course($quiz->course); + $course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id, false, MUST_EXIST); // Update quiz with override information. @@ -489,7 +489,7 @@ protected static function create_helper($conditions) { $attempt = $DB->get_record('quiz_attempts', $conditions, '*', MUST_EXIST); $quiz = quiz_access_manager::load_quiz_and_settings($attempt->quiz); - $course = get_course($quiz->course); + $course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id, false, MUST_EXIST); // Update quiz with override information. diff --git a/mod/quiz/cronlib.php b/mod/quiz/cronlib.php index 8f74ba30716e5..175e5c6a1ac7a 100644 --- a/mod/quiz/cronlib.php +++ b/mod/quiz/cronlib.php @@ -66,7 +66,7 @@ public function update_overdue_attempts($timenow, $processto) { // If we have moved on to a different course, fetch the new data. if (!$course || $course->id != $quiz->course) { - $course = get_course($quiz->course); + $course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST); } // Make a specialised version of the quiz settings, with the relevant overrides. diff --git a/mod/quiz/grade.php b/mod/quiz/grade.php index 9e71e31f86e3d..dd0c9f8d9499f 100644 --- a/mod/quiz/grade.php +++ b/mod/quiz/grade.php @@ -34,7 +34,7 @@ $userid = optional_param('userid', 0, PARAM_INT); $cm = get_coursemodule_from_id('quiz', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $quiz = $DB->get_record('quiz', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, false, $cm); diff --git a/mod/quiz/overridedelete.php b/mod/quiz/overridedelete.php index 7abf7bda2b13e..7528226048299 100644 --- a/mod/quiz/overridedelete.php +++ b/mod/quiz/overridedelete.php @@ -40,7 +40,7 @@ if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $quiz->course)) { print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $context = context_module::instance($cm->id); diff --git a/mod/quiz/overrideedit.php b/mod/quiz/overrideedit.php index 2bd3de5a5f2d0..b298780312e18 100644 --- a/mod/quiz/overrideedit.php +++ b/mod/quiz/overrideedit.php @@ -58,7 +58,7 @@ } else { print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $url = new moodle_url('/mod/quiz/overrideedit.php'); if ($action) { diff --git a/mod/quiz/overrides.php b/mod/quiz/overrides.php index 82a89a98037d5..e6a5d840cd17c 100644 --- a/mod/quiz/overrides.php +++ b/mod/quiz/overrides.php @@ -38,7 +38,7 @@ if (! $quiz = $DB->get_record('quiz', array('id' => $cm->instance))) { print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); // Get the course groups. $groups = groups_get_all_groups($cm->course); diff --git a/mod/resource/index.php b/mod/resource/index.php index 85247133e17cd..3e9baf3d7d747 100644 --- a/mod/resource/index.php +++ b/mod/resource/index.php @@ -28,7 +28,7 @@ $id = required_param('id', PARAM_INT); // course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); require_course_login($course, true); $PAGE->set_pagelayout('incourse'); diff --git a/mod/resource/view.php b/mod/resource/view.php index 6c901b47f90c1..0fb05f4660674 100644 --- a/mod/resource/view.php +++ b/mod/resource/view.php @@ -47,7 +47,7 @@ $resource = $DB->get_record('resource', array('id'=>$cm->instance), '*', MUST_EXIST); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); require_course_login($course, true, $cm); $context = context_module::instance($cm->id); diff --git a/mod/scorm/datamodels/sequencinghandler.php b/mod/scorm/datamodels/sequencinghandler.php index bb3377f09bd0b..f1de51bbbff24 100644 --- a/mod/scorm/datamodels/sequencinghandler.php +++ b/mod/scorm/datamodels/sequencinghandler.php @@ -26,11 +26,11 @@ if (!empty($id)) { $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record("course", array("id" => $cm->course), '*', MUST_EXIST); $scorm = $DB->get_record("scorm", array("id" => $cm->instance), '*', MUST_EXIST); } else if (!empty($a)) { $scorm = $DB->get_record("scorm", array("id" => $a), '*', MUST_EXIST); - $course = get_course($scorm->course); + $course = $DB->get_record("course", array("id" => $scorm->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id, false, MUST_EXIST); } else { print_error('missingparameter'); diff --git a/mod/scorm/loaddatamodel.php b/mod/scorm/loaddatamodel.php index ff7a377e19fd8..297375d25e836 100644 --- a/mod/scorm/loaddatamodel.php +++ b/mod/scorm/loaddatamodel.php @@ -33,11 +33,11 @@ if (!empty($id)) { $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $scorm = $DB->get_record('scorm', array('id'=>$cm->instance), '*', MUST_EXIST); } else if (!empty($a)) { $scorm = $DB->get_record('scorm', array('id'=>$a), '*', MUST_EXIST); - $course = get_course($scorm->course); + $course = $DB->get_record('course', array('id'=>$scorm->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id, false, MUST_EXIST); } else { print_error('missingparameter'); diff --git a/mod/scorm/report.php b/mod/scorm/report.php index bb5304855d9f4..b2fedfba47f12 100644 --- a/mod/scorm/report.php +++ b/mod/scorm/report.php @@ -33,7 +33,7 @@ $mode = optional_param('mode', '', PARAM_ALPHA); // Report mode $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $scorm = $DB->get_record('scorm', array('id'=>$cm->instance), '*', MUST_EXIST); $contextmodule = context_module::instance($cm->id); diff --git a/mod/scorm/report/graphs/graph.php b/mod/scorm/report/graphs/graph.php index d56e0e26e4791..3d9b7f44032ce 100644 --- a/mod/scorm/report/graphs/graph.php +++ b/mod/scorm/report/graphs/graph.php @@ -33,7 +33,7 @@ $sco = $DB->get_record('scorm_scoes', array('id'=>$scoid), '*', MUST_EXIST); $scorm = $DB->get_record('scorm', array('id'=>$sco->scorm), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('scorm', $scorm->id, 0, false, MUST_EXIST); -$course = get_course($scorm->course); +$course = $DB->get_record('course', array('id'=>$scorm->course), '*', MUST_EXIST); // Capability Checks diff --git a/mod/scorm/userreport.php b/mod/scorm/userreport.php index aa321740993ab..5a02c4279f252 100644 --- a/mod/scorm/userreport.php +++ b/mod/scorm/userreport.php @@ -44,7 +44,7 @@ if (!empty($id)) { $url->param('id', $id); $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST); } else { if (!empty($b)) { @@ -55,7 +55,7 @@ if (!empty($a)) { $url->param('a', $a); $scorm = $DB->get_record('scorm', array('id' => $a), '*', MUST_EXIST); - $course = get_course($scorm->course); + $course = $DB->get_record('course', array('id' => $scorm->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id, false, MUST_EXIST); } } diff --git a/mod/url/index.php b/mod/url/index.php index 752a2c8b83a85..e5d096dd42ca9 100644 --- a/mod/url/index.php +++ b/mod/url/index.php @@ -28,7 +28,7 @@ $id = required_param('id', PARAM_INT); // course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); require_course_login($course, true); $PAGE->set_pagelayout('incourse'); diff --git a/mod/url/lib.php b/mod/url/lib.php index ad2b99ff027de..8433058d98f5b 100644 --- a/mod/url/lib.php +++ b/mod/url/lib.php @@ -306,7 +306,7 @@ function url_export_contents($cm, $baseurl) { $contents = array(); $context = context_module::instance($cm->id); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); $url = $DB->get_record('url', array('id'=>$cm->instance), '*', MUST_EXIST); $fullurl = str_replace('&', '&', url_get_full_url($url, $cm, $course)); diff --git a/mod/url/view.php b/mod/url/view.php index 614dc4daf8a8e..72483946f4c4b 100644 --- a/mod/url/view.php +++ b/mod/url/view.php @@ -41,7 +41,7 @@ $url = $DB->get_record('url', array('id'=>$cm->instance), '*', MUST_EXIST); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); require_course_login($course, true, $cm); $context = context_module::instance($cm->id); diff --git a/mod/wiki/admin.php b/mod/wiki/admin.php index d1fef986aa14f..873a9215da8d3 100644 --- a/mod/wiki/admin.php +++ b/mod/wiki/admin.php @@ -48,7 +48,7 @@ if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) { print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); if (!$wiki = wiki_get_wiki($subwiki->wikiid)) { print_error('incorrectwikiid', 'wiki'); } diff --git a/mod/wiki/comments.php b/mod/wiki/comments.php index 749dd22a71240..f10fccb6e5dee 100644 --- a/mod/wiki/comments.php +++ b/mod/wiki/comments.php @@ -55,7 +55,7 @@ print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, true, $cm); diff --git a/mod/wiki/create.php b/mod/wiki/create.php index a79dd01380f42..971c26a70fed9 100644 --- a/mod/wiki/create.php +++ b/mod/wiki/create.php @@ -82,7 +82,7 @@ } } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, true, $cm); diff --git a/mod/wiki/diff.php b/mod/wiki/diff.php index d4dba022b1b93..cdd354c0d6794 100644 --- a/mod/wiki/diff.php +++ b/mod/wiki/diff.php @@ -60,7 +60,7 @@ print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); if ($compare >= $comparewith) { print_error("A page version can only be compared with an older version."); diff --git a/mod/wiki/edit.php b/mod/wiki/edit.php index 7a85b48eca569..fa9da8ef98643 100644 --- a/mod/wiki/edit.php +++ b/mod/wiki/edit.php @@ -66,7 +66,7 @@ print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); if (!empty($section) && !$sectioncontent = wiki_get_section_page($page, $section)) { print_error('invalidsection', 'wiki'); diff --git a/mod/wiki/editcomments.php b/mod/wiki/editcomments.php index 9f6cdf9cc56d7..13c9ebc58fbf5 100644 --- a/mod/wiki/editcomments.php +++ b/mod/wiki/editcomments.php @@ -48,7 +48,7 @@ if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) { print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); if (!$wiki = wiki_get_wiki($subwiki->wikiid)) { print_error('incorrectwikiid', 'wiki'); } diff --git a/mod/wiki/files.php b/mod/wiki/files.php index fdc86875a57a2..4ee6bc188950b 100644 --- a/mod/wiki/files.php +++ b/mod/wiki/files.php @@ -71,7 +71,7 @@ } // Checking course instance -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $context = context_module::instance($cm->id); diff --git a/mod/wiki/filesedit.php b/mod/wiki/filesedit.php index 809ccc4436b81..c306eb1b4f9f0 100644 --- a/mod/wiki/filesedit.php +++ b/mod/wiki/filesedit.php @@ -48,7 +48,7 @@ } // Checking course instance -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $context = context_module::instance($cm->id); diff --git a/mod/wiki/history.php b/mod/wiki/history.php index df297aeced6ba..66010224ec34a 100644 --- a/mod/wiki/history.php +++ b/mod/wiki/history.php @@ -56,7 +56,7 @@ print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, true, $cm); $context = context_module::instance($cm->id); diff --git a/mod/wiki/instancecomments.php b/mod/wiki/instancecomments.php index 97a791ca2a58b..1294c826c3abc 100644 --- a/mod/wiki/instancecomments.php +++ b/mod/wiki/instancecomments.php @@ -54,7 +54,7 @@ if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) { print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); if (!$wiki = wiki_get_wiki($subwiki->wikiid)) { print_error('incorrectwikiid', 'wiki'); } diff --git a/mod/wiki/lock.php b/mod/wiki/lock.php index ec705c819abef..97cd63c78f266 100644 --- a/mod/wiki/lock.php +++ b/mod/wiki/lock.php @@ -60,7 +60,7 @@ print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); if (!empty($section) && !$sectioncontent = wiki_get_section_page($page, $section)) { print_error('invalidsection', 'wiki'); diff --git a/mod/wiki/map.php b/mod/wiki/map.php index 58b0ee5e608d0..745f724e07a3e 100644 --- a/mod/wiki/map.php +++ b/mod/wiki/map.php @@ -48,7 +48,7 @@ if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) { print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); if (!$wiki = wiki_get_wiki($subwiki->wikiid)) { print_error('incorrectwikiid', 'wiki'); } diff --git a/mod/wiki/overridelocks.php b/mod/wiki/overridelocks.php index 583a1d1c52422..7af1f45492363 100644 --- a/mod/wiki/overridelocks.php +++ b/mod/wiki/overridelocks.php @@ -56,7 +56,7 @@ print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); if (!empty($section) && !$sectioncontent = wiki_get_section_page($page, $section)) { print_error('invalidsection', 'wiki'); diff --git a/mod/wiki/prettyview.php b/mod/wiki/prettyview.php index f92e7d0b6b7f0..e208ecfe8d38f 100644 --- a/mod/wiki/prettyview.php +++ b/mod/wiki/prettyview.php @@ -46,7 +46,7 @@ if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) { print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); if (!$wiki = wiki_get_wiki($subwiki->wikiid)) { print_error('incorrectwikiid', 'wiki'); } diff --git a/mod/wiki/restoreversion.php b/mod/wiki/restoreversion.php index 4915057b603ee..d5ad02cbd70bb 100644 --- a/mod/wiki/restoreversion.php +++ b/mod/wiki/restoreversion.php @@ -56,7 +56,7 @@ print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, true, $cm); diff --git a/mod/wiki/view.php b/mod/wiki/view.php index 461dd07014d36..bbfd6f4edff63 100644 --- a/mod/wiki/view.php +++ b/mod/wiki/view.php @@ -66,7 +66,7 @@ } // Checking course instance - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, true, $cm); @@ -138,7 +138,7 @@ $currentgroup = $subwiki->groupid; // Checking course instance - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, true, $cm); /* @@ -169,7 +169,7 @@ } // Checking course instance - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, true, $cm); @@ -252,7 +252,7 @@ // } // // // Checking course instance - // $course = get_course($cm->course); + // $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); // // // Checking course module instance // if (!$cm = get_coursemodule_from_instance("wiki", $wiki->id, $course->id)) { diff --git a/mod/wiki/viewversion.php b/mod/wiki/viewversion.php index 108e7c15aab52..ecdd6504bcc6b 100644 --- a/mod/wiki/viewversion.php +++ b/mod/wiki/viewversion.php @@ -56,7 +56,7 @@ print_error('invalidcoursemodule'); } -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, true, $cm); diff --git a/mod/workshop/aggregate.php b/mod/workshop/aggregate.php index 3743d705dec6a..ee8fb9b35ef5b 100644 --- a/mod/workshop/aggregate.php +++ b/mod/workshop/aggregate.php @@ -36,7 +36,7 @@ $sorthow = optional_param('sorthow', 'ASC', PARAM_ALPHA); $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); diff --git a/mod/workshop/allocation.php b/mod/workshop/allocation.php index a4f1ff1961f23..33842a8d6ac7b 100644 --- a/mod/workshop/allocation.php +++ b/mod/workshop/allocation.php @@ -35,7 +35,7 @@ $method = optional_param('method', 'manual', PARAM_ALPHA); // method to use $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); diff --git a/mod/workshop/allocation/scheduled/lib.php b/mod/workshop/allocation/scheduled/lib.php index 0e1fead5bd6f0..8809e93def272 100644 --- a/mod/workshop/allocation/scheduled/lib.php +++ b/mod/workshop/allocation/scheduled/lib.php @@ -277,7 +277,7 @@ function workshopallocation_scheduled_cron() { foreach ($workshops as $workshop) { $cm = get_coursemodule_from_instance('workshop', $workshop->id, $workshop->course, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); $allocator = $workshop->allocator_instance('scheduled'); $result = $allocator->execute(); diff --git a/mod/workshop/assessment.php b/mod/workshop/assessment.php index f74b8ee3b2a47..ddddfe0c8c693 100644 --- a/mod/workshop/assessment.php +++ b/mod/workshop/assessment.php @@ -42,7 +42,7 @@ $assessment = $DB->get_record('workshop_assessments', array('id' => $asid), '*', MUST_EXIST); $submission = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid, 'example' => 0), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $submission->workshopid), '*', MUST_EXIST); -$course = get_course($workshop->course); +$course = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST); require_login($course, false, $cm); diff --git a/mod/workshop/editform.php b/mod/workshop/editform.php index 993c59b31ad34..5c6d2f100b3f1 100644 --- a/mod/workshop/editform.php +++ b/mod/workshop/editform.php @@ -30,7 +30,7 @@ $cmid = required_param('cmid', PARAM_INT); $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); require_capability('mod/workshop:editdimensions', $PAGE->context); diff --git a/mod/workshop/editformpreview.php b/mod/workshop/editformpreview.php index 56142999d6086..a1185d46e610e 100644 --- a/mod/workshop/editformpreview.php +++ b/mod/workshop/editformpreview.php @@ -29,7 +29,7 @@ $cmid = required_param('cmid', PARAM_INT); $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, false, $cm); diff --git a/mod/workshop/exassessment.php b/mod/workshop/exassessment.php index 48b94706fb1ee..6112a41cf2705 100644 --- a/mod/workshop/exassessment.php +++ b/mod/workshop/exassessment.php @@ -31,7 +31,7 @@ $assessment = $DB->get_record('workshop_assessments', array('id' => $asid), '*', MUST_EXIST); $example = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid, 'example' => 1), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $example->workshopid), '*', MUST_EXIST); -$course = get_course($workshop->course); +$course = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST); require_login($course, false, $cm); diff --git a/mod/workshop/excompare.php b/mod/workshop/excompare.php index d1ecf04bf4526..c5b972e4daaa5 100644 --- a/mod/workshop/excompare.php +++ b/mod/workshop/excompare.php @@ -32,7 +32,7 @@ $aid = required_param('aid', PARAM_INT); // the user's assessment id $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); if (isguestuser()) { diff --git a/mod/workshop/exsubmission.php b/mod/workshop/exsubmission.php index eeadde9f1a4ce..3a29bdf3b03e0 100644 --- a/mod/workshop/exsubmission.php +++ b/mod/workshop/exsubmission.php @@ -35,7 +35,7 @@ $assess = optional_param('assess', false, PARAM_BOOL); // assessment required $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); if (isguestuser()) { diff --git a/mod/workshop/index.php b/mod/workshop/index.php index 48115afa26694..263807a87aa4e 100644 --- a/mod/workshop/index.php +++ b/mod/workshop/index.php @@ -29,7 +29,7 @@ $id = required_param('id', PARAM_INT); // course -$course = get_course($id); +$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); require_course_login($course); diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index de810e3df7f9c..b4ad846bfa24d 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -944,7 +944,7 @@ function workshop_cron() { require_once($CFG->dirroot.'/mod/workshop/locallib.php'); foreach ($workshops as $workshop) { $cm = get_coursemodule_from_instance('workshop', $workshop->id, $workshop->course, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); $workshop->switch_phase(workshop::PHASE_ASSESSMENT); $workshop->log('update switch phase', $workshop->view_url(), $workshop->phase); diff --git a/mod/workshop/submission.php b/mod/workshop/submission.php index bd9e4b3ec8bb7..2b1c1e730f8f0 100644 --- a/mod/workshop/submission.php +++ b/mod/workshop/submission.php @@ -33,7 +33,7 @@ $assess = optional_param('assess', false, PARAM_BOOL); // instant assessment required $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); if (isguestuser()) { diff --git a/mod/workshop/switchphase.php b/mod/workshop/switchphase.php index 4bcae0c55170c..11512e5fc003b 100644 --- a/mod/workshop/switchphase.php +++ b/mod/workshop/switchphase.php @@ -32,7 +32,7 @@ $confirm = optional_param('confirm', false, PARAM_BOOL); // confirmation $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); diff --git a/mod/workshop/toolbox.php b/mod/workshop/toolbox.php index 4338298b2683d..a9f33d13726df 100644 --- a/mod/workshop/toolbox.php +++ b/mod/workshop/toolbox.php @@ -31,7 +31,7 @@ $tool = required_param('tool', PARAM_ALPHA); $cm = get_coursemodule_from_id('workshop', $id, 0, false, MUST_EXIST); -$course = get_course($cm->course); +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, false, $cm); diff --git a/mod/workshop/view.php b/mod/workshop/view.php index 1cce49fba4232..37168ce144e88 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -42,11 +42,11 @@ if ($id) { $cm = get_coursemodule_from_id('workshop', $id, 0, false, MUST_EXIST); - $course = get_course($cm->course); + $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); } else { $workshop = $DB->get_record('workshop', array('id' => $w), '*', MUST_EXIST); - $course = get_course($workshop->course); + $course = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST); } diff --git a/notes/index.php b/notes/index.php index 41a64a0412cb2..62c01b9979d6f 100644 --- a/notes/index.php +++ b/notes/index.php @@ -39,7 +39,7 @@ } /// locate course information -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); /// locate user information if ($userid) { diff --git a/report/completion/index.php b/report/completion/index.php index 1da266537fb38..e80bb56668761 100644 --- a/report/completion/index.php +++ b/report/completion/index.php @@ -44,7 +44,7 @@ $edituser = optional_param('edituser', 0, PARAM_INT); -$course = get_course($courseid); +$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); $context = context_course::instance($course->id); $url = new moodle_url('/report/completion/index.php', array('course'=>$course->id)); diff --git a/report/completion/user.php b/report/completion/user.php index e0377581bde5c..7100df8d30af3 100644 --- a/report/completion/user.php +++ b/report/completion/user.php @@ -31,7 +31,7 @@ $courseid = required_param('course', PARAM_INT); $user = $DB->get_record('user', array('id'=>$userid, 'deleted'=>0), '*', MUST_EXIST); -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $coursecontext = context_course::instance($course->id); $personalcontext = context_user::instance($user->id); diff --git a/report/log/graph.php b/report/log/graph.php index e2813a6dd15fa..58a49cb9ff1e1 100644 --- a/report/log/graph.php +++ b/report/log/graph.php @@ -40,7 +40,7 @@ $type = 'userday.png'; } -$course = get_course($id); +$course = $DB->get_record("course", array("id"=>$id), '*', MUST_EXIST); $user = $DB->get_record("user", array("id"=>$user, 'deleted'=>0), '*', MUST_EXIST); $coursecontext = context_course::instance($course->id); diff --git a/report/log/index.php b/report/log/index.php index 4d3f222ce44b5..6c0e7ede4250d 100644 --- a/report/log/index.php +++ b/report/log/index.php @@ -100,7 +100,7 @@ $PAGE->set_pagelayout('report'); if ($hostid == $CFG->mnet_localhost_id) { - $course = get_course($id); + $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); } else { $course_stub = $DB->get_record('mnet_log', array('hostid'=>$hostid, 'course'=>$id), '*', true); diff --git a/report/log/user.php b/report/log/user.php index 8afaede1aa593..32ed58212336c 100644 --- a/report/log/user.php +++ b/report/log/user.php @@ -36,7 +36,7 @@ } $user = $DB->get_record('user', array('id'=>$userid, 'deleted'=>0), '*', MUST_EXIST); -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $coursecontext = context_course::instance($course->id); $personalcontext = context_user::instance($user->id); diff --git a/report/loglive/index.php b/report/loglive/index.php index fc6cb5170f8be..782679bc4cf5c 100644 --- a/report/loglive/index.php +++ b/report/loglive/index.php @@ -36,7 +36,7 @@ $page = optional_param('page', 0, PARAM_INT); $inpopup = optional_param('inpopup', 0, PARAM_BOOL); -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); require_login($course); diff --git a/report/outline/index.php b/report/outline/index.php index 0ba38196f9801..592c60b0dd969 100644 --- a/report/outline/index.php +++ b/report/outline/index.php @@ -28,7 +28,7 @@ $id = required_param('id',PARAM_INT); // course id -$course = get_course($id); +$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $PAGE->set_url('/report/outline/index.php', array('id'=>$id)); $PAGE->set_pagelayout('report'); diff --git a/report/outline/user.php b/report/outline/user.php index 668e8017e34c9..d19186142669b 100644 --- a/report/outline/user.php +++ b/report/outline/user.php @@ -35,7 +35,7 @@ } $user = $DB->get_record('user', array('id'=>$userid, 'deleted'=>0), '*', MUST_EXIST); -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $coursecontext = context_course::instance($course->id); $personalcontext = context_user::instance($user->id); diff --git a/report/stats/graph.php b/report/stats/graph.php index 21ee319c8241f..f45a58799e90c 100644 --- a/report/stats/graph.php +++ b/report/stats/graph.php @@ -37,7 +37,7 @@ $url = new moodle_url('/report/stats/graph.php', array('course'=>$courseid, 'report'=>$report, 'time'=>$time, 'mode'=>$mode, 'userid'=>$userid, 'roleid'=>$roleid)); $PAGE->set_url($url); -$course = get_course($courseid); +$course = $DB->get_record("course", array("id"=>$courseid), '*', MUST_EXIST); $coursecontext = context_course::instance($course->id); $PAGE->set_context($coursecontext); diff --git a/report/stats/user.php b/report/stats/user.php index 2c18eaff95089..fce42e72fe641 100644 --- a/report/stats/user.php +++ b/report/stats/user.php @@ -30,7 +30,7 @@ $courseid = required_param('course', PARAM_INT); $user = $DB->get_record('user', array('id'=>$userid, 'deleted'=>0), '*', MUST_EXIST); -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $coursecontext = context_course::instance($course->id); $personalcontext = context_user::instance($user->id); diff --git a/user/editadvanced.php b/user/editadvanced.php index 77f57f416a354..94099377894a1 100644 --- a/user/editadvanced.php +++ b/user/editadvanced.php @@ -38,7 +38,7 @@ $PAGE->set_url('/user/editadvanced.php', array('course'=>$course, 'id'=>$id)); -$course = get_course($course); +$course = $DB->get_record('course', array('id'=>$course), '*', MUST_EXIST); if (!empty($USER->newadminuser)) { $PAGE->set_course($SITE); diff --git a/user/index.php b/user/index.php index e5e9ea52992c6..8130981ae6f98 100644 --- a/user/index.php +++ b/user/index.php @@ -38,9 +38,9 @@ if ($context->contextlevel != CONTEXT_COURSE) { print_error('invalidcontext'); } - $course = get_course($context->instanceid); + $course = $DB->get_record('course', array('id'=>$context->instanceid), '*', MUST_EXIST); } else { - $course = get_course($courseid); + $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); } // not needed anymore diff --git a/user/repository.php b/user/repository.php index 4826102daafbb..daa6de058f415 100644 --- a/user/repository.php +++ b/user/repository.php @@ -35,7 +35,7 @@ } $PAGE->set_url($url); -$course = get_course($course); +$course = $DB->get_record("course", array("id"=>$course), '*', MUST_EXIST); $user = $USER; $baseurl = $CFG->wwwroot . '/user/repository.php'; diff --git a/user/view.php b/user/view.php index 24bf47b769b3a..27df57e992655 100644 --- a/user/view.php +++ b/user/view.php @@ -43,7 +43,7 @@ $PAGE->set_url('/user/view.php', array('id'=>$id,'course'=>$courseid)); $user = $DB->get_record('user', array('id'=>$id), '*', MUST_EXIST); -$course = get_course($courseid); +$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $currentuser = ($user->id == $USER->id); $systemcontext = context_system::instance();