Skip to content

Commit

Permalink
MDL-34455 Libraries: Replaced deprecated get_context_instance()
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Jul 23, 2012
1 parent bdaff20 commit bf006d2
Show file tree
Hide file tree
Showing 67 changed files with 80 additions and 80 deletions.
2 changes: 1 addition & 1 deletion admin/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
require_once($CFG->libdir.'/tablelib.php');

require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_capability('moodle/site:config', context_system::instance());

$returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));

Expand Down
2 changes: 1 addition & 1 deletion admin/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

/// no guest autologin
require_login(0, false);
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/admin/category.php', array('category' => $category));
$PAGE->set_pagetype('admin-setting-' . $category);
$PAGE->set_pagelayout('admin');
Expand Down
2 changes: 1 addition & 1 deletion admin/editors.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require_once($CFG->libdir.'/tablelib.php');

require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_capability('moodle/site:config', context_system::instance());

$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";

Expand Down
2 changes: 1 addition & 1 deletion admin/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$PAGE->set_context(context_system::instance());

require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_capability('moodle/site:config', context_system::instance());
require_sesskey();

$enabled = enrol_get_plugins(true);
Expand Down
2 changes: 1 addition & 1 deletion admin/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
$filterpath = optional_param('filterpath', '', PARAM_PATH);

require_login();
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$systemcontext = context_system::instance();
require_capability('moodle/site:config', $systemcontext);

$returnurl = "$CFG->wwwroot/$CFG->admin/filters.php";
Expand Down
2 changes: 1 addition & 1 deletion admin/handlevirus.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
$a->date = userdate($log->time);

$a->action = $action;
$a->course = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$a->course = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
$a->user = fullname($user);

notify_user($user,$subject,$a);
Expand Down
4 changes: 2 additions & 2 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
// and upgrade if possible.

$stradministration = get_string('administration');
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_context(context_system::instance());

if (empty($CFG->version)) {
print_error('missingconfigversion', 'debug');
Expand Down Expand Up @@ -386,7 +386,7 @@

// Check for valid admin user - no guest autologin
require_login(0, false);
$context = get_context_instance(CONTEXT_SYSTEM);
$context = context_system::instance();
require_capability('moodle/site:config', $context);

// check that site is properly customized
Expand Down
2 changes: 1 addition & 1 deletion admin/licenses.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
require_once($CFG->libdir.'/licenselib.php');

require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_capability('moodle/site:config', context_system::instance());

$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managelicenses";

Expand Down
4 changes: 2 additions & 2 deletions admin/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
admin_externalpage_setup('managemessageoutputs');

// Require site configuration capability
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_capability('moodle/site:config', context_system::instance());

// Get the submitted params
$disable = optional_param('disable', 0, PARAM_INT);
Expand Down Expand Up @@ -82,7 +82,7 @@
redirect($url);
}
// Page settings
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_context(context_system::instance());

// Grab the renderer
$renderer = $PAGE->get_renderer('core', 'message');
Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/access_control.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
print_error('requiresopenssl', 'mnet');
}

$sitecontext = get_context_instance(CONTEXT_SYSTEM);
$sitecontext = context_system::instance();
$sesskey = sesskey();
$formerror = array();

Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

require_login();

$context = get_context_instance(CONTEXT_SYSTEM);
$context = context_system::instance();
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");

$mnet = get_mnet_environment();
Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require_login();
admin_externalpage_setup('net');

$context = get_context_instance(CONTEXT_SYSTEM);
$context = context_system::instance();

require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");

Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/peers.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

require_login();

$context = get_context_instance(CONTEXT_SYSTEM);
$context = context_system::instance();
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');

/// Initialize variables.
Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/profilefields.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$mnet_peer = new mnet_peer();
$mnet_peer->set_id($hostid);

$context = get_context_instance(CONTEXT_SYSTEM);
$context = context_system::instance();

require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
admin_externalpage_setup('mnetpeers');
Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
require_login();
admin_externalpage_setup('mnetpeers');

