mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +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
|
@ -39,7 +39,7 @@ $newvalue = optional_param('newvalue', false, PARAM_MULTILANG);
|
|||
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_login($course);
|
||||
|
||||
switch ($action) {
|
||||
|
|
|
@ -46,7 +46,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('gradereport/grader:view', $context);
|
||||
require_capability('moodle/grade:viewall', $context);
|
||||
|
|
|
@ -107,7 +107,7 @@ class grade_report_grader extends grade_report {
|
|||
global $CFG;
|
||||
parent::__construct($courseid, $gpr, $context, $page);
|
||||
|
||||
$this->canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->course->id));
|
||||
$this->canviewhidden = has_capability('moodle/grade:viewhidden', context_course::instance($this->course->id));
|
||||
|
||||
// load collapsed settings for this report
|
||||
if ($collapsed = get_user_preferences('grade_report_grader_collapsed_categories')) {
|
||||
|
|
|
@ -40,8 +40,8 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
|||
|
||||
require_login($course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = context_course::instance($course->id);
|
||||
$systemcontext = context_system::instance();
|
||||
require_capability('gradereport/grader:view', $context);
|
||||
|
||||
require('preferences_form.php');
|
||||
|
|
|
@ -40,8 +40,7 @@ class grader_report_preferences_form extends moodleform {
|
|||
$mform =& $this->_form;
|
||||
$course = $this->_customdata['course'];
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
$canviewhidden = has_capability('moodle/grade:viewhidden', $context);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ if (!$item = $DB->get_record('grade_items', array('id' => $itemid))) {
|
|||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
require_capability('gradereport/grader:view', $context);
|
||||
require_capability('moodle/grade:viewall', $context);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
$row = $tabs = array();
|
||||
$tabcontext = get_context_instance(CONTEXT_COURSE, $COURSE->id);
|
||||
$tabcontext = context_course::instance($COURSE->id);
|
||||
$row[] = new tabobject('graderreport',
|
||||
$CFG->wwwroot.'/grade/report/grader/index.php?id='.$courseid,
|
||||
get_string('pluginname', 'gradereport_grader'));
|
||||
|
|
|
@ -33,7 +33,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);
|
||||
|
||||
/// find all accessible reports
|
||||
$reports = get_plugin_list('gradereport'); // Get all installed reports
|
||||
|
|
|
@ -35,7 +35,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('gradereport/outcomes:view', $context);
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
|||
}
|
||||
require_login($course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = context_course::instance($course->id);
|
||||
$systemcontext = context_system::instance();
|
||||
require_capability('gradereport/overview:view', $context);
|
||||
|
||||
if (empty($userid)) {
|
||||
|
@ -64,7 +64,7 @@ if (has_capability('moodle/grade:viewall', $systemcontext)) {
|
|||
//ok - can view own course grades
|
||||
$access = true;
|
||||
|
||||
} else if (has_capability('moodle/grade:viewall', get_context_instance(CONTEXT_USER, $userid)) and $course->showgrades) {
|
||||
} else if (has_capability('moodle/grade:viewall', context_user::instance($userid)) and $course->showgrades) {
|
||||
// ok - can view grades of this user- parent most probably
|
||||
$access = true;
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ class grade_report_overview extends grade_report {
|
|||
continue;
|
||||
}
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
|
||||
if (!$course->visible && !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
|
||||
// The course is hidden and the user isn't allowed to see it
|
||||
|
|
|
@ -39,7 +39,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
|||
require_login($course);
|
||||
$PAGE->set_pagelayout('report');
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('gradereport/user:view', $context);
|
||||
|
||||
if (empty($userid)) {
|
||||
|
@ -60,7 +60,7 @@ if (has_capability('moodle/grade:viewall', $context)) {
|
|||
//ok - can view own grades
|
||||
$access = true;
|
||||
|
||||
} else if (has_capability('moodle/grade:viewall', get_context_instance(CONTEXT_USER, $userid)) and $course->showgrades) {
|
||||
} else if (has_capability('moodle/grade:viewall', context_user::instance($userid)) and $course->showgrades) {
|
||||
// ok - can view grades of this user- parent most probably
|
||||
$access = true;
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ class grade_report_user extends grade_report {
|
|||
|
||||
$this->tabledata = array();
|
||||
|
||||
$this->canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->courseid));
|
||||
$this->canviewhidden = has_capability('moodle/grade:viewhidden', context_course::instance($this->courseid));
|
||||
|
||||
// get the user (for full name)
|
||||
$this->user = $DB->get_record('user', array('id' => $userid));
|
||||
|
@ -870,7 +870,7 @@ function grade_report_user_profilereport($course, $user) {
|
|||
global $OUTPUT;
|
||||
if (!empty($course->showgrades)) {
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
//first make sure we have proper final grades - this must be done before constructing of the grade tree
|
||||
grade_regrade_final_grades($course->id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue