FIX Crop of large files was selecting wrong image area.
This commit is contained in:
parent
5bbf7e8f1d
commit
22170ac1c1
@ -1018,7 +1018,7 @@ class FormFile
|
|||||||
global $form;
|
global $form;
|
||||||
|
|
||||||
$disablecrop=1;
|
$disablecrop=1;
|
||||||
if (in_array($modulepart, array('societe','product','produit','service','expensereport','holiday','member','project','ticket','user'))) $disablecrop=0;
|
if (in_array($modulepart, array('expensereport','holiday','member','project','product','produit','service','societe','tax','ticket','user'))) $disablecrop=0;
|
||||||
|
|
||||||
// Define relative path used to store the file
|
// Define relative path used to store the file
|
||||||
if (empty($relativepath))
|
if (empty($relativepath))
|
||||||
|
|||||||
@ -83,6 +83,12 @@ elseif ($modulepart == 'societe')
|
|||||||
if (! $user->rights->societe->lire) accessforbidden();
|
if (! $user->rights->societe->lire) accessforbidden();
|
||||||
$accessallowed=1;
|
$accessallowed=1;
|
||||||
}
|
}
|
||||||
|
elseif ($modulepart == 'tax')
|
||||||
|
{
|
||||||
|
$result=restrictedArea($user, 'tax', $id, 'chargesociales','charges');
|
||||||
|
if (! $user->rights->tax->charges->lire) accessforbidden();
|
||||||
|
$accessallowed=1;
|
||||||
|
}
|
||||||
elseif ($modulepart == 'ticket')
|
elseif ($modulepart == 'ticket')
|
||||||
{
|
{
|
||||||
$result=restrictedArea($user,'ticket',$id,'ticket');
|
$result=restrictedArea($user,'ticket',$id,'ticket');
|
||||||
@ -177,6 +183,17 @@ elseif ($modulepart == 'expensereport')
|
|||||||
$dir=$conf->expensereport->dir_output; // By default
|
$dir=$conf->expensereport->dir_output; // By default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elseif ($modulepart == 'tax')
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
||||||
|
$object = new ChargeSociales($db);
|
||||||
|
if ($id > 0)
|
||||||
|
{
|
||||||
|
$result = $object->fetch($id);
|
||||||
|
if ($result <= 0) dol_print_error($db,'Failed to load object');
|
||||||
|
$dir=$conf->tax->dir_output; // By default
|
||||||
|
}
|
||||||
|
}
|
||||||
elseif ($modulepart == 'ticket')
|
elseif ($modulepart == 'ticket')
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
|
||||||
@ -200,7 +217,8 @@ if (empty($backtourl))
|
|||||||
else if (in_array($modulepart, array('member'))) $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
else if (in_array($modulepart, array('member'))) $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
||||||
else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
||||||
else if (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
else if (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
||||||
else if (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
else if (in_array($modulepart, array('tax'))) $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
||||||
|
else if (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
||||||
else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,6 +244,7 @@ if ($cancel)
|
|||||||
if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != ""))
|
if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != ""))
|
||||||
{
|
{
|
||||||
$fullpath=$dir."/".$original_file;
|
$fullpath=$dir."/".$original_file;
|
||||||
|
|
||||||
$result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']);
|
$result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']);
|
||||||
|
|
||||||
if ($result == $fullpath)
|
if ($result == $fullpath)
|
||||||
@ -294,6 +313,8 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
|
|||||||
if ($action == 'confirm_crop')
|
if ($action == 'confirm_crop')
|
||||||
{
|
{
|
||||||
$fullpath=$dir."/".$original_file;
|
$fullpath=$dir."/".$original_file;
|
||||||
|
|
||||||
|
//var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit;
|
||||||
$result=dol_imageResizeOrCrop($fullpath,1,$_POST['w'],$_POST['h'],$_POST['x'],$_POST['y']);
|
$result=dol_imageResizeOrCrop($fullpath,1,$_POST['w'],$_POST['h'],$_POST['x'],$_POST['y']);
|
||||||
|
|
||||||
if ($result == $fullpath)
|
if ($result == $fullpath)
|
||||||
@ -419,9 +440,9 @@ if (! empty($conf->use_javascript_ajax))
|
|||||||
// If image is too large, we use another scale.
|
// If image is too large, we use another scale.
|
||||||
if (! empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth']/2)))
|
if (! empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth']/2)))
|
||||||
{
|
{
|
||||||
$widthforcrop=round($_SESSION['dol_screenwidth']/2);
|
$ratioforcrop=2;
|
||||||
|
$widthforcrop=round($_SESSION['dol_screenwidth'] / $ratioforcrop);
|
||||||
$refsizeforcrop='screenwidth';
|
$refsizeforcrop='screenwidth';
|
||||||
$ratioforcrop=1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<!-- Form to crop -->'."\n";
|
print '<!-- Form to crop -->'."\n";
|
||||||
@ -448,7 +469,7 @@ if (! empty($conf->use_javascript_ajax))
|
|||||||
<input type="hidden" id="action" name="action" value="confirm_crop" />
|
<input type="hidden" id="action" name="action" value="confirm_crop" />
|
||||||
<input type="hidden" id="product" name="product" value="'.dol_escape_htmltag($id).'" />
|
<input type="hidden" id="product" name="product" value="'.dol_escape_htmltag($id).'" />
|
||||||
<input type="hidden" id="refsizeforcrop" name="refsizeforcrop" value="'.$refsizeforcrop.'" />
|
<input type="hidden" id="refsizeforcrop" name="refsizeforcrop" value="'.$refsizeforcrop.'" />
|
||||||
<input type="hidden" id="ratioforcrop" name="ratioforcrop" value="'.$ratioforcrop.'" />
|
<input type="hidden" id="ratioforcrop" name="ratioforcrop" value="'.$ratioforcrop.'" /><!-- field used by core/lib/lib_photoresize.js -->
|
||||||
<input type="hidden" name="modulepart" value="'.dol_escape_htmltag($modulepart).'" />
|
<input type="hidden" name="modulepart" value="'.dol_escape_htmltag($modulepart).'" />
|
||||||
<input type="hidden" name="id" value="'.dol_escape_htmltag($id).'" />
|
<input type="hidden" name="id" value="'.dol_escape_htmltag($id).'" />
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user