mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°4142 - Add config. param. to hide user avatars in the GUIs -mostly in logs- (backoffice, end-users portal, ...)
This commit is contained in:
@@ -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.',
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user