From bea86e845ef950eb10466b3d3c88946c02447589 Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Mon, 1 Jul 2013 14:03:35 +0800 Subject: [PATCH] MDL-34472 libraries: Remove usage of get_context_instance() from core --- lib/accesslib.php | 2 +- lib/pagelib.php | 2 +- mod/assign/feedback/offline/locallib.php | 2 +- user/lib.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index 9cdd393667f..8604f487f40 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -717,7 +717,7 @@ function has_capability_in_accessdata($capability, context $context, array &$acc * @see has_capability() * * @param string $capability the name of the capability to check. For example mod/forum:view - * @param context $context the context to check the capability in. You normally get this with {@link get_context_instance}. + * @param context $context the context to check the capability in. You normally get this with context_xxxx::instance(). * @param int $userid A user id. By default (null) checks the permissions of the current user. * @param bool $doanything If false, ignore effect of admin role assignment * @param string $errormessage The error string to to user. Defaults to 'nopermissions'. diff --git a/lib/pagelib.php b/lib/pagelib.php index 8ebb63bff2c..556a9dfc345 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -899,7 +899,7 @@ class moodle_page { /** * Set the main context to which this page belongs. * - * @param context $context a context object, normally obtained with get_context_instance. + * @param context $context a context object. You normally get this with context_xxxx::instance(). */ public function set_context($context) { if ($context === null) { diff --git a/mod/assign/feedback/offline/locallib.php b/mod/assign/feedback/offline/locallib.php index b1fd7b9c03b..1a5838b900d 100644 --- a/mod/assign/feedback/offline/locallib.php +++ b/mod/assign/feedback/offline/locallib.php @@ -80,7 +80,7 @@ class assign_feedback_offline extends assign_feedback_plugin { $gradeimporter = new assignfeedback_offline_grade_importer($importid, $this->assignment); - $context = get_context_instance(CONTEXT_USER, $USER->id); + $context = context_user::instance($USER->id); $fs = get_file_storage(); if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) { redirect(new moodle_url('view.php', diff --git a/user/lib.php b/user/lib.php index 560e3112580..357facb110c 100644 --- a/user/lib.php +++ b/user/lib.php @@ -527,11 +527,11 @@ function user_get_user_details_courses($user) { */ function can_view_user_details_cap($user, $course = null) { // Check $USER has the capability to view the user details at user context. - $usercontext = get_context_instance(CONTEXT_USER, $user->id); + $usercontext = context_user::instance($user->id); $result = has_capability('moodle/user:viewdetails', $usercontext); // Otherwise can $USER see them at course context. if (!$result && !empty($course)) { - $context = get_context_instance(CONTEXT_COURSE, $course->id); + $context = context_course::instance($course->id); $result = has_capability('moodle/user:viewdetails', $context); } return $result;