diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 25eea15d7..492a3c4db 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -3265,9 +3265,11 @@ HTML; */ public function DisplayDocumentInline(WebPage $oPage, $sAttCode) { + /** @var \ormDocument $oDoc */ $oDoc = $this->Get($sAttCode); $sClass = get_class($this); - $Id = $this->GetKey(); + $sId = $this->GetKey(); + $sDisplayUrl = $oDoc->GetDisplayURL($sClass, $sId, $sAttCode); switch ($oDoc->GetMainMimeType()) { case 'text': @@ -3276,7 +3278,7 @@ HTML; switch ($oDoc->GetMimeType()) { case 'text/xml': - $oPage->add("\n"); + $oPage->add("\n"); break; default: @@ -3289,7 +3291,7 @@ HTML; switch ($oDoc->GetMimeType()) { case 'application/pdf': - $oPage->add("\n"); + $oPage->add("\n"); break; default: @@ -3298,7 +3300,7 @@ HTML; break; case 'image': - $oPage->add("\n"); + $oPage->add("\n"); break; default: diff --git a/core/ormdocument.class.inc.php b/core/ormdocument.class.inc.php index aa8b91eba..8db9782cb 100644 --- a/core/ormdocument.class.inc.php +++ b/core/ormdocument.class.inc.php @@ -129,7 +129,8 @@ class ormDocument */ public function GetDisplayLink($sClass, $Id, $sAttCode) { - return "".htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8')."\n"; + $sUrl = $this->GetDisplayURL($sClass, $Id, $sAttCode); + return "".htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8')."\n"; } /** @@ -138,7 +139,8 @@ class ormDocument */ public function GetDownloadLink($sClass, $Id, $sAttCode) { - return "".htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8')."\n"; + $sUrl = $this->GetDownloadURL($sClass, $Id, $sAttCode); + return "".htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8')."\n"; } /** @@ -147,8 +149,9 @@ class ormDocument */ public function GetDisplayURL($sClass, $Id, $sAttCode) { + $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.render.php?operation=display_document&class=$sClass&id=$Id&field=$sAttCode"; + return utils::GetAbsoluteUrlAppRoot() . "pages/ajax.render.php?operation=display_document&class=$sClass&id=$Id&field=$sAttCode&s=$sSignature&cache=86400"; } /** diff --git a/pages/ajax.document.php b/pages/ajax.document.php index 11e385c23..de526f027 100644 --- a/pages/ajax.document.php +++ b/pages/ajax.document.php @@ -58,15 +58,10 @@ try ormDocument::DownloadDocument($oPage, $sClass, $id, $sField, 'attachment'); if ($iCacheSec > 0) { - $oPage->add_header("Cache-Control: no-transform,public,max-age=$iCacheSec,s-maxage=$iCacheSec"); - $oPage->add_header("Pragma: cache"); // Reset the value set .... where ? - $oPage->add_header("Expires: "); // Reset the value set in ajax_page - + $oPage->set_cache($iCacheSec); // X-Frame http header : set in page constructor, but we need to allow frame integration for this specific page // so we're resetting its value ! (see N°3416) $oPage->add_xframe_options(''); - - $oPage->add_header("Last-Modified: Wed, 15 Jun 2015 13:21:15 GMT"); // An arbitrary date in the past is ok } } break; diff --git a/pages/ajax.render.php b/pages/ajax.render.php index e4e51d789..a3a885c14 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -788,6 +788,8 @@ try // X-Frame http header : set in page constructor, but we need to allow frame integration for this specific page // so we're resetting its value ! (see N°3416) $oPage->add_xframe_options(''); + $iCacheSec = (int)utils::ReadParam('cache', 0); + $oPage->set_cache($iCacheSec); ormDocument::DownloadDocument($oPage, $sClass, $id, $sField, 'inline'); $oKPI->ComputeAndReport('Data fetch and format'); diff --git a/sources/application/WebPage/WebPage.php b/sources/application/WebPage/WebPage.php index b621b0091..538e3b98a 100644 --- a/sources/application/WebPage/WebPage.php +++ b/sources/application/WebPage/WebPage.php @@ -727,6 +727,13 @@ class WebPage implements Page $this->add_header('Expires: 0'); } + public function set_cache($iCacheSec) + { + $this->add_header("Cache-Control: max-age=$iCacheSec"); + $this->add_header("Pragma: cache"); + $this->add_header("Expires: "); + } + /** * Build a special kind of TABLE useful for displaying the details of an object from a hash array of data *