From 0601e0eef60a0f3b7ba543d997dcbb3f50bc7243 Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Wed, 3 Jul 2013 14:39:10 +0800 Subject: [PATCH] MDL-40402 libraries: Replace get_system_context() with context_system::instance() in core --- admin/tool/capability/index.php | 2 +- admin/tool/customlang/edit.php | 2 +- admin/tool/customlang/index.php | 8 ++++---- admin/tool/generator/index.php | 2 +- auth/mnet/auth.php | 2 +- cache/locallib.php | 2 +- calendar/lib.php | 4 ++-- course/editcategory.php | 2 +- course/editcategory_form.php | 2 +- enrol/externallib.php | 2 +- error/index.php | 2 +- files/externallib.php | 2 +- grade/grading/lib.php | 2 +- lib/adminlib.php | 4 ++-- lib/navigationlib.php | 8 ++++---- lib/setup.php | 2 +- lib/tests/accesslib_test.php | 2 +- lib/tests/moodlelib_test.php | 2 +- login/token.php | 4 ++-- mnet/service/enrol/index.php | 2 +- mnet/service/enrol/locallib.php | 2 +- mod/assign/adminmanageplugins.php | 2 +- mod/data/db/upgrade.php | 2 +- mod/feedback/delete_template.php | 4 ++-- mod/feedback/edit.php | 2 +- mod/feedback/edit_form.php | 2 +- mod/feedback/item/label/lib.php | 2 +- mod/feedback/lib.php | 6 +++--- mod/forum/user.php | 4 ++-- portfolio/add.php | 2 +- repository/draftfiles_ajax.php | 2 +- repository/filepicker.php | 2 +- repository/filesystem/lib.php | 6 +++--- repository/flickr_public/lib.php | 2 +- repository/lib.php | 6 +++--- repository/repository_ajax.php | 2 +- tag/coursetags_more.php | 2 +- tag/coursetagslib.php | 2 +- user/edit.php | 2 +- user/externallib.php | 2 +- 40 files changed, 57 insertions(+), 57 deletions(-) diff --git a/admin/tool/capability/index.php b/admin/tool/capability/index.php index 3f9c58edd0c85..e0a0e66509544 100644 --- a/admin/tool/capability/index.php +++ b/admin/tool/capability/index.php @@ -190,7 +190,7 @@ function print_report_tree($contextid, $contexts, $allroles) { // Start the list item, and print the context name as a link to the place to // make changes. - if ($contextid == get_system_context()->id) { + if ($contextid == context_system::instance()->id) { $url = "$CFG->wwwroot/$CFG->admin/roles/manage.php"; $title = get_string('changeroles', 'tool_capability'); } else { diff --git a/admin/tool/customlang/edit.php b/admin/tool/customlang/edit.php index 57d3859e92a0d..6aaec2fe73f8a 100644 --- a/admin/tool/customlang/edit.php +++ b/admin/tool/customlang/edit.php @@ -26,7 +26,7 @@ require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/filter_form.php'); require_login(SITEID, false); -require_capability('tool/customlang:edit', get_system_context()); +require_capability('tool/customlang:edit', context_system::instance()); $lng = required_param('lng', PARAM_LANG); $currentpage = optional_param('p', 0, PARAM_INT); diff --git a/admin/tool/customlang/index.php b/admin/tool/customlang/index.php index 28dae19854761..aff45ef46eced 100644 --- a/admin/tool/customlang/index.php +++ b/admin/tool/customlang/index.php @@ -30,7 +30,7 @@ require_once($CFG->libdir.'/adminlib.php'); require_login(SITEID, false); -require_capability('tool/customlang:view', get_system_context()); +require_capability('tool/customlang:view', context_system::instance()); $action = optional_param('action', '', PARAM_ALPHA); $confirm = optional_param('confirm', false, PARAM_BOOL); @@ -42,7 +42,7 @@ // pre-output actions if ($action === 'checkout') { require_sesskey(); - require_capability('tool/customlang:edit', get_system_context()); + require_capability('tool/customlang:edit', context_system::instance()); if (empty($lng)) { print_error('missingparameter'); } @@ -66,7 +66,7 @@ if ($action === 'checkin') { require_sesskey(); - require_capability('tool/customlang:edit', get_system_context()); + require_capability('tool/customlang:edit', context_system::instance()); if (empty($lng)) { print_error('missingparameter'); } @@ -119,7 +119,7 @@ } $menu = array(); -if (has_capability('tool/customlang:edit', get_system_context())) { +if (has_capability('tool/customlang:edit', context_system::instance())) { $menu['checkout'] = array( 'title' => get_string('checkout', 'tool_customlang'), 'url' => new moodle_url($PAGE->url, array('action' => 'checkout', 'lng' => $lng)), diff --git a/admin/tool/generator/index.php b/admin/tool/generator/index.php index 577fefcf99d41..f77c8e0e1af6d 100644 --- a/admin/tool/generator/index.php +++ b/admin/tool/generator/index.php @@ -39,7 +39,7 @@ } $PAGE->set_url('/admin/tool/generator/index.php'); -$PAGE->set_context(get_system_context()); +$PAGE->set_context(context_system::instance()); $PAGE->set_pagelayout('base'); $generator = new generator_web(); $generator->setup(); diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php index db7328bd9f8b1..c1861fac43ea1 100644 --- a/auth/mnet/auth.php +++ b/auth/mnet/auth.php @@ -146,7 +146,7 @@ function start_jump_session($mnethostid, $wantsurl, $wantsurlbackhere=false) { } // check remote login permissions - if (! has_capability('moodle/site:mnetlogintoremote', get_system_context()) + if (! has_capability('moodle/site:mnetlogintoremote', context_system::instance()) or is_mnet_remote_user($USER) or isguestuser() or !isloggedin()) { diff --git a/cache/locallib.php b/cache/locallib.php index 8124fdc76a9cc..8e4cc319fbc7e 100644 --- a/cache/locallib.php +++ b/cache/locallib.php @@ -901,7 +901,7 @@ public static function get_definition_actions(context $context, array $definitio */ public static function get_store_instance_actions($name, array $storedetails) { $actions = array(); - if (has_capability('moodle/site:config', get_system_context())) { + if (has_capability('moodle/site:config', context_system::instance())) { $baseurl = new moodle_url('/cache/admin.php', array('store' => $name, 'sesskey' => sesskey())); if (empty($storedetails['default'])) { $actions[] = array( diff --git a/calendar/lib.php b/calendar/lib.php index 371b7ecb9668f..bbcd41a83c530 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -1469,7 +1469,7 @@ function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false) { } } if ($group === false) { - if (!empty($CFG->calendar_adminseesall) && has_any_capability($allgroupscaps, get_system_context())) { + if (!empty($CFG->calendar_adminseesall) && has_any_capability($allgroupscaps, context_system::instance())) { $group = true; } else if ($isloggedin) { $groupids = array(); @@ -1790,7 +1790,7 @@ function calendar_set_event_type_display($type, $display = null, $user = null) { function calendar_get_allowed_types(&$allowed, $course = null) { global $USER, $CFG, $DB; $allowed = new stdClass(); - $allowed->user = has_capability('moodle/calendar:manageownentries', get_system_context()); + $allowed->user = has_capability('moodle/calendar:manageownentries', context_system::instance()); $allowed->groups = false; // This may change just below $allowed->courses = false; // This may change just below $allowed->site = has_capability('moodle/calendar:manageentries', context_course::instance(SITEID)); diff --git a/course/editcategory.php b/course/editcategory.php index f2dfd034ff825..a2de1f173319d 100644 --- a/course/editcategory.php +++ b/course/editcategory.php @@ -57,7 +57,7 @@ } $context = context_coursecat::instance($parent); } else { - $context = get_system_context(); + $context = context_system::instance(); } $PAGE->set_context($context); $category = new stdClass(); diff --git a/course/editcategory_form.php b/course/editcategory_form.php index 316c48b9aedcc..4e0db04ba0dce 100644 --- a/course/editcategory_form.php +++ b/course/editcategory_form.php @@ -16,7 +16,7 @@ function definition() { // get list of categories to use as parents, with site as the first one $options = array(); - if (has_capability('moodle/category:manage', get_system_context()) || $category->parent == 0) { + if (has_capability('moodle/category:manage', context_system::instance()) || $category->parent == 0) { $options[0] = get_string('top'); } if ($category->id) { diff --git a/enrol/externallib.php b/enrol/externallib.php index 8f4ef7f0efb2c..bd4f334beb91b 100644 --- a/enrol/externallib.php +++ b/enrol/externallib.php @@ -426,7 +426,7 @@ public static function get_enrolled_users($courseid, $options = array()) { $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); $coursecontext = context_course::instance($courseid, IGNORE_MISSING); if ($courseid == SITEID) { - $context = get_system_context(); + $context = context_system::instance(); } else { $context = $coursecontext; } diff --git a/error/index.php b/error/index.php index 6798a48f475aa..84b24287cfe5f 100644 --- a/error/index.php +++ b/error/index.php @@ -51,7 +51,7 @@ $PAGE->set_url('/error/'); $PAGE->set_title($site->fullname .':Error'); $PAGE->set_heading($site->fullname .': Error 404'); - $PAGE->set_context(get_system_context()); + $PAGE->set_context(context_system::instance()); $PAGE->navbar->add('Error 404 - File not Found'); echo $OUTPUT->header(); echo $OUTPUT->box(get_string('pagenotexist', 'error'). '
'.s($requesturi), 'generalbox boxaligncenter'); diff --git a/files/externallib.php b/files/externallib.php index 0b1d9e6f42db3..54cb292a8508b 100644 --- a/files/externallib.php +++ b/files/externallib.php @@ -80,7 +80,7 @@ public static function get_files($contextid, $component, $filearea, $itemid, $fi $browser = get_file_browser(); if (empty($fileinfo['contextid'])) { - $context = get_system_context(); + $context = context_system::instance(); } else { $context = context::instance_by_id($fileinfo['contextid']); } diff --git a/grade/grading/lib.php b/grade/grading/lib.php index 637a5834c6241..70451da16ebf8 100644 --- a/grade/grading/lib.php +++ b/grade/grading/lib.php @@ -35,7 +35,7 @@ * * @category grading * @example $manager = get_grading_manager($areaid); - * @example $manager = get_grading_manager(get_system_context()); + * @example $manager = get_grading_manager(context_system::instance()); * @example $manager = get_grading_manager($context, 'mod_assignment', 'submission'); * @param stdClass|int|null $context_or_areaid if $areaid is passed, no other parameter is needed * @param string|null $component the frankenstyle name of the component diff --git a/lib/adminlib.php b/lib/adminlib.php index 1276b4172b7b7..4a76f82c16414 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -6959,7 +6959,7 @@ public function output_html($data, $query='') { // Calculate number of instances in order to display them for the Moodle administrator if (!empty($instanceoptionnames)) { $params = array(); - $params['context'] = array(get_system_context()); + $params['context'] = array(context_system::instance()); $params['onlyvisible'] = false; $params['type'] = $typename; $admininstancenumber = count(repository::static_function($typename, 'get_instances', $params)); @@ -7117,7 +7117,7 @@ private function set_protocol_cap($status) { $assign = true; } if (!empty($assign)) { - $systemcontext = get_system_context(); + $systemcontext = context_system::instance(); assign_capability('webservice/xmlrpc:use', $permission, $CFG->defaultuserroleid, $systemcontext->id, true); assign_capability('webservice/rest:use', $permission, $CFG->defaultuserroleid, $systemcontext->id, true); } diff --git a/lib/navigationlib.php b/lib/navigationlib.php index c691a83ef6491..ee018aba61219 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -1725,7 +1725,7 @@ protected function add_category(stdClass $category, navigation_node $parent, $no $categoryname = format_string($category->name, true, array('context' => $context)); $categorynode = $parent->add($categoryname, $url, $nodetype, $categoryname, $category->id); if (empty($category->visible)) { - if (has_capability('moodle/category:viewhiddencategories', get_system_context())) { + if (has_capability('moodle/category:viewhiddencategories', context_system::instance())) { $categorynode->hidden = true; } else { $categorynode->display = false; @@ -2484,7 +2484,7 @@ public function add_front_page_course_essentials(navigation_node $coursenode, st $coursenode->add('frontpageloaded', null, self::TYPE_CUSTOM, null, 'frontpageloaded')->display = false; //Participants - if (has_capability('moodle/course:viewparticipants', get_system_context())) { + if (has_capability('moodle/course:viewparticipants', context_system::instance())) { $coursenode->add(get_string('participants'), new moodle_url('/user/index.php?id='.$course->id), self::TYPE_CUSTOM, get_string('participants'), 'participants'); } @@ -3913,7 +3913,7 @@ protected function generate_user_settings($courseid, $userid, $gstitle='usercurr } $coursecontext = context_course::instance($course->id); // Course context - $systemcontext = get_system_context(); + $systemcontext = context_system::instance(); $currentuser = ($USER->id == $userid); if ($currentuser) { @@ -4059,7 +4059,7 @@ protected function generate_user_settings($courseid, $userid, $gstitle='usercurr $enablemanagetokens = true; } else if (!is_siteadmin($USER->id) && !empty($CFG->enablewebservices) - && has_capability('moodle/webservice:createtoken', get_system_context()) ) { + && has_capability('moodle/webservice:createtoken', context_system::instance()) ) { $enablemanagetokens = true; } // Security keys diff --git a/lib/setup.php b/lib/setup.php index bd590d7bf2d1f..d42429f0edf5e 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -717,7 +717,7 @@ function stripslashes_deep($value) { // define SYSCONTEXTID in config.php if you want to save some queries, // after install it must match the system context record id. if (!defined('SYSCONTEXTID')) { - get_system_context(); + context_system::instance(); } // Defining the site - aka frontpage course diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index 21be098462b01..0dce62eac6a6b 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -2348,7 +2348,7 @@ public function test_permission_evaluation() { // ================================================================= // note: watch out, the fake site might be pretty borked already - $this->assertSame(get_system_context(), context_system::instance()); + $this->assertSame(context_system::instance(), context_system::instance()); foreach ($DB->get_records('context') as $contextid=>$record) { $context = context::instance_by_id($contextid); diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index 36e4df34a239d..627d8f886ff7a 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -2283,7 +2283,7 @@ public function test_convert_to_array() { $this->assertEquals(convert_to_array($obj), (array)$obj); // check that context object (with iterator) is converted to array properly - $obj = get_system_context(); + $obj = context_system::instance(); $ar = array( 'id' => $obj->id, 'contextlevel' => $obj->contextlevel, diff --git a/login/token.php b/login/token.php index f61081c8e15f9..6839cc0df9735 100644 --- a/login/token.php +++ b/login/token.php @@ -146,9 +146,9 @@ if (count($tokens) > 0) { $token = array_pop($tokens); } else { - if ( ($serviceshortname == MOODLE_OFFICIAL_MOBILE_SERVICE and has_capability('moodle/webservice:createmobiletoken', get_system_context())) + if ( ($serviceshortname == MOODLE_OFFICIAL_MOBILE_SERVICE and has_capability('moodle/webservice:createmobiletoken', context_system::instance())) //Note: automatically token generation is not available to admin (they must create a token manually) - or (!is_siteadmin($user) && has_capability('moodle/webservice:createtoken', get_system_context()))) { + or (!is_siteadmin($user) && has_capability('moodle/webservice:createtoken', context_system::instance()))) { // if service doesn't exist, dml will throw exception $service_record = $DB->get_record('external_services', array('shortname'=>$serviceshortname, 'enabled'=>1), '*', MUST_EXIST); // create a new token diff --git a/mnet/service/enrol/index.php b/mnet/service/enrol/index.php index 221a28fa13a40..d4b6bd9fbe667 100644 --- a/mnet/service/enrol/index.php +++ b/mnet/service/enrol/index.php @@ -40,7 +40,7 @@ die(); } -$roamingusers = get_users_by_capability(get_system_context(), 'moodle/site:mnetlogintoremote', 'u.id'); +$roamingusers = get_users_by_capability(context_system::instance(), 'moodle/site:mnetlogintoremote', 'u.id'); if (empty($roamingusers)) { $capname = get_string('site:mnetlogintoremote', 'role'); $url = new moodle_url('/admin/roles/manage.php'); diff --git a/mnet/service/enrol/locallib.php b/mnet/service/enrol/locallib.php index 50494daf90eaf..8f4e527a42d69 100644 --- a/mnet/service/enrol/locallib.php +++ b/mnet/service/enrol/locallib.php @@ -552,7 +552,7 @@ public function __construct($name, $options) { public function find_users($search) { global $CFG, $DB; - $systemcontext = get_system_context(); + $systemcontext = context_system::instance(); $userids = get_users_by_capability($systemcontext, 'moodle/site:mnetlogintoremote', 'u.id'); if (empty($userids)) { diff --git a/mod/assign/adminmanageplugins.php b/mod/assign/adminmanageplugins.php index 7ddcd715bf294..9c6ab63f1aac9 100644 --- a/mod/assign/adminmanageplugins.php +++ b/mod/assign/adminmanageplugins.php @@ -28,7 +28,7 @@ // Create the class for this controller. $pluginmanager = new assign_plugin_manager(required_param('subtype', PARAM_PLUGIN)); -$PAGE->set_context(get_system_context()); +$PAGE->set_context(context_system::instance()); // Execute the controller. $pluginmanager->execute(optional_param('action', null, PARAM_PLUGIN), diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index 9334c1a689e31..c33fcc452aedb 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -40,7 +40,7 @@ function xmldb_data_upgrade($oldversion) { // Get directory contents. $userfolders = new DirectoryIterator($oldpresetdir); // Store the system context, these are site wide presets. - $context = get_system_context(); + $context = context_system::instance(); // Create file storage object. $fs = get_file_storage(); // Create array of accepted files. diff --git a/mod/feedback/delete_template.php b/mod/feedback/delete_template.php index 289f208432441..de240d81cdfaf 100644 --- a/mod/feedback/delete_template.php +++ b/mod/feedback/delete_template.php @@ -93,7 +93,7 @@ } if ($template->ispublic) { - $systemcontext = get_system_context(); + $systemcontext = context_system::instance(); require_capability('mod/feedback:createpublictemplate', $systemcontext); require_capability('mod/feedback:deletetemplate', $systemcontext); } @@ -164,7 +164,7 @@ echo $OUTPUT->box_end(); } //now we get the public templates if it is permitted - $systemcontext = get_system_context(); + $systemcontext = context_system::instance(); if (has_capability('mod/feedback:createpublictemplate', $systemcontext) AND has_capability('mod/feedback:deletetemplate', $systemcontext)) { $templates = feedback_get_template_list($course, 'public'); diff --git a/mod/feedback/edit.php b/mod/feedback/edit.php index cdab171873d5e..f8af903bb9089 100644 --- a/mod/feedback/edit.php +++ b/mod/feedback/edit.php @@ -110,7 +110,7 @@ $savereturn = 'notsaved_name'; } else { //If the feedback is located on the frontpage then templates can be public. - if (has_capability('mod/feedback:createpublictemplate', get_system_context())) { + if (has_capability('mod/feedback:createpublictemplate', context_system::instance())) { $create_template_formdata->ispublic = isset($create_template_formdata->ispublic) ? 1 : 0; } else { $create_template_formdata->ispublic = 0; diff --git a/mod/feedback/edit_form.php b/mod/feedback/edit_form.php index 9faf394a0766c..7541f9b670cca 100644 --- a/mod/feedback/edit_form.php +++ b/mod/feedback/edit_form.php @@ -178,7 +178,7 @@ public function set_form_elements() { get_string('name', 'feedback'), array('size'=>'40', 'maxlength'=>'200')); - if (has_capability('mod/feedback:createpublictemplate', get_system_context())) { + if (has_capability('mod/feedback:createpublictemplate', context_system::instance())) { $elementgroup[] = $mform->createElement('checkbox', 'ispublic', get_string('public', 'feedback'), diff --git a/mod/feedback/item/label/lib.php b/mod/feedback/item/label/lib.php index 350bbcec11277..6b6d44937439a 100644 --- a/mod/feedback/item/label/lib.php +++ b/mod/feedback/item/label/lib.php @@ -146,7 +146,7 @@ public function print_item($item) { if (!$item->feedback AND $item->template) { $template = $DB->get_record('feedback_template', array('id'=>$item->template)); if ($template->ispublic) { - $context = get_system_context(); + $context = context_system::instance(); } else { $context = context_course::instance($template->course); } diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index 2490c3d411655..1bc946da9ab1c 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -1118,7 +1118,7 @@ function feedback_save_as_template($feedback, $name, $ispublic = 0) { //if the template is public the files are in the system context //files in the feedback_item are in the feedback_context of the feedback if ($ispublic) { - $s_context = get_system_context(); + $s_context = context_system::instance(); } else { $s_context = context_course::instance($newtempl->course); } @@ -1223,7 +1223,7 @@ function feedback_items_from_template($feedback, $templateid, $deleteold = false //files in the template_item are in the context of the current course //files in the feedback_item are in the feedback_context of the feedback if ($template->ispublic) { - $s_context = get_system_context(); + $s_context = context_system::instance(); } else { $s_context = context_course::instance($feedback->course); } @@ -1526,7 +1526,7 @@ function feedback_delete_item($itemid, $renumber = true, $template = false) { if ($template) { if ($template->ispublic) { - $context = get_system_context(); + $context = context_system::instance(); } else { $context = context_course::instance($template->course); } diff --git a/mod/forum/user.php b/mod/forum/user.php index 25ad9a39b973b..0059ae8a2899a 100644 --- a/mod/forum/user.php +++ b/mod/forum/user.php @@ -75,7 +75,7 @@ // Make sure the user has not been deleted if ($user->deleted) { $PAGE->set_title(get_string('userdeleted')); - $PAGE->set_context(get_system_context()); + $PAGE->set_context(context_system::instance()); echo $OUTPUT->header(); echo $OUTPUT->heading($PAGE->title); echo $OUTPUT->footer(); @@ -110,7 +110,7 @@ // We are going to search for all of the users posts in all courses! // a general require login here as we arn't actually within any course. require_login(); - $PAGE->set_context(get_system_context()); + $PAGE->set_context(context_system::instance()); // Now we need to get all of the courses to search. // All courses where the user has posted within a forum will be returned. diff --git a/portfolio/add.php b/portfolio/add.php index 8a22e6fc60332..ca77b8347bbc2 100644 --- a/portfolio/add.php +++ b/portfolio/add.php @@ -47,7 +47,7 @@ $callerformats = optional_param('callerformats', null, PARAM_TAGLIST); // Comma separated list of formats the specific place exporting content supports. require_login(); // this is selectively called again with $course later when we know for sure which one we're in. -$PAGE->set_context(get_system_context()); +$PAGE->set_context(context_system::instance()); $PAGE->set_url('/portfolio/add.php', array('id' => $dataid, 'sesskey' => sesskey())); $PAGE->set_pagelayout('standard'); $exporter = null; diff --git a/repository/draftfiles_ajax.php b/repository/draftfiles_ajax.php index e50544ab83690..dbd96675fa536 100644 --- a/repository/draftfiles_ajax.php +++ b/repository/draftfiles_ajax.php @@ -30,7 +30,7 @@ require_once($CFG->libdir.'/filelib.php'); require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->dirroot.'/repository/lib.php'); -$PAGE->set_context(get_system_context()); +$PAGE->set_context(context_system::instance()); require_login(); if (isguestuser()) { print_error('noguest'); diff --git a/repository/filepicker.php b/repository/filepicker.php index bd19ef7f73be7..40046553727dc 100644 --- a/repository/filepicker.php +++ b/repository/filepicker.php @@ -377,7 +377,7 @@ default: case 'plugins': $params = array(); - $params['context'] = array($user_context, get_system_context()); + $params['context'] = array($user_context, context_system::instance()); $params['currentcontext'] = $PAGE->context; $params['return_types'] = FILE_INTERNAL; diff --git a/repository/filesystem/lib.php b/repository/filesystem/lib.php index a5ffca8a6d050..522fe52a44f63 100644 --- a/repository/filesystem/lib.php +++ b/repository/filesystem/lib.php @@ -190,7 +190,7 @@ public function set_option($options = array()) { public static function instance_config_form($mform) { global $CFG, $PAGE; - if (has_capability('moodle/site:config', get_system_context())) { + if (has_capability('moodle/site:config', context_system::instance())) { $path = $CFG->dataroot . '/repository/'; if (!is_dir($path)) { mkdir($path, $CFG->directorypermissions, true); @@ -222,10 +222,10 @@ public static function instance_config_form($mform) { public static function create($type, $userid, $context, $params, $readonly=0) { global $PAGE; - if (has_capability('moodle/site:config', get_system_context())) { + if (has_capability('moodle/site:config', context_system::instance())) { return parent::create($type, $userid, $context, $params, $readonly); } else { - require_capability('moodle/site:config', get_system_context()); + require_capability('moodle/site:config', context_system::instance()); return false; } } diff --git a/repository/flickr_public/lib.php b/repository/flickr_public/lib.php index a0a5c7213dbf6..48458d757cae3 100644 --- a/repository/flickr_public/lib.php +++ b/repository/flickr_public/lib.php @@ -529,7 +529,7 @@ public static function get_type_option_names() { public static function plugin_init() { //here we create a default instance for this type - $id = repository::static_function('flickr_public','create', 'flickr_public', 0, get_system_context(), array('name'=>'', 'email_address' => null, 'usewatermarks' => false), 0); + $id = repository::static_function('flickr_public','create', 'flickr_public', 0, context_system::instance(), array('name'=>'', 'email_address' => null, 'usewatermarks' => false), 0); if (empty($id)) { return false; } else { diff --git a/repository/lib.php b/repository/lib.php index 0e28f1c3fa881..bb25071665b88 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -251,7 +251,7 @@ public function create($silent = false) { // for it $instanceoptions['name'] = $this->_options['pluginname']; } - repository::static_function($this->_typename, 'create', $this->_typename, 0, get_system_context(), $instanceoptions); + repository::static_function($this->_typename, 'create', $this->_typename, 0, context_system::instance(), $instanceoptions); } //run plugin_init function if (!repository::static_function($this->_typename, 'plugin_init')) { @@ -958,7 +958,7 @@ public static function append_suffix($filename) { public static function get_editable_types($context = null) { if (empty($context)) { - $context = get_system_context(); + $context = context_system::instance(); } $types= repository::get_types(true); @@ -3142,7 +3142,7 @@ function initialise_filepicker($args) { $user_context = context_user::instance($USER->id); list($context, $course, $cm) = get_context_info_array($context->id); - $contexts = array($user_context, get_system_context()); + $contexts = array($user_context, context_system::instance()); if (!empty($course)) { // adding course context $contexts[] = context_course::instance($course->id); diff --git a/repository/repository_ajax.php b/repository/repository_ajax.php index d2b1dec2c4a4f..162bbe3bfea52 100644 --- a/repository/repository_ajax.php +++ b/repository/repository_ajax.php @@ -94,7 +94,7 @@ // global search case 'gsearch': $params = array(); - $params['context'] = array(context::instance_by_id($contextid), get_system_context()); + $params['context'] = array(context::instance_by_id($contextid), context_system::instance()); $params['currentcontext'] = context::instance_by_id($contextid); $repos = repository::get_instances($params); $list = array(); diff --git a/tag/coursetags_more.php b/tag/coursetags_more.php index da4d25e2fabd3..cbfeaefd6d902 100644 --- a/tag/coursetags_more.php +++ b/tag/coursetags_more.php @@ -67,7 +67,7 @@ if ($courseid) { $PAGE->set_context(context_course::instance($courseid)); } else { - $PAGE->set_context(get_system_context()); + $PAGE->set_context(context_system::instance()); } // Language strings diff --git a/tag/coursetagslib.php b/tag/coursetagslib.php index 97c27333e631d..4ba4b86b2a58e 100644 --- a/tag/coursetagslib.php +++ b/tag/coursetagslib.php @@ -401,7 +401,7 @@ function coursetag_delete_course_tags($courseid, $showfeedback=false) { $DB->delete_records('tag', array('id'=>$tag->tagid)); // Delete files $fs = get_file_storage(); - $fs->delete_area_files(get_system_context()->id, 'tag', 'description', $tag->tagid); + $fs->delete_area_files(context_system::instance()->id, 'tag', 'description', $tag->tagid); } } } diff --git a/user/edit.php b/user/edit.php index 4e34c646117cc..49758e2df5430 100644 --- a/user/edit.php +++ b/user/edit.php @@ -50,7 +50,7 @@ } redirect(get_login_url()); } else { - $PAGE->set_context(get_system_context()); + $PAGE->set_context(context_system::instance()); $PAGE->set_pagelayout('standard'); } diff --git a/user/externallib.php b/user/externallib.php index a327dcc2f1f0d..e21ed8c775001 100644 --- a/user/externallib.php +++ b/user/externallib.php @@ -678,7 +678,7 @@ public static function get_users_by_id($userids) { $users = $DB->get_recordset_sql($usersql, $params); $result = array(); - $hasuserupdatecap = has_capability('moodle/user:update', get_system_context()); + $hasuserupdatecap = has_capability('moodle/user:update', context_system::instance()); foreach ($users as $user) { if (!empty($user->deleted)) { continue;