diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 4bb83ff80..98625aff5 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -1253,6 +1253,14 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => false, ], + 'activity_panel.hide_avatars' => [ + 'type' => 'array', + 'description' => 'GUIs IDs ("backoffice", "itop-portal" for the standard end-users portal, ...) in which the user avatars should be hidden and replaced if possible by their initials (eg. array("backoffice", "itop-portal", "another-portal-id"))', + 'default' => [], + 'value' => [], + 'source_of_value' => '', + 'show_in_conf_sample' => false, + ], 'activity_panel.show_author_name_below_entries' => [ 'type' => 'bool', 'description' => 'Whether or not to show the author friendlyname next to the date on the last entry.', diff --git a/sources/Renderer/Bootstrap/FieldRenderer/BsSimpleFieldRenderer.php b/sources/Renderer/Bootstrap/FieldRenderer/BsSimpleFieldRenderer.php index df502460c..efe350539 100644 --- a/sources/Renderer/Bootstrap/FieldRenderer/BsSimpleFieldRenderer.php +++ b/sources/Renderer/Bootstrap/FieldRenderer/BsSimpleFieldRenderer.php @@ -577,6 +577,8 @@ HTML // Caching profile picture url as it is resource consuming $aContactPicturesCache = array(); $aPeerColorClassCache = array(); + // Note: Yes, the config. param. is named after the backoffice element but we hope that we will "soon" have some kind of "light" activity panel in the portal too, so we keep this name. + $bHideContactPicture = in_array(PORTAL_ID, utils::GetConfig()->Get('activity_panel.hide_avatars')); // Current user $iCurrentUserId = UserRights::GetUserId(); @@ -590,13 +592,21 @@ HTML // Retrieve (and cache) profile picture if available (standard datamodel) // Note: Here the cache is more about nor retrieving the User object several times rather than computing the picture URL if (!array_key_exists($iEntryUserId, $aContactPicturesCache)) { - $oEntryUser = MetaModel::GetObject('User', $iEntryUserId, false /* Necessary in case user has been deleted */, true); - if(is_null($oEntryUser)) { + // First, check if we should display the picture + if ($bHideContactPicture === true) { $sEntryContactPictureAbsoluteUrl = null; } + // Otherwise try to retrieve one for the current contact else { - $sEntryContactPictureAbsoluteUrl = UserRights::GetUserPictureAbsUrl($oEntryUser->Get('login'), false); + $oEntryUser = MetaModel::GetObject('User', $iEntryUserId, false /* Necessary in case user has been deleted */, true); + if(is_null($oEntryUser)) { + $sEntryContactPictureAbsoluteUrl = null; + } + else { + $sEntryContactPictureAbsoluteUrl = UserRights::GetUserPictureAbsUrl($oEntryUser->Get('login'), false); + } } + $aContactPicturesCache[$iEntryUserId] = $sEntryContactPictureAbsoluteUrl; } diff --git a/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php b/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php index 459d19d29..ffe030809 100644 --- a/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php +++ b/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php @@ -221,9 +221,13 @@ class ActivityEntry extends UIBlock // - Initials $this->sAuthorInitials = UserRights::GetUserInitials($this->sAuthorLogin); // - Picture - $this->sAuthorPictureAbsUrl = UserRights::GetUserPictureAbsUrl($this->sAuthorLogin, false); - if ((null === $this->sAuthorPictureAbsUrl) && (ITOP_APPLICATION_SHORT === $this->sAuthorLogin)) { - $this->sAuthorPictureAbsUrl = utils::GetAbsoluteUrlAppRoot().static::DEFAULT_AUTHOR_PICTURE_REL_URL; + if (in_array('backoffice', utils::GetConfig()->Get('activity_panel.hide_avatars'))) { + $this->sAuthorPictureAbsUrl = null; + } else { + $this->sAuthorPictureAbsUrl = UserRights::GetUserPictureAbsUrl($this->sAuthorLogin, false); + if ((null === $this->sAuthorPictureAbsUrl) && (ITOP_APPLICATION_SHORT === $this->sAuthorLogin)) { + $this->sAuthorPictureAbsUrl = utils::GetAbsoluteUrlAppRoot().static::DEFAULT_AUTHOR_PICTURE_REL_URL; + } } $this->bIsFromCurrentUser = UserRights::GetUserId($this->sAuthorLogin) === UserRights::GetUserId();