From 71d49f1c6f5761b9e09e980eeedc457c2ff1555a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 1 Aug 2017 18:32:21 +0200 Subject: [PATCH] Fix pb in ecm --- htdocs/core/ajax/ajaxdirpreview.php | 4 +- htdocs/core/class/html.form.class.php | 28 ++++++++----- htdocs/core/class/html.formfile.class.php | 6 +-- htdocs/core/lib/files.lib.php | 26 +++++++----- htdocs/core/lib/functions.lib.php | 2 +- htdocs/core/modules/modECM.class.php | 2 +- htdocs/ecm/class/ecmdirectory.class.php | 28 ++++++++++++- htdocs/ecm/docfile.php | 8 ++-- htdocs/ecm/docmine.php | 50 +++++++++++++++-------- htdocs/ecm/index.php | 4 +- 10 files changed, 105 insertions(+), 53 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 709d07c0832..cee16f923f5 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -202,7 +202,7 @@ if ($type == 'directory') $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; // If $section defined with value 0 - if ($section === '0') + if ($section === '0' || empty($section)) { $filearray=array(); } @@ -216,7 +216,7 @@ if ($type == 'directory') else if ($section === '0') $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>'; else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); - $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,$maxlengthname,'',$url); + $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,$maxlengthname,'',$url); } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 27115d12eb7..c7dd20547f4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5890,18 +5890,22 @@ class Form $object->next_prev_filter.=$hookmanager->resPrint; } - //print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; - $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix); - - $navurl = $_SERVER["PHP_SELF"]; - // Special case for project/task page - if ($paramid == 'project_ref') + $previous_ref = $next_ref = ''; + if ($shownav) { - $navurl = preg_replace('/\/tasks\/(task|contact|time|note|document).php/','/tasks.php',$navurl); - $paramid='ref'; + //print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; + $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix); + + $navurl = $_SERVER["PHP_SELF"]; + // Special case for project/task page + if ($paramid == 'project_ref') + { + $navurl = preg_replace('/\/tasks\/(task|contact|time|note|document)\.php/','/tasks.php',$navurl); + $paramid='ref'; + } + $previous_ref = $object->ref_previous?'<a href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'"><i class="fa fa-chevron-left"></i></a>':'<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>'; + $next_ref = $object->ref_next?'<a href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'"><i class="fa fa-chevron-right"></i></a>':'<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>'; } - $previous_ref = $object->ref_previous?'<a href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'"><i class="fa fa-chevron-left"></i></a>':'<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>'; - $next_ref = $object->ref_next?'<a href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'"><i class="fa fa-chevron-right"></i></a>':'<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>'; //print "xx".$previous_ref."x".$next_ref; $ret.='<!-- Start banner content --><div style="vertical-align: middle">'; @@ -5955,6 +5959,10 @@ class Form { $ret.=$object->label; } + else if ($object->element == 'ecm_directories') + { + $ret.=''; + } else if ($fieldref != 'none') $ret.=dol_htmlentities($object->$fieldref); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 040ae1ba96e..c02d2b5c2be 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1007,9 +1007,9 @@ class FormFile print '<table width="100%" id="tablelines" class="'.($useinecm?'liste noborder':'liste').'">'."\n"; print '<tr class="liste_titre nodrag nodrop">'; - print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),$url,"date","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre('Documents2',$url,"name","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre('Size',$url,"size","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('Date',$url,"date","",$param,'align="center"',$sortfield,$sortorder); if (empty($useinecm)) print_liste_field_titre('',$url,"","",$param,'align="center"'); print_liste_field_titre(''); if (! $disablemove) print_liste_field_titre(''); diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0b8282ad5b6..394b3e76778 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1349,14 +1349,15 @@ function dol_init_file_process($pathtoscan='', $trackid='') * * @param string $upload_dir Directory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename) * @param int $allowoverwrite 1=Allow overwrite existing file - * @param int $donotupdatesession 1=Do no edit _SESSION variable + * @param int $donotupdatesession 1=Do no edit _SESSION variable but update database index. 0=Update _SESSION and not database index. * @param string $varfiles _FILES var name * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' * @param string $link Link to add (to add a link instead of a file) * @param string $trackid Track id (used to prefix name of session vars to avoid conflict) + * @param int $generatethumbs 1=Generate also thumbs for uploaded image files * @return int <=0 if KO, >0 if OK */ -function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='') +function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1) { global $db,$user,$conf,$langs; @@ -1407,16 +1408,19 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; // Generate thumbs. - if (image_format_supported($destfull) == 1) + if ($generatethumbs) { - // Create thumbs - // We can't use $object->addThumbs here because there is no $object known - - // Used on logon for example - $imgThumbSmall = vignette($destfull, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); - // Create mini thumbs for image (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + if (image_format_supported($destfull) == 1) + { + // Create thumbs + // We can't use $object->addThumbs here because there is no $object known + + // Used on logon for example + $imgThumbSmall = vignette($destfull, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + } } // Update session diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 61093ebcc52..0b629c1f215 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1341,7 +1341,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>'; } - if ($object->element != 'product' && $object->element != 'bookmark') + if ($object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories') { $morehtmlref.='<div class="refidno">'; $morehtmlref.=$object->getBannerAddress('refaddress',$object); diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index b263b16e29e..bfe0e45e02c 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -63,7 +63,7 @@ class modECM extends DolibarrModules $this->picto='dir'; // Data directories to create when module is enabled - $this->dirs = array("/ecm/temp"); + $this->dirs = array("/ecm/My_First_Directory","/ecm/temp"); // Config pages. Put here list of php page names stored in admmin directory used to setup module $this->config_page_url = array('ecm.php'); diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 31439fa5ba3..5f713bdab91 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -27,8 +27,9 @@ */ class EcmDirectory // extends CommonObject { - //public $element='ecm_directories'; //!< Id that identify managed objects + public $element='ecm_directories'; //!< Id that identify managed objects //public $table_element='ecm_directories'; //!< Name of table without prefix where object is stored + var $picto = 'dir'; var $id; @@ -514,6 +515,31 @@ class EcmDirectory // extends CommonObject } + /** + * Retourne le libelle du status d'un user (actif, inactif) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->status,$mode); + } + + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto + * @return string Label of status + */ + static function LibStatut($status,$mode=0) + { + global $langs; + return ''; + } + + /** * Reconstruit l'arborescence des categories sous la forme d'un tableau à partir de la base de donnée * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php index 31f9b6b11c2..577ac3e0262 100644 --- a/htdocs/ecm/docfile.php +++ b/htdocs/ecm/docfile.php @@ -78,7 +78,7 @@ if (! $urlfile) // Load ecm object $ecmdir = new EcmDirectory($db); -$result=$ecmdir->fetch(GETPOST("section")); +$result=$ecmdir->fetch(GETPOST("section",'alpha')); if (! $result > 0) { dol_print_error($db,$ecmdir->error); @@ -109,10 +109,10 @@ if (! empty($_GET["fileid"])) * Put here all code to do according to value of "action" parameter ********************************************************************/ -if ($action == 'cancel') +if ($action == 'cancel') { $action =''; - if ($backtourl) + if ($backtourl) { header("Location: ".$backtourl); exit; @@ -144,7 +144,7 @@ if ($action == 'update') //print $oldfile.' - '.$newfile; if ($newlabel != $oldlabel) { - $result=dol_move($oldfile,$newfile); + $result=dol_move($oldfile, $newfile); if (! $result) { $langs->load('errors'); diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php index 48f39cb12f2..f418627d1be 100644 --- a/htdocs/ecm/docmine.php +++ b/htdocs/ecm/docmine.php @@ -191,15 +191,15 @@ if ($action == 'update' && ! GETPOST('cancel')) /******************************************************************* -* PAGE -* -* Put here all code to do according to value of "action" parameter +* View ********************************************************************/ -llxHeader(); - $form=new Form($db); +$object=new EcmDirectory($db); // Need to create a new one +$object->fetch($ecmdir->id); + +llxHeader(); // Built the file List $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); @@ -211,7 +211,8 @@ foreach($filearray as $key => $file) $head = ecm_prepare_head($ecmdir); -dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), '', 'dir'); +dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), -1, 'dir'); + if ($action == 'edit') { @@ -221,13 +222,11 @@ if ($action == 'edit') print '<input type="hidden" name="action" value="update">'; } -print '<table class="border" width="100%">'; -print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'; $s=''; -$tmpecmdir=new EcmDirectory($db); // Need to create a new one -$tmpecmdir->fetch($ecmdir->id); $result = 1; $i=0; +$tmpecmdir=new EcmDirectory($db); // Need to create a new one +$tmpecmdir->fetch($ecmdir->id); while ($tmpecmdir && $result > 0) { $tmpecmdir->ref=$tmpecmdir->label; @@ -248,10 +247,21 @@ while ($tmpecmdir && $result > 0) $i++; } +$morehtml=''; + +$morehtmlref = '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s; + +dol_banner_tab($object, '', $morehtml, 0, '', '', $morehtmlref); + +print '<div class="fichecenter">'; + +print '<div class="underbanner clearboth"></div>'; +print '<table class="border" width="100%">'; +/*print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'; print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '; print $s; -print '</td></tr>'; -print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; +print '</td></tr>';*/ +print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; if ($action == 'edit') { print '<textarea class="flat" name="description" cols="80">'; @@ -283,20 +293,24 @@ print '</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'; print dol_print_size($totalsize); print '</td></tr>'; +print '</table>'; + if ($action == 'edit') { - print '<tr><td colspan="2" align="center">'; + print '<br><div align="center">'; print '<input type="submit" class="button" name="submit" value="'.$langs->trans("Save").'">'; print ' '; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; - print '</td></tr>'; + print '</div>'; } -print '</table>'; + +print '</div>'; if ($action == 'edit') { print '</form>'; } -print '</div>'; + +dol_fiche_end(); @@ -341,7 +355,7 @@ if ($action != 'edit' && $action != 'delete') if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"].'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile'); - + } // Confirm remove file @@ -349,7 +363,7 @@ if ($action == 'delete_dir') { $relativepathwithoutslash=preg_replace('/[\/]$/','',$relativepath); print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"], $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', '', 1, 1); - + } $formfile=new FormFile($db); diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 28913f9aa11..bc2b781d2dc 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -110,7 +110,7 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) if (! $error) { - $res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', '', ''); + $res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', '', '', 0); if ($res > 0) { $result=$ecmdir->changeNbOfFiles('+'); @@ -430,7 +430,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti // Manual section $htmltooltip=$langs->trans("ECMAreaDesc2"); - + if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { print '<tr><td colspan="6">'; -- GitLab