From d099f4fd0edc4df1bf1781e6478427813bcddcb8 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 6 Jun 2012 10:35:19 +1200 Subject: [PATCH] MDL-31520 user-ws: Optimised if statement for email access by moving admin check to the start --- user/lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user/lib.php b/user/lib.php index caf286fb600..33b730bb2d0 100644 --- a/user/lib.php +++ b/user/lib.php @@ -309,11 +309,11 @@ function user_get_user_details($user, $course = null) { } } - if ($currentuser + if ($isadmin + of $currentuser or $canviewuseremail // this is a capability in course context, it will be false in usercontext or $user->maildisplay == 1 - or ($user->maildisplay == 2 and enrol_sharing_course($user, $USER)) - or $isadmin) { + or ($user->maildisplay == 2 and enrol_sharing_course($user, $USER))) { $userdetails['email'] = $user->email;; }