Can resize and crop images in the ticketsup module
This commit is contained in:
parent
f8ca4b1b5c
commit
f46df6d8e5
@ -69,6 +69,7 @@ $object = new Commande($db);
|
|||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($object->fetch($id))
|
if ($object->fetch($id))
|
||||||
{
|
{
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
|||||||
@ -1226,14 +1226,14 @@ class FormFile
|
|||||||
if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service';
|
if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service';
|
||||||
|
|
||||||
$disablecrop=1;
|
$disablecrop=1;
|
||||||
if (in_array($modulepart, array('societe','product','produit','service','expensereport','holiday','project','user'))) $disablecrop=0;
|
if (in_array($modulepart, array('societe','product','produit','service','expensereport','holiday','project','ticketsup','user'))) $disablecrop=0;
|
||||||
|
|
||||||
if (! $disablecrop && image_format_supported($file['name']) > 0)
|
if (! $disablecrop && image_format_supported($file['name']) > 0)
|
||||||
{
|
{
|
||||||
if ($permtoeditline)
|
if ($permtoeditline)
|
||||||
{
|
{
|
||||||
// Link to resize
|
// Link to resize
|
||||||
print '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode($newmodulepart).'&id='.$object->id.'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),'resize','class="paddingrightonly"').'</a>';
|
print '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode($newmodulepart).'&id='.$object->id.'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])).'" title="'.dol_escape_htmltag($langs->trans("ResizeOrCrop")).'">'.img_picto($langs->trans("ResizeOrCrop"),'resize','class="paddingrightonly"').'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,6 +77,12 @@ elseif ($modulepart == 'societe')
|
|||||||
if (! $user->rights->societe->lire) accessforbidden();
|
if (! $user->rights->societe->lire) accessforbidden();
|
||||||
$accessallowed=1;
|
$accessallowed=1;
|
||||||
}
|
}
|
||||||
|
elseif ($modulepart == 'ticketsup')
|
||||||
|
{
|
||||||
|
$result=restrictedArea($user,'ticketsup',$id,'ticketsup');
|
||||||
|
if (! $user->rights->ticketsup->read) accessforbidden();
|
||||||
|
$accessallowed=1;
|
||||||
|
}
|
||||||
|
|
||||||
// Security:
|
// Security:
|
||||||
// Limit access if permissions are wrong
|
// Limit access if permissions are wrong
|
||||||
@ -154,6 +160,20 @@ elseif ($modulepart == 'expensereport')
|
|||||||
$dir=$conf->expensereport->dir_output; // By default
|
$dir=$conf->expensereport->dir_output; // By default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elseif ($modulepart == 'ticketsup')
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/ticketsup/class/ticketsup.class.php';
|
||||||
|
$object = new Ticketsup($db);
|
||||||
|
if ($id > 0)
|
||||||
|
{
|
||||||
|
$result = $object->fetch($id);
|
||||||
|
if ($result <= 0) dol_print_error($db,'Failed to load object');
|
||||||
|
$dir=$conf->ticketsup->dir_output; // By default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print 'Action crop for module part '.$modulepart.' is not supported yet.';
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($backtourl))
|
if (empty($backtourl))
|
||||||
{
|
{
|
||||||
@ -161,8 +181,9 @@ if (empty($backtourl))
|
|||||||
else if (in_array($modulepart, array('expensereport'))) $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
else if (in_array($modulepart, array('expensereport'))) $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
||||||
else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
|
else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/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('user'))) $backtourl=DOL_URL_ROOT."/user/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('ticketsup'))) $backtourl=DOL_URL_ROOT."/ticketsup/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"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -185,6 +185,7 @@ ToLink=Link
|
|||||||
Select=Select
|
Select=Select
|
||||||
Choose=Choose
|
Choose=Choose
|
||||||
Resize=Resize
|
Resize=Resize
|
||||||
|
ResizeOrCrop=Resize or Crop
|
||||||
Recenter=Recenter
|
Recenter=Recenter
|
||||||
Author=Author
|
Author=Author
|
||||||
User=User
|
User=User
|
||||||
|
|||||||
@ -33,12 +33,10 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT . "/core/lib/company.lib.php";
|
require_once DOL_DOCUMENT_ROOT . "/core/lib/company.lib.php";
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
|
||||||
|
|
||||||
$langs->load("companies");
|
$langs->loadLangs(array("companies","other","ticketsup"));
|
||||||
$langs->load('other');
|
|
||||||
$langs->load("ticketsup");
|
|
||||||
|
|
||||||
$action = GETPOST('action');
|
$action = GETPOST('action','alpha');
|
||||||
$confirm = GETPOST('confirm');
|
$confirm = GETPOST('confirm','alpha');
|
||||||
$id = GETPOST('id', 'int');
|
$id = GETPOST('id', 'int');
|
||||||
$track_id = GETPOST('track_id', 'alpha');
|
$track_id = GETPOST('track_id', 'alpha');
|
||||||
$ref = GETPOST('ref', 'alpha');
|
$ref = GETPOST('ref', 'alpha');
|
||||||
@ -61,7 +59,6 @@ $pagenext = $page + 1;
|
|||||||
if (!$sortorder) {
|
if (!$sortorder) {
|
||||||
$sortorder = "ASC";
|
$sortorder = "ASC";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$sortfield) {
|
if (!$sortfield) {
|
||||||
$sortfield = "name";
|
$sortfield = "name";
|
||||||
}
|
}
|
||||||
@ -75,22 +72,22 @@ $object->ref = $object->track_id;
|
|||||||
|
|
||||||
|
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
setEventMessage($object->error, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
} else {
|
} else {
|
||||||
$upload_dir = $conf->ticketsup->dir_output . "/" . dol_sanitizeFileName($object->track_id);
|
$upload_dir = $conf->ticketsup->dir_output . "/" . dol_sanitizeFileName($object->track_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
// Included file moved into Dolibarr 4, keep it for compatibility
|
|
||||||
$res=@include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
|
||||||
if (! $res) {
|
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
$object->ref = $old_ref;
|
$object->ref = $old_ref;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -155,10 +152,12 @@ if ($object->id) {
|
|||||||
foreach ($filearray as $key => $file) {
|
foreach ($filearray as $key => $file) {
|
||||||
$totalsize += $file['size'];
|
$totalsize += $file['size'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// For compatibility we use track ID for directory
|
// For compatibility we use track ID for directory
|
||||||
$object->ref = $object->track_id;
|
$object->ref = $object->track_id;
|
||||||
$modulepart = 'ticketsup';
|
$modulepart = 'ticketsup';
|
||||||
$permission = $user->rights->ticketsup->write;
|
$permission = $user->rights->ticketsup->write;
|
||||||
|
$permtoedit = $user->rights->ticketsup->write;
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user