From 2f9e050e2b527fc295509b13c0ac6dc8a62dccb6 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Thu, 20 Jun 2019 10:34:10 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B02323.4=20Fix=20regression=20introduced?= =?UTF-8?q?=20in=20previous=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Current user picture was no longer displayed in the portal (cherry picked from commit 56b9eb6cf3c65a98f6772e4b849bfce4c1d4f858) --- core/ormdocument.class.inc.php | 2 ++ .../src/controllers/userprofilebrickcontroller.class.inc.php | 3 ++- .../portal/src/helpers/applicationhelper.class.inc.php | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/ormdocument.class.inc.php b/core/ormdocument.class.inc.php index 3ff796f8c..68d8d0368 100644 --- a/core/ormdocument.class.inc.php +++ b/core/ormdocument.class.inc.php @@ -126,6 +126,7 @@ class ormDocument */ public function GetDisplayURL($sClass, $Id, $sAttCode) { + // TODO: When refactoring this with the URLMaker system, mind to also change calls in the portal (look for the "p_object_document_display" route) return utils::GetAbsoluteUrlAppRoot() . "pages/ajax.render.php?operation=display_document&class=$sClass&id=$Id&field=$sAttCode"; } @@ -137,6 +138,7 @@ class ormDocument { // Compute a signature to reset the cache anytime the data changes (this is acceptable if used only with icon files) $sSignature = md5($this->GetData()); + // TODO: When refactoring this with the URLMaker system, mind to also change calls in the portal (look for the "p_object_document_display" route) return utils::GetAbsoluteUrlAppRoot() . "pages/ajax.document.php?operation=download_document&class=$sClass&id=$Id&field=$sAttCode&s=$sSignature&cache=86400"; } diff --git a/datamodels/2.x/itop-portal-base/portal/src/controllers/userprofilebrickcontroller.class.inc.php b/datamodels/2.x/itop-portal-base/portal/src/controllers/userprofilebrickcontroller.class.inc.php index d2d8ebdae..62e24a4dc 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/controllers/userprofilebrickcontroller.class.inc.php +++ b/datamodels/2.x/itop-portal-base/portal/src/controllers/userprofilebrickcontroller.class.inc.php @@ -284,7 +284,8 @@ class UserProfileBrickController extends BrickController $aFormData['error'] = $e->GetMessage(); } - $aFormData['picture_url'] = $oImage->GetDownloadURL(get_class($oCurContact), $oCurContact->GetKey(), $sPictureAttCode); + // TODO: This should be changed when refactoring the ormDocument GetDisplayUrl() and GetDownloadUrl() in iTop 2.8 + $aFormData['picture_url'] = $oApp['url_generator']->generate('p_object_document_display', array('sObjectClass' => get_class($oCurContact), 'sObjectId' => $oCurContact->GetKey(), 'sObjectField' => $sPictureAttCode, 'cache' => 86400, 't' => time())); $aFormData['validation'] = array( 'valid' => true, 'messages' => array() diff --git a/datamodels/2.x/itop-portal-base/portal/src/helpers/applicationhelper.class.inc.php b/datamodels/2.x/itop-portal-base/portal/src/helpers/applicationhelper.class.inc.php index 44e39a360..91f9ec59e 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/helpers/applicationhelper.class.inc.php +++ b/datamodels/2.x/itop-portal-base/portal/src/helpers/applicationhelper.class.inc.php @@ -632,7 +632,10 @@ class ApplicationHelper $oImage = $oContact->Get('picture'); if (is_object($oImage) && !$oImage->IsEmpty()) { - $sContactPhotoUrl = $oImage->GetDownloadURL(get_class($oContact), $oContact->GetKey(), 'picture'); + // Note: At this stage of runtime, the UrlGenerator context is not properly initialized (lacks the baseurl among other things). + // The Context is set later by the RouterListener during an event, so we manually put the base url with utils::GetAbsoluteUrlExecPage() + // TODO: This should be changed when refactoring the ormDocument GetDisplayUrl() and GetDownloadUrl() in iTop 2.8 + $sContactPhotoUrl = utils::GetAbsoluteUrlExecPage().$oApp['url_generator']->generate('p_object_document_display', array('sObjectClass' => get_class($oContact), 'sObjectId' => $oContact->GetKey(), 'sObjectField' => 'picture', 'cache' => 86400)); } else {