diff --git a/admin/tool/capability/index.php b/admin/tool/capability/index.php index 3f9c58edd0c..e0a0e665095 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 57d3859e92a..6aaec2fe73f 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/locallib.php'); 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 28dae198547..aff45ef46ec 100644 --- a/admin/tool/customlang/index.php +++ b/admin/tool/customlang/index.php @@ -30,7 +30,7 @@ require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/locallib.php'); 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 @@ $langs = get_string_manager()->get_list_of_translations(); // 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 === 'checkout') { 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 @@ if ($numofmodified != 0) { } $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 577fefcf99d..f77c8e0e1af 100644 --- a/admin/tool/generator/index.php +++ b/admin/tool/generator/index.php @@ -39,7 +39,7 @@ if (!debugging('', DEBUG_DEVELOPER)) { } $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 db7328bd9f8..c1861fac43e 100644 --- a/auth/mnet/auth.php +++ b/auth/mnet/auth.php @@ -146,7 +146,7 @@ class auth_plugin_mnet extends auth_plugin_base { } // 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 e66384d6f94..2e6c0185922 100644 --- a/cache/locallib.php +++ b/cache/locallib.php @@ -903,7 +903,7 @@ abstract class cache_administration_helper extends cache_helper { */ 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 371b7ecb966..bbcd41a83c5 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 f2dfd034ff8..a2de1f17331 100644 --- a/course/editcategory.php +++ b/course/editcategory.php @@ -57,7 +57,7 @@ if ($id) { } $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 316c48b9aed..4e0db04ba0d 100644 --- a/course/editcategory_form.php +++ b/course/editcategory_form.php @@ -16,7 +16,7 @@ class editcategory_form extends moodleform { // 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 8f4ef7f0efb..bd4f334beb9 100644 --- a/enrol/externallib.php +++ b/enrol/externallib.php @@ -426,7 +426,7 @@ class core_enrol_external extends external_api { $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 6798a48f475..84b24287cfe 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 0b1d9e6f42d..54cb292a850 100644 --- a/files/externallib.php +++ b/files/externallib.php @@ -80,7 +80,7 @@ class core_files_external extends external_api { $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 637a5834c62..70451da16eb 100644 --- a/grade/grading/lib.php +++ b/grade/grading/lib.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); * * @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/accesslib.php b/lib/accesslib.php index 886f7e048b1..e16b1da4bac 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -6005,7 +6005,7 @@ class context_system extends context { try { - // we ignore the strictness completely because system context must except except during install + // We ignore the strictness completely because system context must exist except during install. $record = $DB->get_record('context', array('contextlevel'=>CONTEXT_SYSTEM), '*', MUST_EXIST); } catch (dml_exception $e) { //table or record does not exist @@ -7229,46 +7229,6 @@ class context_block extends context { // before removing devs will be warned with a debugging message first, // then we will add error message and only after that we can remove the functions // completely. - - -/** - * Not available any more, use load_temp_course_role() instead. - * - * @deprecated since 2.2 - * @param stdClass $context - * @param int $roleid - * @param array $accessdata - * @return array - */ -function load_temp_role($context, $roleid, array $accessdata) { - debugging('load_temp_role() is deprecated, please use load_temp_course_role() instead, temp role not loaded.'); - return $accessdata; -} - -/** - * Not available any more, use remove_temp_course_roles() instead. - * - * @deprecated since 2.2 - * @param stdClass $context - * @param array $accessdata - * @return array access data - */ -function remove_temp_roles($context, array $accessdata) { - debugging('remove_temp_role() is deprecated, please use remove_temp_course_roles() instead.'); - return $accessdata; -} - -/** - * Returns system context or null if can not be created yet. - * - * @deprecated since 2.2, use context_system::instance() - * @param bool $cache use caching - * @return context system context (null if context table not created yet) - */ -function get_system_context($cache = true) { - return context_system::instance(0, IGNORE_MISSING, $cache); -} - /** * Recursive function which, given a context, find all parent context ids, * and return the array in reverse order, i.e. parent first, then grand diff --git a/lib/adminlib.php b/lib/adminlib.php index 1276b4172b7..4a76f82c164 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -6959,7 +6959,7 @@ class admin_setting_managerepository extends admin_setting { // 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 @@ class admin_setting_enablemobileservice extends admin_setting_configcheckbox { $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/deprecatedlib.php b/lib/deprecatedlib.php index ecb064bd89f..064725d2eda 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -4899,3 +4899,32 @@ function get_context_instance_by_id($id, $strictness = IGNORE_MISSING) { debugging('get_context_instance_by_id() is deprecated, please use context::instance_by_id($id) instead.', DEBUG_DEVELOPER); return context::instance_by_id($id, $strictness); } + +/** + * @deprecated since Moodle 2.2 + * @see load_temp_course_role() + */ +function load_temp_role($context, $roleid, array $accessdata) { + throw new coding_exception('load_temp_role() can not be used any more, please use load_temp_course_role()'); +} + +/** + * @deprecated since Moodle 2.2 + * @see remove_temp_course_roles() + */ +function remove_temp_roles($context, array $accessdata) { + throw new coding_exception('remove_temp_roles() can not be used any more, please use remove_temp_course_roles()'); +} + +/** + * Returns system context or null if can not be created yet. + * + * @see context_system::instance() + * @deprecated since 2.2 + * @param bool $cache use caching + * @return context system context (null if context table not created yet) + */ +function get_system_context($cache = true) { + debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER); + return context_system::instance(0, IGNORE_MISSING, $cache); +} diff --git a/lib/navigationlib.php b/lib/navigationlib.php index c691a83ef64..ee018aba612 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -1725,7 +1725,7 @@ class global_navigation extends navigation_node { $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 @@ class global_navigation extends navigation_node { $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 @@ class settings_navigation extends navigation_node { } $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 @@ class settings_navigation extends navigation_node { $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 32453f7d5cc..0f79447c4c1 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -717,7 +717,7 @@ initialise_fullme(); // 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 21be098462b..fa6dfc277f4 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -2372,6 +2372,8 @@ class accesslib_testcase extends advanced_testcase { $this->assertDebuggingCalled('get_context_instance() is deprecated, please use context_xxxx::instance() instead.', DEBUG_DEVELOPER); get_context_instance_by_id($record->id); $this->assertDebuggingCalled('get_context_instance_by_id() is deprecated, please use context::instance_by_id($id) instead.', DEBUG_DEVELOPER); + get_system_context(); + $this->assertDebuggingCalled('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER); $DB->delete_records('context', array('contextlevel'=>CONTEXT_BLOCK)); create_contexts(); diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index 36e4df34a23..627d8f886ff 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -2283,7 +2283,7 @@ class moodlelib_testcase extends advanced_testcase { $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/lib/upgrade.txt b/lib/upgrade.txt index c69272d6e6b..919cb45caa5 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -6,6 +6,8 @@ information provided here is intended especially for developers. * Use core_text::* instead of textlib:: and also core_collator::* instead of collatorlib::*. * get_context_instance() is deprecated, please use use context_xxxx::instance(). * get_context_instance_by_id() is deprecated, please use context::instance_by_id($id). +* load_temp_role() and remove_temp_roles() can not be used any more. +* get_system_context() is deprecated, please use context_system::instance(). === 2.5.1 === diff --git a/login/token.php b/login/token.php index f61081c8e15..6839cc0df97 100644 --- a/login/token.php +++ b/login/token.php @@ -146,9 +146,9 @@ if (!empty($user)) { 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 221a28fa13a..d4b6bd9fbe6 100644 --- a/mnet/service/enrol/index.php +++ b/mnet/service/enrol/index.php @@ -40,7 +40,7 @@ if (!$service->is_available()) { 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 50494daf90e..8f4e527a42d 100644 --- a/mnet/service/enrol/locallib.php +++ b/mnet/service/enrol/locallib.php @@ -552,7 +552,7 @@ class mnetservice_enrol_potential_users_selector extends user_selector_base { 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 7ddcd715bf2..9c6ab63f1aa 100644 --- a/mod/assign/adminmanageplugins.php +++ b/mod/assign/adminmanageplugins.php @@ -28,7 +28,7 @@ require_once($CFG->dirroot.'/mod/assign/adminlib.php'); // 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 9334c1a689e..c33fcc452ae 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 289f2084324..de240d81cdf 100644 --- a/mod/feedback/delete_template.php +++ b/mod/feedback/delete_template.php @@ -93,7 +93,7 @@ if (isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1) { } 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 @@ if ($shoulddelete == 1) { 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 cdab171873d..f8af903bb90 100644 --- a/mod/feedback/edit.php +++ b/mod/feedback/edit.php @@ -110,7 +110,7 @@ if (isset($create_template_formdata->savetemplate) && $create_template_formdata- $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 9faf394a076..7541f9b670c 100644 --- a/mod/feedback/edit_form.php +++ b/mod/feedback/edit_form.php @@ -178,7 +178,7 @@ class feedback_edit_create_template_form extends moodleform { 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 350bbcec112..6b6d4493743 100644 --- a/mod/feedback/item/label/lib.php +++ b/mod/feedback/item/label/lib.php @@ -146,7 +146,7 @@ class feedback_item_label extends feedback_item_base { 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 2490c3d4116..1bc946da9ab 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 25ad9a39b97..0059ae8a289 100644 --- a/mod/forum/user.php +++ b/mod/forum/user.php @@ -75,7 +75,7 @@ if (isguestuser($user)) { // 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 @@ if ($isspecificcourse) { // 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 8a22e6fc603..ca77b8347bb 100644 --- a/portfolio/add.php +++ b/portfolio/add.php @@ -47,7 +47,7 @@ $callbackclass = optional_param('callbackclass', null, PARAM_ALPHAEXT); // Callb $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 e50544ab836..dbd96675fa5 100644 --- a/repository/draftfiles_ajax.php +++ b/repository/draftfiles_ajax.php @@ -30,7 +30,7 @@ require('../config.php'); 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 bd19ef7f73b..40046553727 100644 --- a/repository/filepicker.php +++ b/repository/filepicker.php @@ -377,7 +377,7 @@ case 'confirm': 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 a5ffca8a6d0..522fe52a44f 100644 --- a/repository/filesystem/lib.php +++ b/repository/filesystem/lib.php @@ -190,7 +190,7 @@ class repository_filesystem extends repository { 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 @@ class repository_filesystem extends repository { 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 a0a5c7213db..48458d757ca 100644 --- a/repository/flickr_public/lib.php +++ b/repository/flickr_public/lib.php @@ -529,7 +529,7 @@ class repository_flickr_public extends repository { 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 137700bee74..c3b17f24a71 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -251,7 +251,7 @@ class repository_type implements cacheable_object { // 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 @@ abstract class repository implements cacheable_object { public static function get_editable_types($context = null) { if (empty($context)) { - $context = get_system_context(); + $context = context_system::instance(); } $types= repository::get_types(true); @@ -3168,7 +3168,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 d2b1dec2c4a..162bbe3bfea 100644 --- a/repository/repository_ajax.php +++ b/repository/repository_ajax.php @@ -94,7 +94,7 @@ switch ($action) { // 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 da4d25e2fab..cbfeaefd6d9 100644 --- a/tag/coursetags_more.php +++ b/tag/coursetags_more.php @@ -67,7 +67,7 @@ if ($courseid) { 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 97c27333e63..4ba4b86b2a5 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 4e34c646117..49758e2df54 100644 --- a/user/edit.php +++ b/user/edit.php @@ -50,7 +50,7 @@ if ($course->id != SITEID) { } 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 a327dcc2f1f..e21ed8c7750 100644 --- a/user/externallib.php +++ b/user/externallib.php @@ -678,7 +678,7 @@ class core_user_external extends external_api { $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;