Commit 853e8647 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use get_user_for_display in View::get_owner_object()



Bug #1006634, part 3

This is more efficient on many pages, because the user object has
already been fetched, or is about to be fetched, to run display_name
or profile_icon_url.

However, user object returned by get_user_for_display won't allow
can_view_view to tell whether a user is suspended or not, so
suspendedctime is added to this object (it's less identifying than
suspendedcusr).

Change-Id: Ic9d1e5d437aedbc45f6328a05997812dcf45c8d6
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 022f91cb
...@@ -1823,7 +1823,7 @@ function can_view_view($view, $user_id=null) { ...@@ -1823,7 +1823,7 @@ function can_view_view($view, $user_id=null) {
// If the view's owner is suspended, deny access to the view // If the view's owner is suspended, deny access to the view
if ($view->get('owner')) { if ($view->get('owner')) {
if ((!$owner = $view->get_owner_object()) || $owner->suspendedcusr) { if ((!$owner = $view->get_owner_object()) || $owner->suspendedctime) {
return false; return false;
} }
} }
......
...@@ -871,7 +871,7 @@ function get_user_for_display($user=null) { ...@@ -871,7 +871,7 @@ function get_user_for_display($user=null) {
$fields = array( $fields = array(
'id', 'username', 'preferredname', 'firstname', 'lastname', 'admin', 'staff', 'id', 'username', 'preferredname', 'firstname', 'lastname', 'admin', 'staff',
'profileicon', 'email', 'deleted', 'urlid', 'profileicon', 'email', 'deleted', 'urlid', 'suspendedctime',
); );
if (is_numeric($user) && isset($usercache[$user])) { if (is_numeric($user) && isset($usercache[$user])) {
......
...@@ -601,7 +601,7 @@ class View { ...@@ -601,7 +601,7 @@ class View {
return false; return false;
} }
if (!isset($this->ownerobj)) { if (!isset($this->ownerobj)) {
$this->ownerobj = get_record('usr', 'id', $this->get('owner')); $this->ownerobj = get_user_for_display($this->get('owner'));
} }
return $this->ownerobj; return $this->ownerobj;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment