mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-34463 - lib - Alteration of the get_context_instance function to utilize the new function context_XXXX::instance().
This commit is contained in:
parent
3294034b80
commit
d40604724b
61 changed files with 95 additions and 100 deletions
|
@ -34,7 +34,7 @@ $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
|
|||
|
||||
/// Make sure they can even access this course
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/course:update', $context);
|
||||
|
||||
/// return tracking object
|
||||
|
|
|
@ -40,7 +40,7 @@ if ($id !== 0) {
|
|||
$PAGE->set_url($url);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$systemcontext = context_system::instance();
|
||||
$heading = null;
|
||||
|
||||
// a bit complex access control :-O
|
||||
|
@ -57,7 +57,7 @@ if ($id) {
|
|||
print_error('invalidcourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
$courseid = $course->id;
|
||||
} else {
|
||||
|
@ -77,7 +77,7 @@ if ($id) {
|
|||
/// adding new outcome from course
|
||||
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
navigation_node::override_active_url(new moodle_url('/grade/edit/outcome/course.php', array('id'=>$courseid)));
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ class edit_outcome_form extends moodleform {
|
|||
if (empty($courseid)) {
|
||||
$mform->hardFreeze('standard');
|
||||
|
||||
} else if (empty($outcome->courseid) and !has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
} else if (empty($outcome->courseid) and !has_capability('moodle/grade:manage', context_system::instance())) {
|
||||
$mform->hardFreeze('standard');
|
||||
|
||||
} else if ($coursecount and empty($outcome->courseid)) {
|
||||
|
@ -130,7 +130,7 @@ class edit_outcome_form extends moodleform {
|
|||
|
||||
|
||||
} else {
|
||||
if (empty($courseid) or !has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (empty($courseid) or !has_capability('moodle/grade:manage', context_system::instance())) {
|
||||
$mform->hardFreeze('standard');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ if ($courseid) {
|
|||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
if (empty($CFG->enableoutcomes)) {
|
||||
|
@ -49,10 +49,6 @@ if ($courseid) {
|
|||
|
||||
require_sesskey();
|
||||
|
||||
// $outcome = grade_outcome::fetch(array('id'=>$outcomeid));
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
header("Content-Type: text/csv; charset=utf-8");
|
||||
// TODO: make the filename more useful, include a date, a specific name, something...
|
||||
header('Content-Disposition: attachment; filename=outcomes.csv');
|
||||
|
|
|
@ -40,7 +40,7 @@ if ($courseid) {
|
|||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
if (empty($CFG->enableoutcomes)) {
|
||||
redirect('../../index.php?id='.$courseid);
|
||||
|
@ -49,7 +49,7 @@ if ($courseid) {
|
|||
} else {
|
||||
require_once $CFG->libdir.'/adminlib.php';
|
||||
admin_externalpage_setup('outcomes');
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = context_system::instance();
|
||||
}
|
||||
|
||||
require_capability('moodle/grade:manageoutcomes', $context);
|
||||
|
@ -79,7 +79,7 @@ if (!$upload_form->save_file('userfile', $imported_file, true)) {
|
|||
if (isset($courseid) && ($scope == 'custom')) {
|
||||
// custom scale
|
||||
$local_scope = true;
|
||||
} elseif (($scope == 'global') && has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
} elseif (($scope == 'global') && has_capability('moodle/grade:manage', context_system::instance())) {
|
||||
// global scale
|
||||
$local_scope = false;
|
||||
} else {
|
||||
|
|
|
@ -41,7 +41,7 @@ class import_outcomes_form extends moodleform {
|
|||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$scope = array();
|
||||
if (($PAGE->course->id > 1) && has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (($PAGE->course->id > 1) && has_capability('moodle/grade:manage', context_system::instance())) {
|
||||
$mform->addElement('radio', 'scope', get_string('importcustom', 'grades'), null, 'custom');
|
||||
$mform->addElement('radio', 'scope', get_string('importstandard', 'grades'), null, 'global');
|
||||
$mform->setDefault('scope', 'custom');
|
||||
|
|
|
@ -36,7 +36,7 @@ $PAGE->set_pagelayout('admin');
|
|||
if ($courseid) {
|
||||
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manageoutcomes', $context);
|
||||
|
||||
if (empty($CFG->enableoutcomes)) {
|
||||
|
@ -76,7 +76,7 @@ switch ($action) {
|
|||
}
|
||||
|
||||
if (empty($outcome->courseid)) {
|
||||
require_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('moodle/grade:manage', context_system::instance());
|
||||
} else if ($outcome->courseid != $courseid) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ switch ($action) {
|
|||
break;
|
||||
}
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$systemcontext = context_system::instance();
|
||||
$caneditsystemscales = has_capability('moodle/course:managescales', $systemcontext);
|
||||
|
||||
if ($courseid) {
|
||||
|
@ -138,7 +138,7 @@ if ($courseid and $outcomes = grade_outcome::fetch_all_local($courseid)) {
|
|||
} else if ($scale->courseid == $courseid) {
|
||||
$caneditthisscale = $caneditcoursescales;
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $scale->courseid);
|
||||
$context = context_course::instance($scale->courseid);
|
||||
$caneditthisscale = has_capability('moodle/course:managescales', $context);
|
||||
}
|
||||
if ($caneditthisscale) {
|
||||
|
@ -187,7 +187,7 @@ if ($outcomes = grade_outcome::fetch_all_global()) {
|
|||
} else if ($scale->courseid == $courseid) {
|
||||
$caneditthisscale = $caneditcoursescales;
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $scale->courseid);
|
||||
$context = context_course::instance($scale->courseid);
|
||||
$caneditthisscale = has_capability('moodle/course:managescales', $context);
|
||||
}
|
||||
if ($caneditthisscale) {
|
||||
|
@ -201,10 +201,10 @@ if ($outcomes = grade_outcome::fetch_all_global()) {
|
|||
$line[] = $outcome->get_item_uses_count();
|
||||
|
||||
$buttons = "";
|
||||
if (has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('moodle/grade:manage', context_system::instance())) {
|
||||
$buttons .= grade_button('edit', $courseid, $outcome);
|
||||
}
|
||||
if (has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM)) and $outcome->can_delete()) {
|
||||
if (has_capability('moodle/grade:manage', context_system::instance()) and $outcome->can_delete()) {
|
||||
$buttons .= grade_button('delete', $courseid, $outcome);
|
||||
}
|
||||
$line[] = $buttons;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
$row = $tabs = array();
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
|
||||
$row[] = new tabobject('courseoutcomes',
|
||||
$CFG->wwwroot.'/grade/edit/outcome/course.php?id='.$courseid,
|
||||
|
|
|
@ -33,7 +33,7 @@ $id = optional_param('id', 0, PARAM_INT);
|
|||
$PAGE->set_url('/grade/edit/scale/edit.php', array('id' => $id, 'courseid' => $courseid));
|
||||
$PAGE->set_pagelayout('admin');
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$systemcontext = context_system::instance();
|
||||
$heading = '';
|
||||
|
||||
// a bit complex access control :-O
|
||||
|
@ -50,7 +50,7 @@ if ($id) {
|
|||
print_error('invalidcourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
$courseid = $course->id;
|
||||
} else {
|
||||
|
@ -75,7 +75,7 @@ if ($id) {
|
|||
$scale_rec->standard = 0;
|
||||
$scale_rec->courseid = $courseid;
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
|
||||
} else {
|
||||
|
|
|
@ -88,7 +88,7 @@ class edit_scale_form extends moodleform {
|
|||
if (empty($courseid)) {
|
||||
$mform->hardFreeze('standard');
|
||||
|
||||
} else if (!has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
} else if (!has_capability('moodle/course:managescales', context_system::instance())) {
|
||||
//if they dont have managescales at system level the shouldnt be allowed to make scales standard (or not standard)
|
||||
$mform->hardFreeze('standard');
|
||||
|
||||
|
@ -102,7 +102,7 @@ class edit_scale_form extends moodleform {
|
|||
|
||||
} else {
|
||||
$mform->removeElement('used');
|
||||
if (empty($courseid) or !has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (empty($courseid) or !has_capability('moodle/course:managescales', context_system::instance())) {
|
||||
$mform->hardFreeze('standard');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ if ($courseid) {
|
|||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
} else {
|
||||
|
@ -69,7 +69,7 @@ switch ($action) {
|
|||
}
|
||||
|
||||
if (empty($scale->courseid)) {
|
||||
require_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('moodle/course:managescales', context_system::instance());
|
||||
} else if ($scale->courseid != $courseid) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
@ -147,10 +147,10 @@ if ($scales = grade_scale::fetch_all_global()) {
|
|||
$line[] = $used ? get_string('yes') : get_string('no');
|
||||
|
||||
$buttons = "";
|
||||
if (has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('moodle/course:managescales', context_system::instance())) {
|
||||
$buttons .= grade_button('edit', $courseid, $scale);
|
||||
}
|
||||
if (!$used and has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (!$used and has_capability('moodle/course:managescales', context_system::instance())) {
|
||||
$buttons .= grade_button('delete', $courseid, $scale);
|
||||
}
|
||||
$line[] = $buttons;
|
||||
|
|
|
@ -39,7 +39,7 @@ class course_settings_form extends moodleform {
|
|||
|
||||
$mform =& $this->_form;
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$systemcontext = context_system::instance();
|
||||
$can_view_admin_links = false;
|
||||
if (has_capability('moodle/grade:manage', $systemcontext)) {
|
||||
$can_view_admin_links = true;
|
||||
|
|
|
@ -36,7 +36,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
|||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
|||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
|
|
|
@ -43,7 +43,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
|||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
|
|
|
@ -42,7 +42,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
|||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
|
|
|
@ -50,7 +50,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
|||
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
if (!has_capability('moodle/grade:manage', $context)) {
|
||||
require_capability('moodle/grade:edit', $context);
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ class edit_grade_form extends moodleform {
|
|||
function definition_after_data() {
|
||||
global $CFG, $COURSE, $DB;
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
|
||||
$context = context_course::instance($COURSE->id);
|
||||
|
||||
$mform =& $this->_form;
|
||||
$grade_item = $this->_customdata['grade_item'];
|
||||
|
|
|
@ -47,7 +47,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
|||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// todo $PAGE->requires->js_module() should be used here instead
|
||||
|
|
|
@ -43,7 +43,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
|||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
|
|
|
@ -41,7 +41,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
|||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue