Fix: Can set savingdocmask by caller. Fix permissions names.
Fix: Disable crop on svg images.
This commit is contained in:
parent
8c1bba5a60
commit
8be0a6d470
@ -40,6 +40,7 @@ function image_format_supported($file)
|
||||
$regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php
|
||||
|
||||
// Case filename is not a format image
|
||||
$reg = array();
|
||||
if (! preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1;
|
||||
|
||||
// Case filename is a format image but not supported by this PHP
|
||||
@ -51,6 +52,7 @@ function image_format_supported($file)
|
||||
if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp';
|
||||
if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm';
|
||||
if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm';
|
||||
if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available
|
||||
if ($imgfonction)
|
||||
{
|
||||
if (! function_exists($imgfonction))
|
||||
|
||||
@ -20,10 +20,13 @@
|
||||
*/
|
||||
|
||||
// Following var can be set
|
||||
// $permission = permission or not to add a file
|
||||
// $permtoedit = permission or not to edit file name, crop file
|
||||
// $permissiontoadd = permission or not to add a file (can use also $permission) and permission or not to edit file name or crop file (can use also $permtoedit)
|
||||
// $modulepart = for download
|
||||
// $param = param to add to download links
|
||||
// $upload_dir
|
||||
// $object
|
||||
// $filearray
|
||||
// $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($langs) || ! is_object($langs))
|
||||
@ -35,7 +38,9 @@ if (empty($langs) || ! is_object($langs))
|
||||
|
||||
$langs->load("link");
|
||||
if (empty($relativepathwithnofile)) $relativepathwithnofile='';
|
||||
if (empty($permtoedit)) $permtoedit=-1;
|
||||
|
||||
if (! isset($permission)) $permission = $permissiontoadd;
|
||||
if (! isset($permtoedit)) $permtoedit = $permissiontoadd;
|
||||
|
||||
// Drag and drop for up and down allowed on product, thirdparty, ...
|
||||
// The drag and drop call the page core/ajax/row.php
|
||||
@ -66,19 +71,40 @@ if ($action == 'delete')
|
||||
|
||||
$formfile=new FormFile($db);
|
||||
|
||||
// We define var to enable the feature to add prefix of uploaded files
|
||||
$savingdocmask='';
|
||||
if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX))
|
||||
{
|
||||
//var_dump($modulepart);
|
||||
if (in_array($modulepart, array('facture_fournisseur','commande_fournisseur','facture','commande','propal','supplier_proposal','ficheinter','contract','expedition','project','project_task','expensereport','tax', 'produit', 'product_batch')))
|
||||
{
|
||||
$savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
|
||||
// We define var to enable the feature to add prefix of uploaded files.
|
||||
// Caller of this include can make
|
||||
// $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
|
||||
if (!isset($savingdocmask) || !empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) {
|
||||
$savingdocmask='';
|
||||
if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) {
|
||||
//var_dump($modulepart);
|
||||
if (in_array($modulepart, array(
|
||||
'facture_fournisseur',
|
||||
'commande_fournisseur',
|
||||
'facture',
|
||||
'commande',
|
||||
'propal',
|
||||
'supplier_proposal',
|
||||
'ficheinter',
|
||||
'contract',
|
||||
'expedition',
|
||||
'project',
|
||||
'project_task',
|
||||
'expensereport',
|
||||
'tax',
|
||||
'produit',
|
||||
'product_batch',
|
||||
'bom',
|
||||
'mrp'
|
||||
)))
|
||||
{
|
||||
$savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
|
||||
}
|
||||
/*if (in_array($modulepart,array('member')))
|
||||
{
|
||||
$savingdocmask=$object->login.'___file__';
|
||||
}*/
|
||||
}
|
||||
/*if (in_array($modulepart,array('member')))
|
||||
{
|
||||
$savingdocmask=$object->login.'___file__';
|
||||
}*/
|
||||
}
|
||||
|
||||
// Show upload form (document and links)
|
||||
|
||||
@ -133,10 +133,8 @@ if ($object->id)
|
||||
dol_fiche_end();
|
||||
|
||||
$modulepart = 'mrp';
|
||||
//$permission = $user->rights->mrp->create;
|
||||
$permission = 1;
|
||||
//$permtoedit = $user->rights->mrp->create;
|
||||
$permtoedit = 1;
|
||||
$permission = $user->rights->mrp->write;
|
||||
$permtoedit = $user->rights->mrp->write;
|
||||
$param = '&id=' . $object->id;
|
||||
|
||||
//$relativepathwithnofile='mo/' . dol_sanitizeFileName($object->id).'/';
|
||||
|
||||
@ -144,18 +144,6 @@ if ($object->id)
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
$modulepart = 'mymodule';
|
||||
//$permission = $user->rights->mymodule->create;
|
||||
$permission = 1;
|
||||
//$permtoedit = $user->rights->mymodule->create;
|
||||
$permtoedit = 1;
|
||||
$param = '&id=' . $object->id;
|
||||
|
||||
//$relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->id).'/';
|
||||
$relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->ref).'/';
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user