MDL-34472 libraries: Remove usage of get_context_instance() from core
This commit is contained in:
+1
-1
@@ -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'.
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
@@ -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',
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user