Commit 8766e7df authored by Tobias Zeuch's avatar Tobias Zeuch Committed by Robert Lyon
Browse files

Hide author on view if his profile page isn't visible



Bug 548021: Right now, the author is always displayed on a page, even if it is
publically shared. Suggestion: only show author, if the currently logged in
user (may be anonymous/not logged in) can see his profile page

Change-Id: I998e1395d3a5f8d167314862d6e1e4b83a7bdf4b
Signed-off-by: default avatarTobias Zeuch <tobias.zeuch@kit.edu>
parent e8eeb1e9
......@@ -4505,6 +4505,9 @@ class View {
else if ($this->group) {
return group_homepage_url($this->get_group_object());
}
else if ($this->institution) {
return get_config('wwwroot') . 'institution/index.php?institution=' . $this->institution;
}
return null;
}
......@@ -4546,6 +4549,36 @@ class View {
}
public function display_author() {
$view = null;
if (!empty($this->owner)) {
$userobj = new User();
$userobj->find_by_id($this->owner);
$view = $userobj->get_profile_view();
// Hide author if profile isn't visible to user
if (!$view || !can_view_view($view)) {
return null;
}
}
else if (!empty($this->group)) {
$view = group_get_homepage_view($this->group);
// Hide author if profile isn't visible to user
if (!$view || !can_view_view($view)) {
return null;
}
}
else if (!empty($this->institution)) {
global $USER;
if (!$USER->is_logged_in() || (
!get_field('institution', 'registerallowed', 'name', $this->institution) &&
!$USER->in_institution($this->institution) &&
!$USER->get('admin'))) {
return null;
}
}
$ownername = hsc($this->formatted_owner());
$ownerlink = hsc($this->owner_link());
return get_string('viewauthor', 'view', $ownerlink, $ownername);
......
Markdown is supported
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