From 4e58b8616a21c34cfe672124d6b76daebaad8725 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Thu, 15 Jul 2021 17:31:30 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B03203=20-=20PHPDoc=20and=20small=20variab?= =?UTF-8?q?le=20refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bootstrap/FieldRenderer/BsSimpleFieldRenderer.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sources/Renderer/Bootstrap/FieldRenderer/BsSimpleFieldRenderer.php b/sources/Renderer/Bootstrap/FieldRenderer/BsSimpleFieldRenderer.php index 6d50da11f..df502460c 100644 --- a/sources/Renderer/Bootstrap/FieldRenderer/BsSimpleFieldRenderer.php +++ b/sources/Renderer/Bootstrap/FieldRenderer/BsSimpleFieldRenderer.php @@ -588,8 +588,9 @@ HTML $iEntryUserId = $aEntries[$i]['user_id']; // 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, true); + $oEntryUser = MetaModel::GetObject('User', $iEntryUserId, false /* Necessary in case user has been deleted */, true); if(is_null($oEntryUser)) { $sEntryContactPictureAbsoluteUrl = null; } @@ -625,8 +626,9 @@ HTML ); // Open medallion from profile picture or first name letter - $sEntryMedallionStyle = (empty($aContactPicturesCache[$iEntryUserId]) === false) ? ' background-image: url(\''.$aContactPicturesCache[$iEntryUserId].'\');' : ''; - $sEntryMedallionContent = (empty($aContactPicturesCache[$iEntryUserId]) === false) ? '' : UserRights::GetUserInitials($sEntryUserLogin); + $bEntryHasMedallionPicture = (empty($aContactPicturesCache[$iEntryUserId]) === false); + $sEntryMedallionStyle = $bEntryHasMedallionPicture ? ' background-image: url(\''.$aContactPicturesCache[$iEntryUserId].'\');' : ''; + $sEntryMedallionContent = $bEntryHasMedallionPicture ? '' : UserRights::GetUserInitials($sEntryUserLogin); // - Entry tooltip $sEntryMedallionTooltip = utils::HtmlEntities($sEntryUserLogin); $sEntryMedallionTooltipPlacement = ($iEntryUserId === $iCurrentUserId) ? 'left' : 'right';