N°3423 - Allow AttributeImage / AttributeDocument content to be cached by the browser (portal)

This commit is contained in:
Eric
2021-01-21 15:15:45 +01:00
parent 8f1d9fba57
commit 154156f4a1
8 changed files with 61 additions and 18 deletions

View File

@@ -149,7 +149,7 @@ class ormDocument
*/
public function GetDisplayURL($sClass, $Id, $sAttCode)
{
$sSignature = md5($this->GetData());
$sSignature = $this->GetSignature();
// 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&s=$sSignature&cache=86400";
}
@@ -161,7 +161,7 @@ class ormDocument
public function GetDownloadURL($sClass, $Id, $sAttCode)
{
// Compute a signature to reset the cache anytime the data changes (this is acceptable if used only with icon files)
$sSignature = md5($this->GetData());
$sSignature = $this->GetSignature();
// 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";
}
@@ -221,4 +221,12 @@ class ormDocument
$oPage->p($e->getMessage());
}
}
/**
* @return string
*/
public function GetSignature(): string
{
return md5($this->GetData());
}
}

View File

@@ -1159,7 +1159,8 @@ class UserRights
else
{
if (ContextTag::Check(ContextTag::TAG_PORTAL)) {
$sPictureUrl = utils::GetAbsoluteUrlAppRoot().'pages/exec.php/object/document/display/'.$sContactClass.'/'.$oContact->GetKey().'/'.static::DEFAULT_CONTACT_PICTURE_ATTCODE.'?exec_module=itop-portal-base&exec_page=index.php&portal_id='.PORTAL_ID;
$sSignature = $oPicture->GetSignature();
$sPictureUrl = utils::GetAbsoluteUrlAppRoot().'pages/exec.php/object/document/display/'.$sContactClass.'/'.$oContact->GetKey().'/'.static::DEFAULT_CONTACT_PICTURE_ATTCODE.'?cache=86400&s='.$sSignature.'&exec_module=itop-portal-base&exec_page=index.php&portal_id='.PORTAL_ID;
}
else {
$sPictureUrl = $oPicture->GetDisplayURL($sContactClass, $oContact->GetKey(), static::DEFAULT_CONTACT_PICTURE_ATTCODE);