diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 9cad5a7383f..27d03465d98 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -455,17 +455,17 @@ class FormFile /** - * \brief Show list of documents in a directory - * \param filearray Array of files loaded by dol_dir_list function - * \param object Object on which document is linked to - * \param modulepart Value for modulepart used by download wrapper - * \param param Parameters on sort links - * \param forcedownload Force to open dialog box "Save As" when clicking on file - * \param relativepath Relative path of docs (autodefined if not provided) - * \param permtodelete Permission to delete - * \param useinecm Change output for use in ecm module - * \param textifempty Text to show if filearray is empty - * \return int <0 if KO, nb of files shown if OK + * Show list of documents in a directory + * @param filearray Array of files loaded by dol_dir_list function + * @param object Object on which document is linked to + * @param modulepart Value for modulepart used by download wrapper + * @param param Parameters on sort links + * @param forcedownload Force to open dialog box "Save As" when clicking on file + * @param relativepath Relative path of docs (autodefined if not provided) + * @param permtodelete Permission to delete + * @param useinecm Change output for use in ecm module + * @param textifempty Text to show if filearray is empty + * @return int <0 if KO, nb of files shown if OK */ function list_of_documents($filearray,$object,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0) { @@ -510,11 +510,9 @@ class FormFile print ''.dol_print_size($file['size'],1,1).''; print ''.dol_print_date($file['date'],"dayhour").''; print ''; - //print ' '; - if ($permtodelete) - print ''.img_delete().''; - else - print ' '; + if (! empty($useinecm)) print ''.img_view().'   '; + if ($permtodelete) print ''.img_delete().''; + else print ' '; print "\n"; } } diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php index 5836c2540e9..5ce624f94a8 100644 --- a/htdocs/ecm/docfile.php +++ b/htdocs/ecm/docfile.php @@ -26,8 +26,9 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); -require_once(DOL_DOCUMENT_ROOT."/ecm/class/htmlecm.form.class.php"); require_once(DOL_DOCUMENT_ROOT."/ecm/class/ecmdirectory.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/ecm.lib.php"); // Load traductions files $langs->load("ecm"); @@ -48,9 +49,6 @@ if (!$user->rights->ecm->setup) accessforbidden(); // Get parameters $socid = isset($_GET["socid"])?$_GET["socid"]:''; -$section=$_GET["section"]; -if (! $section) $section='misc'; -$upload_dir = $conf->ecm->dir_output.'/'.$section; $page=$_GET["page"]; $sortorder=$_GET["sortorder"]; @@ -61,19 +59,29 @@ $offset = $limit * $page ; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="label"; -$fileid=$_REQUEST["fileid"]; -if (! $fileid) -{ - dol_print_error('',"ErrorParamNotDefined"); - exit; -} -$section=$_REQUEST["section"]; +$section=GETPOST("section"); if (! $section) { - dol_print_error('',"ErrorSectionParamNotDefined"); - exit; + dol_print_error('','Error, section parameter missing'); + exit; +} +$urlfile=GETPOST("urlfile"); +if (! $urlfile) +{ + dol_print_error('',"ErrorParamNotDefined"); + exit; } +// Load ecm object +$ecmdir = new ECMDirectory($db); +$result=$ecmdir->fetch(GETPOST("section")); +if (! $result > 0) +{ + dol_print_error($db,$ecmdir->error); + exit; +} +$relativepath=$ecmdir->getRelativePath(); +$upload_dir = $conf->ecm->dir_output.'/'.$relativepath; /* @@ -97,6 +105,45 @@ if (! empty($_GET["fileid"])) * Put here all code to do according to value of "action" parameter ********************************************************************/ +// Rename file +if (GETPOST('action') == 'update' && ! GETPOST('cancel')) +{ + $error=0; + + $oldlabel=GETPOST('urlfile'); + $newlabel=GETPOST('label'); + + //$db->begin(); + + $olddir=$ecmdir->getRelativePath(0); + $olddir=$conf->ecm->dir_output.'/'.$olddir; + $newdir=$olddir; + + $oldfile=$olddir.$oldlabel; + $newfile=$newdir.$newlabel; + + //print $oldfile.' - '.$newfile; + if ($newlabel != $oldlabel) + { + $result=dol_move($oldfile,$newfile); + if (! $result) + { + $langs->load('errors'); + $mesg='
'.$langs->trans('ErrorFailToRenameFile',$oldfile,$newfile).'
'; + $error++; + } + } + + if (! $error) + { + //$db->commit(); + $urlfile=$newlabel; + } + else + { + //$db->rollback(); + } +} @@ -109,18 +156,21 @@ if (! empty($_GET["fileid"])) llxHeader(); $form=new Form($db); -$formecm=new FormEcm($db); +$fullpath=$conf->ecm->dir_output.'/'.$ecmdir->label.'/'.$urlfile; +$file->section_id=$ecmdir->id; +$file->label=$urlfile; -$head = ecm_prepare_head($ecmdir); -dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual")); +$head = ecm_file_prepare_head($file); +dol_fiche_head($head, 'card', $langs->trans("File"), 0, 'generic'); if ($_GET["action"] == 'edit') { print '
'; print ''; - print ''; + print ''; + print ''; print ''; } @@ -134,11 +184,7 @@ $i=0; while ($tmpecmdir && $result > 0) { $tmpecmdir->ref=$tmpecmdir->label; - if ($i == 0 && $_GET["action"] == 'edit') - { - $s=''; - } - else $s=$tmpecmdir->getNomUrl(1).$s; + $s=$tmpecmdir->getNomUrl(1).$s; if ($tmpecmdir->fk_parent) { $s=' -> '.$s; @@ -153,8 +199,11 @@ while ($tmpecmdir && $result > 0) print img_picto('','object_dir').' '.$langs->trans("ECMRoot").' -> '; print $s; +print ' -> '; +if (GETPOST('action') == 'edit') print ''; +else print $urlfile; print ''; -print ''.$langs->trans("Description").''; +/*print ''.$langs->trans("Description").''; if ($_GET["action"] == 'edit') { print '