diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 3e96cefd5a3..9f0c509f53a 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -61,13 +61,15 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $upload_dir = dirname(str_replace("../", "/", $rootdirfordoc.'/'.$file)); - $ecmdir = new EcmDirectory($db); - $result = $ecmdir->fetch($section); - if (!$result > 0) - { - //dol_print_error($db,$ecmdir->error); - //exit; - } + $ecmdir = new EcmDirectory($db); + if ($section > 0) { + $result = $ecmdir->fetch($section); + if (!$result > 0) + { + //dol_print_error($db,$ecmdir->error); + //exit; + } + } } else // For no ajax call { $rootdirfordoc = $conf->ecm->dir_output; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 15de01d4127..97b929cce20 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1035,7 +1035,7 @@ class FormFile if ($disablecrop == -1) { $disablecrop = 1; - if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'member', 'mrp', 'project', 'product', 'produit', 'propal', 'service', 'societe', 'tax', 'tax-vat', 'ticket', 'user'))) $disablecrop = 0; + if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'medias', 'member', 'mrp', 'project', 'product', 'produit', 'propal', 'service', 'societe', 'tax', 'tax-vat', 'ticket', 'user'))) $disablecrop = 0; } // Define relative path used to store the file @@ -1292,11 +1292,11 @@ class FormFile // Delete or view link // ($param must start with &) print ''; - if ($useinecm == 1 || $useinecm == 5) + if ($useinecm == 1 || $useinecm == 5) // ECM manual tree { - print ''.img_edit('default', 0, 'class="paddingrightonly"').''; + print ''.img_edit('default', 0, 'class="paddingrightonly"').''; } - if (empty($useinecm) || $useinecm == 2 || $useinecm == 6) + if (empty($useinecm) || $useinecm == 2 || $useinecm == 6) // 6=Media file manager { $newmodulepart = $modulepart; if (in_array($modulepart, array('product', 'produit', 'service'))) $newmodulepart = 'produit|service'; @@ -1306,7 +1306,13 @@ class FormFile if ($permtoeditline) { // Link to resize - print ''.img_picto($langs->trans("ResizeOrCrop"), 'resize', 'class="paddingrightonly"').''; + $moreparaminurl = ''; + if ($object->id > 0) { + $moreparaminurl = '&id='.$object->id; + } elseif (GETPOST('website', 'alpha')) { + $moreparaminurl = '&website='.GETPOST('website', 'alpha'); + } + print ''.img_picto($langs->trans("ResizeOrCrop"), 'resize', 'class="paddingrightonly"').''; } } diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index eeb39fd5020..b809897739c 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -40,7 +40,7 @@ $cancel = GETPOST('cancel', 'alpha'); $file = GETPOST('file', 'alpha'); $num = GETPOST('num', 'alpha'); // Used for document on bank statement - +$website = GETPOST('website', 'alpha'); // Security check if (empty($modulepart)) accessforbidden('Bad value for modulepart'); @@ -80,6 +80,11 @@ if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'serv $result = restrictedArea($user, 'banque', $id, 'bank_account'); if (!$user->rights->banque->lire) accessforbidden(); $accessallowed = 1; +} elseif ($modulepart == 'medias') +{ + $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write); + if (!$permtoadd) accessforbidden(); + $accessallowed = 1; } else // ticket, holiday, expensereport, societe... { $result = restrictedArea($user, $modulepart, $id, $modulepart); @@ -207,8 +212,7 @@ if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'serv if ($result <= 0) dol_print_error($db, 'Failed to load object'); $dir = $conf->$modulepart->dir_output; // By default } -} elseif ($modulepart == 'mrp') -{ +} elseif ($modulepart == 'mrp') { require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; $object = new MO($db); if ($id > 0) @@ -217,8 +221,7 @@ if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'serv if ($result <= 0) dol_print_error($db, 'Failed to load object'); $dir = $conf->$modulepart->dir_output; // By default } -} elseif ($modulepart == 'bank') -{ +} elseif ($modulepart == 'bank') { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $object = new Account($db); if ($id > 0) @@ -227,6 +230,8 @@ if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'serv if ($result <= 0) dol_print_error($db, 'Failed to load object'); $dir = $conf->bank->dir_output; // By default } +} elseif ($modulepart == 'medias') { + $dir = $dolibarr_main_data_root.'/'.$modulepart; } else { print 'Action crop for modulepart = '.$modulepart.' is not supported yet by photos_resize.php.'; } @@ -250,6 +255,8 @@ if (empty($backtourl)) $backtourl = DOL_URL_ROOT."/compta/bank/account_statement_document.php?id=".$id.'&num='.urlencode($num).'&file='.urldecode($file); } elseif (in_array($modulepart, array('bank'))) $backtourl = DOL_URL_ROOT."/compta/bank/document.php?id=".$id.'&file='.urldecode($file); elseif (in_array($modulepart, array('mrp'))) $backtourl = DOL_URL_ROOT."/mrp/mo_document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('medias'))) $backtourl = DOL_URL_ROOT."/website/index.php?action=file_manager&website=".$website."&file=".urldecode($file).'&preopend=image'; + // Generic case that should work for everybody else else $backtourl = DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($file); } @@ -278,7 +285,10 @@ if ($action == 'confirm_resize' && GETPOSTISSET("file") && GETPOSTISSET("sizex") if ($result == $fullpath) { - $object->addThumbs($fullpath); + // If image is related to a given object, we create also thumbs. + if (is_object($object)) { + $object->addThumbs($fullpath); + } // Update/create database for file $fullpath $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $fullpath); @@ -343,7 +353,9 @@ if ($action == 'confirm_crop') if ($result == $fullpath) { - $object->addThumbs($fullpath); + if (is_object($object)) { + $object->addThumbs($fullpath); + } // Update/create database for file $fullpath $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $fullpath); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 24ef7601ce3..67d68cb8d53 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -670,10 +670,12 @@ body[class*="colorblind-"] .text-success{ color : } -.editfielda span.fa-pencil-alt, .editfielda span.fa-pencil-ruler, .editfielda span.fa-trash, .editfieldlang { +.editfielda span.fa-pencil-alt, .editfielda span.fa-pencil-ruler, .editfielda span.fa-trash, .editfielda span.fa-crop, +.editfieldlang { color: #ccc !important; } -.editfielda span.fa-pencil-alt:hover, .editfielda span.fa-pencil-ruler:hover, .editfielda span.fa-trash:hover, .editfieldlang:hover { +.editfielda span.fa-pencil-alt:hover, .editfielda span.fa-pencil-ruler:hover, .editfielda span.fa-trash:hover, .editfielda span.fa-crop:hover, +.editfieldlang:hover { color: var(--colortexttitle) !important; } .fawidth30 {