mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
N°1750 Portal: Fix broken attachment preview and link on object creation (worked on object edition)
This commit is contained in:
@@ -1379,7 +1379,8 @@ class ObjectController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checking security layers
|
// Checking security layers
|
||||||
if (!SecurityHelper::IsActionAllowed($oApp, UR_ACTION_READ, $sHostClass, $sHostId))
|
// Note: Checking if host object already exists as we can try to download document from an object that is being created
|
||||||
|
if (($sHostId > 0) && !SecurityHelper::IsActionAllowed($oApp, UR_ACTION_READ, $sHostClass, $sHostId))
|
||||||
{
|
{
|
||||||
IssueLog::Warning(__METHOD__ . ' at line ' . __LINE__ . ' : User #' . UserRights::GetUserId() . ' not allowed to retrieve document from attribute ' . $sObjectField . ' as it not allowed to read ' . $sHostClass . '::' . $sHostId . ' object.');
|
IssueLog::Warning(__METHOD__ . ' at line ' . __LINE__ . ' : User #' . UserRights::GetUserId() . ' not allowed to retrieve document from attribute ' . $sObjectField . ' as it not allowed to read ' . $sHostClass . '::' . $sHostId . ' object.');
|
||||||
$oApp->abort(404, Dict::S('UI:ObjectDoesNotExist'));
|
$oApp->abort(404, Dict::S('UI:ObjectDoesNotExist'));
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class BsFileUploadFieldRenderer extends FieldRenderer
|
|||||||
|
|
||||||
$(this).closest('.fileupload_field_content').find('.attachments_container').append(
|
$(this).closest('.fileupload_field_content').find('.attachments_container').append(
|
||||||
'<div class="attachment col-xs-6 col-sm-3 col-md-2" id="display_attachment_'+data.result.att_id+'">'+
|
'<div class="attachment col-xs-6 col-sm-3 col-md-2" id="display_attachment_'+data.result.att_id+'">'+
|
||||||
' <a data-preview="'+data.result.preview+'" href="'+sDownloadLink+'" title="'+data.result.msg+'">'+
|
' <a data-preview="'+data.result.preview+'" href="'+sDownloadLink+'" target="_blank" title="'+data.result.msg+'">'+
|
||||||
' <div class="attachment_icon"><img src="'+data.result.icon+'"></div>'+
|
' <div class="attachment_icon"><img src="'+data.result.icon+'"></div>'+
|
||||||
' <div class="attachment_name">'+data.result.msg+'</div>'+
|
' <div class="attachment_name">'+data.result.msg+'</div>'+
|
||||||
' <input id="attachment_'+data.result.att_id+'" type="hidden" name="attachments[]" value="'+data.result.att_id+'"/>'+
|
' <input id="attachment_'+data.result.att_id+'" type="hidden" name="attachments[]" value="'+data.result.att_id+'"/>'+
|
||||||
@@ -127,7 +127,7 @@ class BsFileUploadFieldRenderer extends FieldRenderer
|
|||||||
if(data.result.preview){
|
if(data.result.preview){
|
||||||
$('#display_attachment_'+data.result.att_id).tooltip({
|
$('#display_attachment_'+data.result.att_id).tooltip({
|
||||||
html: true,
|
html: true,
|
||||||
title: function(){ return '<img src="'+sDownloadLink+'" style="max-width: 100%;" />'; }
|
title: function(){ return '<div style="width: 350px; height: 300px;"><img src="'+sDownloadLink+'" style="max-width: 100%; max-height: 100%;" /></div>'; }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Showing remove button on hover
|
// Showing remove button on hover
|
||||||
@@ -163,7 +163,7 @@ class BsFileUploadFieldRenderer extends FieldRenderer
|
|||||||
$('.attachment [data-preview="true"]').each(function(iIndex, oElem){
|
$('.attachment [data-preview="true"]').each(function(iIndex, oElem){
|
||||||
$(oElem).parent().tooltip({
|
$(oElem).parent().tooltip({
|
||||||
html: true,
|
html: true,
|
||||||
title: function(){ return '<img src="'+$(oElem).attr('href')+'" style="max-width: 100%;" />'; }
|
title: function(){ return '<div style="width: 350px; height: 300px;"><img src="'+$(oElem).attr('href')+'" style="max-width: 100%; max-height: 100%;" /></div>'; }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// Remove button handler
|
// Remove button handler
|
||||||
@@ -229,10 +229,14 @@ EOF
|
|||||||
return $oOutput;
|
return $oOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param RenderingOutput $oOutput
|
* @param \Combodo\iTop\Renderer\RenderingOutput $oOutput
|
||||||
*/
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \CoreException
|
||||||
|
* @throws \OQLException
|
||||||
|
*/
|
||||||
protected function PrepareExistingFiles(RenderingOutput &$oOutput)
|
protected function PrepareExistingFiles(RenderingOutput &$oOutput)
|
||||||
{
|
{
|
||||||
$sObjectClass = get_class($this->oField->GetObject());
|
$sObjectClass = get_class($this->oField->GetObject());
|
||||||
@@ -262,7 +266,7 @@ EOF
|
|||||||
$oOutput->Addhtml(
|
$oOutput->Addhtml(
|
||||||
<<<EOF
|
<<<EOF
|
||||||
<div class="attachment col-xs-6 col-sm-3 col-md-2" id="display_attachment_{$iAttId}">
|
<div class="attachment col-xs-6 col-sm-3 col-md-2" id="display_attachment_{$iAttId}">
|
||||||
<a data-preview="{$sPreview}" href="{$sDownloadLink}" title="{$sFileName}">
|
<a data-preview="{$sPreview}" href="{$sDownloadLink}" target="_blank" title="{$sFileName}" >
|
||||||
<div class="attachment_icon"><img src="{$sIcon}"></div>
|
<div class="attachment_icon"><img src="{$sIcon}"></div>
|
||||||
<div class="attachment_name">{$sFileName}</div>
|
<div class="attachment_name">{$sFileName}</div>
|
||||||
<input id="attachment_{$iAttId}" type="hidden" name="attachments[]" value="{$iAttId}"/>
|
<input id="attachment_{$iAttId}" type="hidden" name="attachments[]" value="{$iAttId}"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user