Skip to content

Commit

Permalink
Merge branch 'MDL-39876-master' of git://github.com/sammarshallou/moodle
Browse files Browse the repository at this point in the history
Conflicts:
	course/lib.php
  • Loading branch information
Sam Hemelryk committed Aug 21, 2013
2 parents e542bc2 + c290ac5 commit 6eee89b
Show file tree
Hide file tree
Showing 191 changed files with 279 additions and 273 deletions.
2 changes: 1 addition & 1 deletion admin/roles/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/override.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$course = get_course(optional_param('courseid', SITEID, PARAM_INT));
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/usersroles.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

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

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

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

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

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

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

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

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

// Define section_included (to decide if the whole task must be really executed)
$settingname = $settingprefix . 'included';
Expand Down
6 changes: 3 additions & 3 deletions backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ public function process_course($data) {
}

// Course record ready, update it
$DB->update_record('course', $data);
update_course_record($data);

course_get_format($data)->update_course_format_options($data);

Expand Down Expand Up @@ -1632,7 +1632,7 @@ class restore_default_enrolments_step extends restore_execution_step {
public function define_execution() {
global $DB;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

$course = $DB->get_record('course', array('id' => $newcourseid), '*', MUST_EXIST);
$course = get_course($newcourseid);
$course->fullname = $params['fullname'];
$course->shortname = $params['shortname'];
$course->visible = $params['visible'];

// Set shortname and fullname back.
$DB->update_record('course', $course);
update_course_record($course);

if (empty($CFG->keeptempdirectoriesonbackup)) {
fulldelete($backupbasepath);
Expand Down
12 changes: 6 additions & 6 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ function move_courses($courseids, $categoryid) {
$course->visible = 0;
}

$DB->update_record('course', $course);
update_course_record($course);

// Store the context.
$context = context_course::instance($course->id);
Expand Down Expand Up @@ -2383,7 +2383,7 @@ function update_course($data, $editoroptions = NULL) {
}

// Update with the new data
$DB->update_record('course', $data);
update_course_record($data);
// make sure the modinfo cache is reset
rebuild_course_cache($data->id);

Expand Down Expand Up @@ -3083,7 +3083,7 @@ function course_get_url($courseorid, $section = null, $options = array()) {
* @return object the created module info
*/
function create_module($moduleinfo) {
global $DB, $CFG;
global $CFG;

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

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

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

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

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

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

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

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

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

// User must be logged in.

Expand Down
6 changes: 3 additions & 3 deletions course/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,17 @@
if ((!empty($hide) or !empty($show)) && confirm_sesskey()) {
// Hide or show a course.
if (!empty($hide)) {
$course = $DB->get_record('course', array('id' => $hide), '*', MUST_EXIST);
$course = get_course($hide);
$visible = 0;
} else {
$course = $DB->get_record('course', array('id' => $show), '*', MUST_EXIST);
$course = get_course($show);
$visible = 1;
}
$coursecontext = context_course::instance($course->id);
require_capability('moodle/course:visibility', $coursecontext);
// Set the visibility of the course. we set the old flag when user manually changes visibility of course.
$params = array('id' => $course->id, 'visible' => $visible, 'visibleold' => $visible, 'timemodified' => time());
$DB->update_record('course', $params);
update_course_record((object)$params);
cache_helper::purge_by_event('changesincourse');

// Update the course object we pass to the event class.
Expand Down
Loading

0 comments on commit 6eee89b

Please sign in to comment.