$context = get_context_instance(CONTEXT_SYSTEM);
$context = context_system::instance();
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");

$hostid = required_param('hostid', PARAM_INT);
Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/testclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
require_login();
admin_externalpage_setup('mnettestclient');

$context = get_context_instance(CONTEXT_SYSTEM);
$context = context_system::instance();
require_capability('moodle/site:config', $context);

error_reporting(DEBUG_ALL);
Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/trustedhosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
require_login();
admin_externalpage_setup('trustedhosts');

$context = get_context_instance(CONTEXT_SYSTEM);
$context = context_system::instance();

require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");

Expand Down
2 changes: 1 addition & 1 deletion admin/oacleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function online_assignment_cleanup($output=false) {
/// cycle through each course
foreach ($courses as $course) {
context_instance_preload($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$context = context_course::instance($course->id);

if (empty($course->fullname)) {
$fullname = get_string('course').': '.$course->id;
Expand Down
2 changes: 1 addition & 1 deletion admin/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/pluginlib.php');

require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_capability('moodle/site:config', context_system::instance());
admin_externalpage_setup('pluginsoverview');

$fetchremote = optional_param('fetchremote', false, PARAM_BOOL);
Expand Down
2 changes: 1 addition & 1 deletion admin/portfolio.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

admin_externalpage_setup($pagename);

require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_capability('moodle/site:config', context_system::instance());

$baseurl = "$CFG->wwwroot/$CFG->admin/portfolio.php";
$sesskeyurl = "$CFG->wwwroot/$CFG->admin/portfolio.php?sesskey=" . sesskey();
Expand Down
2 changes: 1 addition & 1 deletion admin/purgecaches.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
admin_externalpage_setup('purgecaches');

require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_capability('moodle/site:config', context_system::instance());

if ($confirm) {
require_sesskey();
Expand Down
2 changes: 1 addition & 1 deletion admin/qbehaviours.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

// Check permissions.
require_login();
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$systemcontext = context_system::instance();
require_capability('moodle/question:config', $systemcontext);

admin_externalpage_setup('manageqbehaviours');
Expand Down
2 changes: 1 addition & 1 deletion admin/qtypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

// Check permissions.
require_login();
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$systemcontext = context_system::instance();
require_capability('moodle/question:config', $systemcontext);
$canviewreports = has_capability('report/questioninstances:view', $systemcontext);

Expand Down
2 changes: 1 addition & 1 deletion admin/registration/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function definition() {
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
$sitename = get_config('hub', 'site_name_' . $cleanhuburl);
if ($sitename === false) {
$sitename = format_string($site->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$sitename = format_string($site->fullname, true, array('context' => context_course::instance(SITEID)));
}
$sitedescription = get_config('hub', 'site_description_' . $cleanhuburl);
if ($sitedescription === false) {
Expand Down
2 changes: 1 addition & 1 deletion admin/repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
$visible = false;
}

require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_capability('moodle/site:config', context_system::instance());
admin_externalpage_setup($pagename);

$sesskeyurl = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php?sesskey=' . sesskey();
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/allow.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$baseurl = new moodle_url('/admin/roles/allow.php', array('mode'=>$mode));
admin_externalpage_setup('defineroles', '', array(), $baseurl);

$syscontext = get_context_instance(CONTEXT_SYSTEM);
$syscontext = context_system::instance();
require_capability('moodle/role:manage', $syscontext);

$controller = new $classformode[$mode]();
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/define.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}

/// Check access permissions.
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$systemcontext = context_system::instance();
require_login();
require_capability('moodle/role:manage', $systemcontext);
admin_externalpage_setup('defineroles', '', array('action' => $action, 'roleid' => $roleid), $defineurl);
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ public function __construct($tablename, $targetcolname) {
*/
protected function load_required_roles() {
/// Get all roles
$this->roles = role_fix_names(get_all_roles(), get_context_instance(CONTEXT_SYSTEM), ROLENAME_ORIGINAL);
$this->roles = role_fix_names(get_all_roles(), context_system::instance(), ROLENAME_ORIGINAL);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
$defineurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/define.php';

/// Check access permissions.
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$systemcontext = context_system::instance();
require_login();
require_capability('moodle/role:manage', $systemcontext);
admin_externalpage_setup('defineroles');
Expand Down
6 changes: 3 additions & 3 deletions admin/roles/usersroles.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);

$usercontext = get_context_instance(CONTEXT_USER, $user->id);
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$usercontext = context_user::instance($user->id);
$coursecontext = context_course::instance($course->id);
$systemcontext = context_system::instance();

$baseurl = new moodle_url('/admin/roles/usersroles.php', array('userid'=>$userid, 'courseid'=>$courseid));

Expand Down
2 changes: 1 addition & 1 deletion admin/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

$query = trim(optional_param('query', '', PARAM_NOTAGS)); // Search string

$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_context(context_system::instance());

admin_externalpage_setup('search', '', array('query' => $query)); // now hidden page

Expand Down
2 changes: 1 addition & 1 deletion admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/// no guest autologin
require_login(0, false);
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/admin/settings.php', array('section' => $section));
$PAGE->set_pagetype('admin-setting-' . $section);
$PAGE->set_pagelayout('admin');
Expand Down
2 changes: 1 addition & 1 deletion admin/settings/frontpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This file defines everything related to frontpage

if (!during_initial_install()) { //do not use during installation
$frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
$frontpagecontext = context_course::instance(SITEID);

if ($hassiteconfig or has_any_capability(array(
'moodle/course:update',
Expand Down
2 changes: 1 addition & 1 deletion admin/settings/top.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// since they need to exist *before* settingpages and externalpages
// are added to them.

$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$systemcontext = context_system::instance();
$hassiteconfig = has_capability('moodle/site:config', $systemcontext);

$ADMIN->add('root', new admin_externalpage('adminnotifications', new lang_string('notifications'), "$CFG->wwwroot/$CFG->admin/index.php"));
Expand Down
2 changes: 1 addition & 1 deletion admin/settings/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$temp = new admin_settingpage('userpolicies', new lang_string('userpolicies', 'admin'));
if ($ADMIN->fulltree) {
if (!during_initial_install()) {
$context = get_context_instance(CONTEXT_SYSTEM);
$context = context_system::instance();

$otherroles = array();
$guestroles = array();
Expand Down
2 changes: 1 addition & 1 deletion admin/timezone.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

require_login();

require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_capability('moodle/site:config', context_system::instance());

$strtimezone = get_string("timezone");
$strsavechanges = get_string("savechanges");
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/bloglevelupgrade/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@
function bloglevelupgrade_entries($blogentries, $forum, $cm, $groupid=-1) {
$count = 0;

$forumcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
$forumcontext = context_module::instance($cm->id);
$sitecontext = context_system::instance();

foreach ($blogentries as $blogentry) {
$discussion = new stdClass();
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/capability/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

// Check permissions.
require_login();
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$systemcontext = context_system::instance();
require_capability('moodle/role:manage', $systemcontext);

// Get URL parameters.
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/generator/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


require_login();
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$systemcontext = context_system::instance();
require_capability('moodle/site:config', $systemcontext);
if (!is_siteadmin()) {
error('Only for admins');
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/generator/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ public function generate_role_assignments($users, $courses) {
shuffle($users);
$users_to_assign = array_slice($users, 0, $this->get('students_per_course'));

$context = get_context_instance(CONTEXT_COURSE, $courseid);
$context = context_course::instance($courseid);
foreach ($users_to_assign as $random_user) {
role_assign(5, $random_user, $context->id);

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/health/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$solution = optional_param('solution', 0, PARAM_PLUGIN);

require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_capability('moodle/site:config', context_system::instance());

$site = get_site();

Expand Down
Loading

0 comments on commit bf006d2

Please sign in to comment.