26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/ecm/class/htmlecm.form.class.php';
35$langs->loadLangs(array(
'ecm',
'companies',
'other'));
37$action =
GETPOST(
'action',
'alpha');
38$cancel =
GETPOST(
'cancel',
'aZ09');
39$backtopage =
GETPOST(
'backtopage',
'alpha');
40$confirm =
GETPOST(
'confirm',
'alpha');
42$module =
GETPOST(
'module',
'alpha');
43$website =
GETPOST(
'website',
'alpha');
51$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54if (empty($page) || $page == -1) {
57$offset = $limit * $page;
67$section =
GETPOST(
"section",
'alpha') ?
GETPOST(
"section",
'alpha') :
GETPOST(
"relativedir",
'alpha');
76if ($module ==
'ecm') {
78 $result = $ecmdir->fetch($section);
80 $relativepath = $ecmdir->getRelativePath();
81 $upload_dir = $conf->ecm->dir_output.
'/'.$relativepath;
83 $relativepath = $section;
84 $upload_dir = $conf->ecm->dir_output.
'/'.$relativepath;
87 $relativepath = $section;
88 $upload_dir = $conf->medias->multidir_output[$conf->entity].
'/'.$relativepath;
94$permissiontoupload = 0;
95if ($module ==
'ecm') {
96 $permissiontoread = $user->hasRight(
"ecm",
"read");
97 $permissiontoadd = $user->hasRight(
"ecm",
"setup");
98 $permissiontoupload = $user->hasRight(
"ecm",
"upload");
100if ($module ==
'medias') {
101 $permissiontoread = ($user->hasRight(
"mailing",
"lire") || $user->hasRight(
"website",
"read"));
102 $permissiontoadd = ($user->hasRight(
"mailing",
"creer") || $user->hasRight(
"website",
"write"));
103 $permissiontoupload = ($user->hasRight(
"mailing",
"creer") || $user->hasRight(
"website",
"write"));
106if (!$permissiontoread) {
119 if (is_numeric($resupload) && $resupload > 0) {
120 $result = $ecmdir->changeNbOfFiles(
'+');
122 $langs->load(
"errors");
123 if ($resupload < 0) {
125 } elseif (preg_match(
'/ErrorFileIsInfectedWithAVirus/', $resupload)) {
127 setEventMessages($langs->trans(
"ErrorFileIsInfectedWithAVirus"),
null,
'errors');
134 $langs->load(
"errors");
135 setEventMessages($langs->trans(
"ErrorFailToCreateDir", $upload_dir),
null,
'errors');
140if ($action ==
'confirm_deletefile' && $confirm ==
'yes' && $permissiontoupload) {
141 $langs->load(
"other");
142 $file = $upload_dir.
"/".
GETPOST(
'urlfile');
150 $result = $ecmdir->changeNbOfFiles(
'-');
154if ($action ==
'confirm_deletedir' && $confirm ==
'yes' && $permissiontoupload) {
155 $backtourl = DOL_URL_ROOT.
"/ecm/index.php";
156 if ($module ==
'medias') {
157 $backtourl = DOL_URL_ROOT.
"/website/index.php?file_manager=1";
160 $deletedirrecursive = (
GETPOST(
'deletedirrecursive',
'alpha') ==
'on' ? 1 : 0);
162 if ($module ==
'ecm' && $ecmdir->id > 0) {
164 $result = $ecmdir->delete($user,
'all', $deletedirrecursive);
166 $langs->load(
'errors');
167 setEventMessages($langs->trans($ecmdir->error, $ecmdir->label),
null,
'errors');
170 if ($deletedirrecursive) {
178 $langs->load(
'errors');
179 setEventMessages($langs->trans(
"ErrorFailToDeleteDir", $upload_dir),
null,
'errors');
184 header(
"Location: ".$backtourl);
190if ($action ==
'update' && !
GETPOST(
'cancel',
'alpha') && $permissiontoadd) {
193 if ($module ==
'ecm') {
194 $oldlabel = $ecmdir->label;
195 $olddir = $ecmdir->getRelativePath(0);
196 $olddir = $conf->ecm->dir_output.
'/'.$olddir;
198 $olddir =
GETPOST(
'section',
'alpha');
199 $olddir = $conf->medias->multidir_output[$conf->entity].
'/'.$relativepath;
202 if ($module ==
'ecm') {
208 if ($fk_parent == -1) {
209 $ecmdir->fk_parent = 0;
211 $ecmdir->fk_parent = $fk_parent;
213 $ecmdir->description =
GETPOST(
"description");
214 $ret = $extrafields->setOptionalsFromPost(
null, $ecmdir);
220 $result = $ecmdir->insertExtraFields();
226 $result = $ecmdir->update($user);
228 $newdir = $ecmdir->getRelativePath(1);
229 $newdir = $conf->ecm->dir_output.
'/'.$newdir;
231 if (($oldlabel != $ecmdir->label && file_exists($olddir)) || ($olddir != $newdir && file_exists($olddir))) {
232 $newdir = $ecmdir->getRelativePath(1);
233 $newdir = $conf->ecm->dir_output.
'/'.$newdir;
235 $result = @rename($olddir, $newdir);
237 $langs->load(
'errors');
238 setEventMessages($langs->trans(
'ErrorFailToRenameDir', $olddir, $newdir),
null,
'errors');
247 $relativepath = $ecmdir->getRelativePath();
248 $upload_dir = $conf->ecm->dir_output.
'/'.$relativepath;
257 $newdir = $conf->medias->multidir_output[$conf->entity].
'/'.
GETPOST(
'oldrelparentdir',
'alpha').
'/'.
GETPOST(
'label',
'alpha');
259 $result = @rename($olddir, $newdir);
261 $langs->load(
'errors');
262 setEventMessages($langs->trans(
'ErrorFailToRenameDir', $olddir, $newdir),
null,
'errors');
268 $relativepath =
GETPOST(
'oldrelparentdir',
'alpha').
'/'.
GETPOST(
'label',
'alpha');
269 $upload_dir = $conf->medias->multidir_output[$conf->entity].
'/'.$relativepath;
270 $section = $relativepath;
280$form =
new Form($db);
286$extrafields->fetch_name_optionals_label(
$object->table_element);
288if ($module ==
'ecm' && $ecmdir->id > 0) {
292llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-ecm page-dir_card');
295$filearrayall =
dol_dir_list($upload_dir,
"all", 0,
'',
'', $sortfield, (strtolower($sortorder) ==
'desc' ? SORT_DESC : SORT_ASC), 1);
296$filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) ==
'desc' ? SORT_DESC : SORT_ASC), 1);
298foreach ($filearray as $key => $file) {
299 $totalsize += $file[
'size'];
307if ($action ==
'edit') {
308 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
309 print
'<input type="hidden" name="token" value="'.newToken().
'">';
310 print
'<input type="hidden" name="section" value="'.$section.
'">';
311 print
'<input type="hidden" name="module" value="'.$module.
'">';
312 print
'<input type="hidden" name="action" value="update">';
318$morehtmlref =
'/'.$module.
'/'.$relativepath;
320if ($module ==
'ecm') {
325 if ($ecmdir->id > 0) {
326 $tmpecmdir->fetch($ecmdir->id);
327 while ($tmpecmdir && $result > 0) {
328 $tmpecmdir->ref = $tmpecmdir->label;
329 $s = $tmpecmdir->getNomUrl(1).$s;
330 if ($tmpecmdir->fk_parent) {
332 $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
339 $s .= implode(
' -> ', explode(
'/', $section));
341 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/ecm/index.php">'.$langs->trans(
"ECMRoot").
'</a> -> '.$s;
343if ($module ==
'medias') {
346 $subdirs = explode(
'/', $section);
348 foreach ($subdirs as $subdir) {
349 if ($i == (count($subdirs) - 1)) {
350 if ($action ==
'edit') {
351 $s .=
'<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$subdir.
'">';
352 $s .=
'<input type="hidden" name="oldrelparentdir" value="'.dirname($section).
'">';
353 $s .=
'<input type="hidden" name="oldreldir" value="'.basename($section).
'">';
358 if ($i < (count($subdirs) - 1)) {
359 $s .= $subdir.
' -> ';
368dol_banner_tab($object,
'', $morehtml, 0,
'',
'', $morehtmlref);
370print
'<div class="fichecenter">';
372print
'<div class="underbanner clearboth"></div>';
373print
'<table class="border centpercent tableforfield">';
378if ($module ==
'ecm') {
379 if ($action ==
'edit') {
380 print
'<tr><td class="titlefield tdtop">'.$langs->trans(
"ECMDirName").
'</td><td>';
381 print
'<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$ecmdir->label.
'">';
383 print
'<tr><td class="titlefield tdtop">'.$langs->trans(
"ECMParentDirectory").
'</td><td>';
384 print $formecm->selectAllSections($ecmdir->fk_parent,
'',
'ecm', array($ecmdir->id));
389 print
'<tr><td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
390 if ($action ==
'edit') {
391 print
'<textarea class="flat quatrevingtpercent" name="description">';
392 print $ecmdir->description;
399 print
'<tr><td class="titlefield">'.$langs->trans(
"ECMCreationUser").
'</td><td>';
400 if ($ecmdir->fk_user_c > 0) {
401 $userecm =
new User($db);
402 $userecm->fetch($ecmdir->fk_user_c);
403 print $userecm->getNomUrl(1);
407print
'<tr><td class="titlefield">'.$langs->trans(
"ECMCreationDate").
'</td><td>';
408if ($module ==
'ecm') {
415print
'<tr><td>'.$langs->trans(
"ECMDirectoryForFiles").
'</td><td>';
416if ($module ==
'ecm') {
417 print
'/ecm/'.$relativepath;
419 print
'/'.$module.
'/'.$relativepath;
422print
'<tr><td>'.$langs->trans(
"ECMNbOfDocs").
'</td><td>';
423$nbofiles = count($filearray);
425if ($ecmdir->id > 0) {
427 if ($nbofiles != $ecmdir->cachenbofdoc) {
428 $ecmdir->changeNbOfFiles((
string) $nbofiles);
432print
'<tr><td>'.$langs->trans(
"TotalSizeOfAttachedFiles").
'</td><td>';
435print
$object->showOptionals($extrafields, ($action ==
'edit' ?
'edit' :
'view'));
438if ($action ==
'edit') {
439 print $form->buttonsSaveCancel();
443if ($action ==
'edit') {
452if ($action !=
'edit' && $action !=
'delete' && $action !=
'deletefile') {
453 print
'<div class="tabsAction">';
455 if ($permissiontoadd) {
456 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().($module ?
'&module='.$module :
'').
'§ion='.$section.
'">'.$langs->trans(
'Edit').
'</a>';
459 if ($permissiontoadd) {
460 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/ecm/dir_add_card.php?action=create&token='.
newToken().($module ?
'&module='.$module :
'').
'&catParent='.$section.
'">'.$langs->trans(
'ECMAddSection').
'</a>';
462 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
'ECMAddSection').
'</a>';
465 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().($module ?
'&module='.urlencode($module) :
'').
'§ion='.urlencode($section).($backtopage ?
'&backtopage='.urlencode($backtopage) :
''),
'', $permissiontoadd);
472if ($action ==
'deletefile') {
473 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.urlencode(
GETPOST(
"section",
'alpha')).
'&urlfile='.urlencode(
GETPOST(
"urlfile")).($backtopage ?
'&backtopage='.urlencode($backtopage) :
''), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile');
477if ($action ==
'delete' || $action ==
'delete_dir') {
478 $relativepathwithoutslash = preg_replace(
'/[\/]$/',
'', $relativepath);
481 if (count($filearrayall) > 0) {
482 $langs->load(
"other");
483 $formquestion = array(
484 array(
'type' =>
'checkbox',
'name' =>
'deletedirrecursive',
'label' => $langs->trans(
"ContentOfDirectoryIsNotEmpty").
'<br>'.$langs->trans(
"DeleteAlsoContentRecursively"),
'value' =>
'0')
488 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.urlencode(
GETPOST(
'section',
'alpha')).($module ?
'&module='.$module :
'').($backtopage ?
'&backtopage='.urlencode($backtopage) :
''), $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $relativepathwithoutslash),
'confirm_deletedir', $formquestion, 1, 1);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage ECM directories.
Class to manage Dolibarr users.
ecm_prepare_head($object, $module='ecm', $section='')
Prepare array with list of tabs.
dol_filemtime($pathoffile)
Return time of a file.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Check validity of a file upload from an GUI page, and move it to its final destination.
dol_delete_dir($dir, $nophperrors=0)
Remove a directory (not recursive, so content must be empty).
dol_unescapefile($filename)
Unescape a file submitted by upload.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formatted size.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.