Permalink
Browse files

MDL-34463 - lib - Alteration of the get_context_instance function to …

…utilize the new function context_XXXX::instance().
  • Loading branch information...
1 parent 3294034 commit d40604724b0c37333cb4c4848e7b9544452a1473 @abgreeve abgreeve committed Jul 24, 2012
Showing with 95 additions and 100 deletions.
  1. +1 −1 grade/edit/outcome/course.php
  2. +3 −3 grade/edit/outcome/edit.php
  3. +2 −2 grade/edit/outcome/edit_form.php
  4. +1 −5 grade/edit/outcome/export.php
  5. +3 −3 grade/edit/outcome/import.php
  6. +1 −1 grade/edit/outcome/import_outcomes_form.php
  7. +7 −7 grade/edit/outcome/index.php
  8. +1 −1 grade/edit/outcome/tabs.php
  9. +3 −3 grade/edit/scale/edit.php
  10. +2 −2 grade/edit/scale/edit_form.php
  11. +4 −4 grade/edit/scale/index.php
  12. +1 −1 grade/edit/settings/form.php
  13. +1 −1 grade/edit/settings/index.php
  14. +1 −1 grade/edit/tree/action.php
  15. +1 −1 grade/edit/tree/calculation.php
  16. +1 −1 grade/edit/tree/category.php
  17. +1 −1 grade/edit/tree/grade.php
  18. +1 −1 grade/edit/tree/grade_form.php
  19. +1 −1 grade/edit/tree/index.php
  20. +1 −1 grade/edit/tree/item.php
  21. +1 −1 grade/edit/tree/outcomeitem.php
  22. +1 −1 grade/export/grade_export_form.php
  23. +1 −1 grade/export/key.php
  24. +1 −1 grade/export/keymanager.php
  25. +1 −1 grade/export/ods/dump.php
  26. +1 −1 grade/export/ods/export.php
  27. +1 −1 grade/export/ods/grade_export_ods.php
  28. +1 −1 grade/export/ods/index.php
  29. +1 −1 grade/export/txt/dump.php
  30. +1 −1 grade/export/txt/export.php
  31. +1 −1 grade/export/txt/grade_export_txt.php
  32. +1 −1 grade/export/txt/index.php
  33. +1 −1 grade/export/xls/dump.php
  34. +1 −1 grade/export/xls/export.php
  35. +1 −1 grade/export/xls/grade_export_xls.php
  36. +1 −1 grade/export/xls/index.php
  37. +1 −1 grade/export/xml/dump.php
  38. +1 −1 grade/export/xml/export.php
  39. +1 −1 grade/export/xml/grade_export_xml.php
  40. +1 −1 grade/export/xml/index.php
  41. +1 −1 grade/import/csv/index.php
  42. +1 −1 grade/import/key.php
  43. +1 −1 grade/import/keymanager.php
  44. +2 −2 grade/import/lib.php
  45. +1 −1 grade/import/xml/fetch.php
  46. +1 −1 grade/import/xml/import.php
  47. +1 −1 grade/import/xml/index.php
  48. +12 −12 grade/lib.php
  49. +1 −1 grade/report/grader/ajax_callbacks.php
  50. +1 −1 grade/report/grader/index.php
  51. +1 −1 grade/report/grader/lib.php
  52. +2 −2 grade/report/grader/preferences.php
  53. +1 −2 grade/report/grader/preferences_form.php
  54. +1 −1 grade/report/grader/quickedit_item.php
  55. +1 −1 grade/report/grader/tabs.php
  56. +1 −1 grade/report/index.php
  57. +1 −1 grade/report/outcomes/index.php
  58. +3 −3 grade/report/overview/index.php
  59. +1 −1 grade/report/overview/lib.php
  60. +2 −2 grade/report/user/index.php
  61. +2 −2 grade/report/user/lib.php
@@ -34,7 +34,7 @@
/// 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 @@
$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 @@
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 @@
/// 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 @@ function definition_after_data() {
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 @@ function definition_after_data() {
} 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 @@
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 @@
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 @@
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 @@
} 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 (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 @@ public function definition() {
$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 @@
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 @@
}
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 @@
break;
}
-$systemcontext = get_context_instance(CONTEXT_SYSTEM);
+$systemcontext = context_system::instance();
$caneditsystemscales = has_capability('moodle/course:managescales', $systemcontext);
if ($courseid) {
@@ -138,7 +138,7 @@
} 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 @@
} 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 @@
$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 @@
$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 @@
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 @@
$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 @@ function definition_after_data() {
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 @@ function definition_after_data() {
} 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 @@
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 @@
}
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 @@
$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 @@ function definition() {
$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 @@
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 @@
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 @@
}
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 @@
}
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 @@
$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 @@ function definition() {
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 @@
}
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
View
@@ -43,7 +43,7 @@
}
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 @@
}
require_login($course);
-$context = get_context_instance(CONTEXT_COURSE, $course->id);
+$context = context_course::instance($course->id);
require_capability('moodle/grade:manage', $context);
@@ -119,7 +119,7 @@ function definition() {
if ($grade_items = $gseq->items) {
$needs_multiselect = false;
- $canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $COURSE->id));
+ $canviewhidden = has_capability('moodle/grade:viewhidden', context_course::instance($COURSE->id));
foreach ($grade_items as $grade_item) {
// Is the grade_item hidden? If so, can the user see hidden grade_items?
View
@@ -59,7 +59,7 @@
$key->courseid = $course->id;
require_login($course);
-$context = get_context_instance(CONTEXT_COURSE, $course->id);
+$context = context_course::instance($course->id);
require_capability('moodle/grade:export', $context);
// extra security check
@@ -35,7 +35,7 @@
}
require_login($course);
-$context = get_context_instance(CONTEXT_COURSE, $id);
+$context = context_course::instance($id);
require_capability('moodle/grade:export', $context);
@@ -29,7 +29,7 @@
print_error('gradepubdisable');
}
-$context = get_context_instance(CONTEXT_COURSE, $id);
+$context = context_course::instance($id);
require_capability('gradeexport/ods:publish', $context);
// use the same page parameters as export.php and append &key=sdhakjsahdksahdkjsahksadjksahdkjsadhksa
@@ -33,7 +33,7 @@
}
require_login($course);
-$context = get_context_instance(CONTEXT_COURSE, $id);
+$context = context_course::instance($id);
require_capability('moodle/grade:export', $context);
require_capability('gradeexport/ods:view', $context);
@@ -32,7 +32,7 @@ function print_grades() {
$strgrades = get_string('grades');
- $shortname = format_string($this->course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $this->course->id)));
+ $shortname = format_string($this->course->shortname, true, array('context' => context_course::instance($this->course->id)));
// Calculate file name
$downloadfilename = clean_filename("$shortname $strgrades.ods");
Oops, something went wrong.

0 comments on commit d406047

Please sign in to comment.