--- /tmp/dsg/dolibarr/htdocs/ecm/github_dir_add_card.php +++ /tmp/dsg/dolibarr/htdocs/ecm/client_dir_add_card.php @@ -41,24 +41,23 @@ $module = GETPOST('module', 'alpha'); $website = GETPOST('website', 'alpha'); $pageid = GETPOST('pageid', 'int'); -if (empty($module)) { - $module = 'ecm'; -} +if (empty($module)) $module = 'ecm'; // Security check -if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; +if ($user->socid > 0) +{ + $action = ''; + $socid = $user->socid; } $section = $urlsection = GETPOST('section', 'alpha'); -if (empty($urlsection)) { - $urlsection = 'misc'; -} - -if ($module == 'ecm') { +if (empty($urlsection)) $urlsection = 'misc'; + +if ($module == 'ecm') +{ $upload_dir = $conf->ecm->dir_output.'/'.$urlsection; -} else // For example $module == 'medias' +} +else // For example $module == 'medias' { $upload_dir = $conf->medias->multidir_output[$conf->entity]; } @@ -67,23 +66,19 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "label"; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "label"; $ecmdir = new EcmDirectory($db); -if (!empty($section)) { +if (!empty($section)) +{ $result = $ecmdir->fetch($section); - if (!$result > 0) { + if (!$result > 0) + { dol_print_error($db, $ecmdir->error); exit; } @@ -92,18 +87,18 @@ // Permissions $permtoadd = 0; $permtoupload = 0; -if ($module == 'ecm') { +if ($module == 'ecm') +{ $permtoadd = $user->rights->ecm->setup; $permtoupload = $user->rights->ecm->upload; } -if ($module == 'medias') { +if ($module == 'medias') +{ $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write); $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); } -if (!$permtoadd) { - accessforbidden(); -} +if (!$permtoadd) accessforbidden(); @@ -112,76 +107,94 @@ */ // Action ajout d'un produit ou service -if ($action == 'add' && $permtoadd) { - if ($cancel) { - if (!empty($backtopage)) { +if ($action == 'add' && $permtoadd) +{ + if ($cancel) + { + if (!empty($backtopage)) + { header("Location: ".$backtopage); exit; - } else { + } + else + { header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager'.($module ? '&module='.$module : '')); exit; } } - $ref = (string) GETPOST("ref", 'alpha'); - $label = (string) GETPOST("label", 'alpha'); - $desc = (string) GETPOST("desc", 'alpha'); + $ref = trim(GETPOST("ref", 'alpha')); + $label = trim(GETPOST("label", 'alpha')); + $desc = trim(GETPOST("desc", 'alpha')); $catParent = GETPOST("catParent", 'alpha'); // Can be an int (with ECM) or a string (with generic filemanager) - if ($catParent == '-1') { - $catParent = 0; - } + if ($catParent == '-1') $catParent = 0; $error = 0; - if (empty($label)) { + if (empty($label)) + { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); $action = 'create'; $error++; } - if (!$error) { - if ($module == 'ecm') { + if (!$error) + { + if ($module == 'ecm') + { $ecmdir->ref = $ref; $ecmdir->label = $label; $ecmdir->description = $desc; $ecmdir->fk_parent = (int) $catParent; $id = $ecmdir->create($user); - if ($id <= 0) { + if ($id <= 0) + { $error++; $langs->load("errors"); setEventMessages($ecmdir->error, $ecmdir->errors, 'errors'); $action = 'create'; } - } else // For example $module == 'medias' + } + else // For example $module == 'medias' { $dirfornewdir = ''; - if ($module == 'medias') { + if ($module == 'medias') + { $dirfornewdir = $conf->medias->multidir_output[$conf->entity]; } - if (empty($dirfornewdir)) { + if (empty($dirfornewdir)) + { $error++; dol_print_error('', 'Bad value for module. Not supported.'); } - if (!$error) { + if (!$error) + { $fullpathofdir = $dirfornewdir.'/'.($catParent ? $catParent.'/' : '').$label; $result = dol_mkdir($fullpathofdir, DOL_DATA_ROOT); - if ($result < 0) { + if ($result < 0) + { setEventMessages($langs->trans('ErrorFailToCreateDir', $label), null, 'errors'); $error++; - } else { + } + else + { setEventMessages($langs->trans("ECMSectionWasCreated", $label), null, 'mesgs'); } } } } - if (!$error) { - if (!empty($backtopage)) { + if (!$error) + { + if (!empty($backtopage)) + { header("Location: ".$backtopage); exit; - } else { + } + else + { header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager'); exit; } @@ -189,7 +202,8 @@ } // Deleting file -elseif ($action == 'confirm_deletesection' && $confirm == 'yes') { +elseif ($action == 'confirm_deletesection' && $confirm == 'yes') +{ $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); } @@ -206,7 +220,8 @@ $form = new Form($db); $formecm = new FormEcm($db); -if ($action == 'create') { +if ($action == 'create') +{ //*********************** // Create //*********************** @@ -215,17 +230,13 @@ print ''; print ''; print ''; - if ($website) { - print ''; - } - if ($pageid) { - print ''; - } + if ($website) print ''; + if ($pageid) print ''; $title = $langs->trans("ECMNewSection"); print load_fiche_titre($title); - print dol_get_fiche_head(); + dol_fiche_head(); print ''; @@ -237,7 +248,8 @@ print ''."\n"; // Description - if ($module == 'ecm') { + if ($module == 'ecm') + { print ''; print ''; } print ''; @@ -426,15 +443,14 @@ print ''; -print $object->showOptionals($extrafields, ($action == 'edit' ? 'edit' : 'view')); print '
'.$langs->trans("Description").''; print ''; - } else print dol_nl2br($ecmdir->description); + } + else print dol_nl2br($ecmdir->description); print '
'.$langs->trans("ECMCreationUser").''; - if ($ecmdir->fk_user_c > 0) { - $userecm = new User($db); - $userecm->fetch($ecmdir->fk_user_c); - print $userecm->getNomUrl(1); - } + $userecm = new User($db); + $userecm->fetch($ecmdir->fk_user_c); + print $userecm->getNomUrl(1); print '
'.$langs->trans("ECMCreationDate").''; if ($module == 'ecm') { print dol_print_date($ecmdir->date_c, 'dayhour'); -} else { +} +else +{ //var_dump($upload_dir); print dol_print_date(dol_filemtime($upload_dir), 'dayhour'); } @@ -407,7 +422,9 @@ if ($module == 'ecm') { print '/ecm/'.$relativepath; -} else { +} +else +{ print '/'.$module.'/'.$relativepath; } print '
'.$langs->trans("TotalSizeOfAttachedFiles").''; print dol_print_size($totalsize); print '
'; if ($action == 'edit') { print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; } @@ -444,7 +460,7 @@ print ''; } -print dol_get_fiche_end(); +dol_fiche_end(); @@ -461,7 +477,9 @@ if ($permtoadd) { print ''.$langs->trans('ECMAddSection').''; - } else { + } + else + { print ''.$langs->trans('ECMAddSection').''; } @@ -469,8 +487,10 @@ //{ if ($permtoadd) { - print ''.$langs->trans('Delete').''; - } else { + print ''.$langs->trans('Delete').''; + } + else + { print ''.$langs->trans('Delete').''; } /*} --- /tmp/dsg/dolibarr/htdocs/ecm/github_file_card.php +++ /tmp/dsg/dolibarr/htdocs/ecm/client_file_card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2017 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,6 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by page $langs->loadLangs(array('ecm', 'companies', 'other', 'users', 'orders', 'propal', 'bills', 'contracts', 'categories')); @@ -44,8 +43,8 @@ // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -62,14 +61,14 @@ $section = GETPOST("section", 'alpha'); if (!$section) { - dol_print_error('', 'Error, section parameter missing'); - exit; -} -$urlfile = (string) dol_sanitizePathName(GETPOST("urlfile")); + dol_print_error('', 'Error, section parameter missing'); + exit; +} +$urlfile = GETPOST("urlfile"); if (!$urlfile) { - dol_print_error('', "ErrorParamNotDefined"); - exit; + dol_print_error('', "ErrorParamNotDefined"); + exit; } // Load ecm object @@ -77,8 +76,8 @@ $result = $ecmdir->fetch(GETPOST("section", 'alpha')); if (!$result > 0) { - dol_print_error($db, $ecmdir->error); - exit; + dol_print_error($db, $ecmdir->error); + exit; } $relativepath = $ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; @@ -95,10 +94,6 @@ // Try to load object from index $object = new ECMFiles($db); -$extrafields = new ExtraFields($db); -// fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - $result = $object->fetch(0, '', $filepathtodocument); if ($result < 0) { @@ -114,94 +109,91 @@ if ($cancel) { - $action = ''; - if ($backtopage) - { - header("Location: ".$backtopage); - exit; - } else { - header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'§ion='.urlencode($section).($module ? '&module='.urlencode($module) : '')); - exit; - } + $action = ''; + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'§ion='.urlencode($section).($module ? '&module='.urlencode($module) : '')); + exit; + } } // Rename file if ($action == 'update') { - $error = 0; - - $oldlabel = GETPOST('urlfile', 'alpha'); - $newlabel = dol_sanitizeFileName(GETPOST('label', 'alpha')); + $error = 0; + + $oldlabel = GETPOST('urlfile', 'alpha'); + $newlabel = GETPOST('label', 'alpha'); $shareenabled = GETPOST('shareenabled', 'alpha'); - //$db->begin(); - - $olddir = $ecmdir->getRelativePath(0); // Relative to ecm - $olddirrelativetodocument = 'ecm/'.$olddir; // Relative to document - $newdirrelativetodocument = 'ecm/'.$olddir; - $olddir = $conf->ecm->dir_output.'/'.$olddir; - $newdir = $olddir; - - $oldfile = $olddir.$oldlabel; - $newfile = $newdir.$newlabel; - $newfileformove = $newfile; - // If old file end with .noexe, new file must also end with .noexe - if (preg_match('/\.noexe$/', $oldfile) && !preg_match('/\.noexe$/', $newfileformove)) { - $newfileformove .= '.noexe'; - } - //var_dump($oldfile);var_dump($newfile);exit; - - // Now we update index of file - $db->begin(); - //print $oldfile.' - '.$newfile; - if ($newlabel != $oldlabel) - { - $result = dol_move($oldfile, $newfileformove); // This include update of database - if (!$result) - { - $langs->load('errors'); - setEventMessages($langs->trans('ErrorFailToRenameFile', $oldfile, $newfile), null, 'errors'); - $error++; - } - - // Reload object after the move - $result = $object->fetch(0, '', $newdirrelativetodocument.$newlabel); - if ($result < 0) - { - dol_print_error($db, $object->error, $object->errors); - exit; - } - } - - if (!$error) - { + //$db->begin(); + + $olddir = $ecmdir->getRelativePath(0); // Relative to ecm + $olddirrelativetodocument = 'ecm/'.$olddir; // Relative to document + $newdirrelativetodocument = 'ecm/'.$olddir; + $olddir = $conf->ecm->dir_output.'/'.$olddir; + $newdir = $olddir; + + $oldfile = $olddir.$oldlabel; + $newfile = $newdir.$newlabel; + $newfileformove = $newfile; + // If old file end with .noexe, new file must also end with .noexe + if (preg_match('/\.noexe$/', $oldfile) && ! preg_match('/\.noexe$/', $newfileformove)) { + $newfileformove .= '.noexe'; + } + //var_dump($oldfile);var_dump($newfile);exit; + + // Now we update index of file + $db->begin(); + + //print $oldfile.' - '.$newfile; + if ($newlabel != $oldlabel) + { + $result = dol_move($oldfile, $newfileformove); // This include update of database + if (!$result) + { + $langs->load('errors'); + setEventMessages($langs->trans('ErrorFailToRenameFile', $oldfile, $newfile), null, 'errors'); + $error++; + } + + // Reload object after the move + $result = $object->fetch(0, '', $newdirrelativetodocument.$newlabel); + if ($result < 0) + { + dol_print_error($db, $object->error, $object->errors); + exit; + } + } + + if (!$error) + { if ($shareenabled) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $object->share = getRandomPassword(true); - } else { + } + else + { $object->share = ''; } if ($object->id > 0) { - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; - if (!$error) { - // Actions on extra fields - $result = $object->insertExtraFields(); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } // Call update to set the share key $result = $object->update($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'warnings'); } - } else { + } + else + { // Call create to insert record $object->entity = $conf->entity; $object->filepath = preg_replace('/[\\/]+$/', '', $newdirrelativetodocument); @@ -217,23 +209,25 @@ setEventMessages($object->error, $object->errors, 'warnings'); } } - } - - if (!$error) - { - $db->commit(); - - $urlfile = $newlabel; - // If old file end with .noexe, new file must also end with .noexe - if (preg_match('/\.noexe$/', $newfileformove)) { - $urlfile .= '.noexe'; - } - - header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'§ion='.urlencode($section)); - exit; - } else { - $db->rollback(); - } + } + + if (!$error) + { + $db->commit(); + + $urlfile = $newlabel; + // If old file end with .noexe, new file must also end with .noexe + if (preg_match('/\.noexe$/', $newfileformove)) { + $urlfile .= '.noexe'; + } + + header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'§ion='.urlencode($section)); + exit; + } + else + { + $db->rollback(); + } } @@ -259,7 +253,7 @@ print ''; } -print dol_get_fiche_head($head, 'card', $langs->trans("File"), -1, 'generic'); +dol_fiche_head($head, 'card', $langs->trans("File"), -1, 'generic'); $s = ''; @@ -275,7 +269,9 @@ { $s = ' -> '.$s; $result = $tmpecmdir->fetch($tmpecmdir->fk_parent); - } else { + } + else + { $tmpecmdir = 0; } $i++; @@ -298,7 +294,7 @@ print '
'; print '
'; -print ''; +print '
'; print ''; @@ -320,7 +316,9 @@ if (!empty($object->label)) { print $object->label; -} else { +} +else +{ print img_warning().' '.$langs->trans("FileNotYetIndexedInDatabase"); } print ''; @@ -368,44 +366,49 @@ if ($action != 'edit') print ''; else print $fulllink; if ($action != 'edit') print ' '.$langs->trans("Download").''; // No target here - } else { + } + else + { print 'share ? ' checked="checked"' : '').' /> '; } -} else { +} +else +{ if ($action != 'edit') { print ''.$langs->trans("FileNotShared").''; - } else { + } + else + { print 'share ? ' checked="checked"' : '').' /> '; } } -print ''; -print ''; -print $object->showOptionals($extrafields, ($action == 'edit' ? 'edit' : 'view')); +print ''; + print '
'.$langs->trans("ECMCreationDate").''; print dol_print_date(dol_filemtime($fullpath), 'dayhour'); print '
'; print '
'; print ajax_autoselect('downloadinternallink'); print ajax_autoselect('downloadlink'); -print dol_get_fiche_end(); +dol_fiche_end(); if ($action == 'edit') { - print '
'; - print ''; - print '     '; - print ''; - print '
'; - - print ''; + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print ''; } // Confirmation de la suppression d'une ligne categorie if ($action == 'delete_file') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.urlencode($section), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile', $urlfile), 'confirm_deletefile', '', 1, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.urlencode($section), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile', $urlfile), 'confirm_deletefile', '', 1, 1); } if ($action != 'edit') @@ -413,14 +416,14 @@ // Actions buttons print '
'; + if ($user->rights->ecm->setup) + { + print ''.$langs->trans('Edit').''; + } + /* if ($user->rights->ecm->setup) { - print ''.$langs->trans('Edit').''; - } - /* - if ($user->rights->ecm->setup) - { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } else { --- /tmp/dsg/dolibarr/htdocs/ecm/github_index.php +++ /tmp/dsg/dolibarr/htdocs/ecm/client_index.php @@ -83,10 +83,10 @@ //include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; // Upload file (code similar but different than actions_linkedfiles.inc.php) -if (GETPOST("sendit", 'alphanohtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST("sendit", 'none') && !empty($conf->global->MAIN_UPLOAD_DOC)) { // Define relativepath and upload_dir - $relativepath = ''; + $relativepath = ''; if ($ecmdir->id) $relativepath = $ecmdir->getRelativePath(); else $relativepath = $section_dir; $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; @@ -101,7 +101,8 @@ $error++; if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); - } else { + } + else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); } } @@ -111,10 +112,10 @@ { $generatethumbs = 0; $res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', null, '', $generatethumbs); - if ($res > 0) - { - $result = $ecmdir->changeNbOfFiles('+'); - } + if ($res > 0) + { + $result = $ecmdir->changeNbOfFiles('+'); + } } } @@ -127,6 +128,7 @@ $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : ''); $file = $upload_dir."/".GETPOST('urlfile', 'alpha'); + $ret = dol_delete_file($file); // This include also the delete from file index in database. if ($ret) { @@ -134,7 +136,9 @@ $urlfiletoshow = preg_replace('/\.noexe$/', '', $urlfiletoshow); setEventMessages($langs->trans("FileWasRemoved", $urlfiletoshow), null, 'mesgs'); $result = $ecmdir->changeNbOfFiles('-'); - } else { + } + else + { setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile', 'alpha')), null, 'errors'); } @@ -155,7 +159,9 @@ { header("Location: ".$_SERVER["PHP_SELF"]); exit; - } else { + } + else + { setEventMessages('Error '.$langs->trans($ecmdir->error), null, 'errors'); $action = "create"; } @@ -169,7 +175,7 @@ $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); - clearstatcache(); + clearstatcache(); } // Refresh directory view @@ -177,130 +183,137 @@ // To refresh content of dir with cache, just open the dir in edit mode. if ($action == 'refreshmanual') { - $ecmdirtmp = new EcmDirectory($db); + $ecmdirtmp = new EcmDirectory($db); // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate clearstatcache(); - $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output); - $diroutputslash .= '/'; - - // Scan directory tree on disk - $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); - - // Scan directory tree in database - $sqltree = $ecmdirstatic->get_full_arbo(0); - - $adirwascreated = 0; - - // Now we compare both trees to complete missing trees into database - //var_dump($disktree); - //var_dump($sqltree); - foreach ($disktree as $dirdesc) // Loop on tree onto disk - { - $dirisindatabase = 0; - foreach ($sqltree as $dirsqldesc) - { - if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) - { - $dirisindatabase = 1; - break; - } - } - - if (!$dirisindatabase) - { - $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; - dol_syslog($txt); - //print $txt."
\n"; - - // We must first find the fk_parent of directory to create $dirdesc['fullname'] - $fk_parent = -1; - $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); - $relativepathtosearchparent = $relativepathmissing; - //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); - if (preg_match('/\//', $relativepathtosearchparent)) - //while (preg_match('/\//',$relativepathtosearchparent)) - { - $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); - $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; - dol_syslog($txt); - //print $txt." -> "; - $parentdirisindatabase = 0; - foreach ($sqltree as $dirsqldesc) + $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output); + $diroutputslash .= '/'; + + // Scan directory tree on disk + $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); + + // Scan directory tree in database + $sqltree = $ecmdirstatic->get_full_arbo(0); + + $adirwascreated = 0; + + // Now we compare both trees to complete missing trees into database + //var_dump($disktree); + //var_dump($sqltree); + foreach ($disktree as $dirdesc) // Loop on tree onto disk + { + $dirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) + { + if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) + { + $dirisindatabase = 1; + break; + } + } + + if (!$dirisindatabase) + { + $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; + dol_syslog($txt); + //print $txt."
\n"; + + // We must first find the fk_parent of directory to create $dirdesc['fullname'] + $fk_parent = -1; + $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); + $relativepathtosearchparent = $relativepathmissing; + //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); + if (preg_match('/\//', $relativepathtosearchparent)) + //while (preg_match('/\//',$relativepathtosearchparent)) + { + $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); + $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; + dol_syslog($txt); + //print $txt." -> "; + $parentdirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) + { + if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) + { + $parentdirisindatabase = $dirsqldesc['id']; + break; + } + } + if ($parentdirisindatabase > 0) + { + dol_syslog("Yes with id ".$parentdirisindatabase); + //print "Yes with id ".$parentdirisindatabase."
\n"; + $fk_parent = $parentdirisindatabase; + //break; // We found parent, we can stop the while loop + } + else { - if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) - { - $parentdirisindatabase = $dirsqldesc['id']; - break; - } - } - if ($parentdirisindatabase > 0) - { - dol_syslog("Yes with id ".$parentdirisindatabase); - //print "Yes with id ".$parentdirisindatabase."
\n"; - $fk_parent = $parentdirisindatabase; - //break; // We found parent, we can stop the while loop - } else { - dol_syslog("No"); - //print "No
\n"; - } - } else { - dol_syslog("Parent is root"); - $fk_parent = 0; // Parent is root - } - - if ($fk_parent >= 0) - { - $ecmdirtmp->ref = 'NOTUSEDYET'; - $ecmdirtmp->label = dol_basename($dirdesc['fullname']); - $ecmdirtmp->description = ''; - $ecmdirtmp->fk_parent = $fk_parent; - - $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; - dol_syslog($txt); - //print $ecmdirtmp->cachenbofdoc."
\n";exit; - $id = $ecmdirtmp->create($user); - if ($id > 0) - { - $newdirsql = array('id'=>$id, - 'id_mere'=>$ecmdirtmp->fk_parent, - 'label'=>$ecmdirtmp->label, - 'description'=>$ecmdirtmp->description, - 'fullrelativename'=>$relativepathmissing); - $sqltree[] = $newdirsql; // We complete fulltree for following loops - //var_dump($sqltree); - $adirwascreated = 1; - } else { - dol_syslog("Failed to create directory ".$ecmdirtmp->label, LOG_ERR); - } - } else { - $txt = "Parent of ".$dirdesc['fullname']." not found"; - dol_syslog($txt); - //print $txt."
\n"; - } - } - } - - // Loop now on each sql tree to check if dir exists - foreach ($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk - { - $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; + dol_syslog("No"); + //print "No
\n"; + } + } + else + { + dol_syslog("Parent is root"); + $fk_parent = 0; // Parent is root + } + + if ($fk_parent >= 0) + { + $ecmdirtmp->ref = 'NOTUSEDYET'; + $ecmdirtmp->label = dol_basename($dirdesc['fullname']); + $ecmdirtmp->description = ''; + $ecmdirtmp->fk_parent = $fk_parent; + + $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; + dol_syslog($txt); + //print $ecmdirtmp->cachenbofdoc."
\n";exit; + $id = $ecmdirtmp->create($user); + if ($id > 0) + { + $newdirsql = array('id'=>$id, + 'id_mere'=>$ecmdirtmp->fk_parent, + 'label'=>$ecmdirtmp->label, + 'description'=>$ecmdirtmp->description, + 'fullrelativename'=>$relativepathmissing); + $sqltree[] = $newdirsql; // We complete fulltree for following loops + //var_dump($sqltree); + $adirwascreated = 1; + } + else + { + dol_syslog("Failed to create directory ".$ecmdirtmp->label, LOG_ERR); + } + } + else { + $txt = "Parent of ".$dirdesc['fullname']." not found"; + dol_syslog($txt); + //print $txt."
\n"; + } + } + } + + // Loop now on each sql tree to check if dir exists + foreach ($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk + { + $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; if (!dol_is_dir($dirtotest)) { $ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->delete($user, 'databaseonly'); //exit; } - } - - $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" - dol_syslog("sql = ".$sql); - $db->query($sql); - - // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean - // it to be sure that fulltree array is not used without reloading it. - if ($adirwascreated) $sqltree = null; + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" + dol_syslog("sql = ".$sql); + $db->query($sql); + + // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean + // it to be sure that fulltree array is not used without reloading it. + if ($adirwascreated) $sqltree = null; } @@ -327,7 +340,7 @@ llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0); $head = ecm_prepare_dasboard_head(''); -print dol_get_fiche_head($head, 'index', $langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"), -1, ''); +dol_fiche_head($head, 'index', $langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"), -1, ''); // Add filemanager component @@ -335,7 +348,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php'; // End of page -print dol_get_fiche_end(); +dol_fiche_end(); llxFooter(); --- /tmp/dsg/dolibarr/htdocs/ecm/github_index_auto.php +++ /tmp/dsg/dolibarr/htdocs/ecm/client_index_auto.php @@ -102,7 +102,9 @@ { header("Location: ".$_SERVER["PHP_SELF"]); exit; - } else { + } + else + { setEventMessages('Error '.$langs->trans($ecmdir->error), null, 'errors'); $action = "create"; } @@ -113,30 +115,31 @@ // Remove file if ($action == 'confirm_deletefile') { - if (GETPOST('confirm') == 'yes') - { - $langs->load("other"); - if ($section) - { - $result = $ecmdir->fetch($section); - if (!($result > 0)) - { - dol_print_error($db, $ecmdir->error); - exit; - } - $relativepath = $ecmdir->getRelativePath(); - } else $relativepath = ''; - $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : ''); - $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP). - - $ret = dol_delete_file($file); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - - $result = $ecmdir->changeNbOfFiles('-'); - - clearstatcache(); - } + if (GETPOST('confirm') == 'yes') + { + $langs->load("other"); + if ($section) + { + $result = $ecmdir->fetch($section); + if (!($result > 0)) + { + dol_print_error($db, $ecmdir->error); + exit; + } + $relativepath = $ecmdir->getRelativePath(); + } + else $relativepath = ''; + $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : ''); + $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP). + + $ret = dol_delete_file($file); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + + $result = $ecmdir->changeNbOfFiles('-'); + + clearstatcache(); + } $action = 'file_manager'; } @@ -146,7 +149,7 @@ $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); - clearstatcache(); + clearstatcache(); } // Refresh directory view @@ -154,130 +157,137 @@ // To refresh content of dir with cache, just open the dir in edit mode. if ($action == 'refreshmanual') { - $ecmdirtmp = new EcmDirectory($db); + $ecmdirtmp = new EcmDirectory($db); // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate clearstatcache(); - $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output); - $diroutputslash .= '/'; - - // Scan directory tree on disk - $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); - - // Scan directory tree in database - $sqltree = $ecmdirstatic->get_full_arbo(0); - - $adirwascreated = 0; - - // Now we compare both trees to complete missing trees into database - //var_dump($disktree); - //var_dump($sqltree); - foreach ($disktree as $dirdesc) // Loop on tree onto disk - { - $dirisindatabase = 0; - foreach ($sqltree as $dirsqldesc) - { - if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) - { - $dirisindatabase = 1; - break; - } - } - - if (!$dirisindatabase) - { - $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; - dol_syslog($txt); - //print $txt."
\n"; - - // We must first find the fk_parent of directory to create $dirdesc['fullname'] - $fk_parent = -1; - $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); - $relativepathtosearchparent = $relativepathmissing; - //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); - if (preg_match('/\//', $relativepathtosearchparent)) - //while (preg_match('/\//',$relativepathtosearchparent)) - { - $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); - $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; - dol_syslog($txt); - //print $txt." -> "; - $parentdirisindatabase = 0; - foreach ($sqltree as $dirsqldesc) + $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output); + $diroutputslash .= '/'; + + // Scan directory tree on disk + $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); + + // Scan directory tree in database + $sqltree = $ecmdirstatic->get_full_arbo(0); + + $adirwascreated = 0; + + // Now we compare both trees to complete missing trees into database + //var_dump($disktree); + //var_dump($sqltree); + foreach ($disktree as $dirdesc) // Loop on tree onto disk + { + $dirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) + { + if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) + { + $dirisindatabase = 1; + break; + } + } + + if (!$dirisindatabase) + { + $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; + dol_syslog($txt); + //print $txt."
\n"; + + // We must first find the fk_parent of directory to create $dirdesc['fullname'] + $fk_parent = -1; + $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); + $relativepathtosearchparent = $relativepathmissing; + //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); + if (preg_match('/\//', $relativepathtosearchparent)) + //while (preg_match('/\//',$relativepathtosearchparent)) + { + $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); + $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; + dol_syslog($txt); + //print $txt." -> "; + $parentdirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) + { + if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) + { + $parentdirisindatabase = $dirsqldesc['id']; + break; + } + } + if ($parentdirisindatabase > 0) + { + dol_syslog("Yes with id ".$parentdirisindatabase); + //print "Yes with id ".$parentdirisindatabase."
\n"; + $fk_parent = $parentdirisindatabase; + //break; // We found parent, we can stop the while loop + } + else { - if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) - { - $parentdirisindatabase = $dirsqldesc['id']; - break; - } - } - if ($parentdirisindatabase > 0) - { - dol_syslog("Yes with id ".$parentdirisindatabase); - //print "Yes with id ".$parentdirisindatabase."
\n"; - $fk_parent = $parentdirisindatabase; - //break; // We found parent, we can stop the while loop - } else { - dol_syslog("No"); - //print "No
\n"; - } - } else { - dol_syslog("Parent is root"); - $fk_parent = 0; // Parent is root - } - - if ($fk_parent >= 0) - { - $ecmdirtmp->ref = 'NOTUSEDYET'; - $ecmdirtmp->label = dol_basename($dirdesc['fullname']); - $ecmdirtmp->description = ''; - $ecmdirtmp->fk_parent = $fk_parent; - - $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; - dol_syslog($txt); - //print $ecmdirtmp->cachenbofdoc."
\n";exit; - $id = $ecmdirtmp->create($user); - if ($id > 0) - { - $newdirsql = array('id'=>$id, - 'id_mere'=>$ecmdirtmp->fk_parent, - 'label'=>$ecmdirtmp->label, - 'description'=>$ecmdirtmp->description, - 'fullrelativename'=>$relativepathmissing); - $sqltree[] = $newdirsql; // We complete fulltree for following loops - //var_dump($sqltree); - $adirwascreated = 1; - } else { - dol_syslog("Failed to create directory ".$ecmdirtmp->label, LOG_ERR); - } - } else { - $txt = "Parent of ".$dirdesc['fullname']." not found"; - dol_syslog($txt); - //print $txt."
\n"; - } - } - } - - // Loop now on each sql tree to check if dir exists - foreach ($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk - { - $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; + dol_syslog("No"); + //print "No
\n"; + } + } + else + { + dol_syslog("Parent is root"); + $fk_parent = 0; // Parent is root + } + + if ($fk_parent >= 0) + { + $ecmdirtmp->ref = 'NOTUSEDYET'; + $ecmdirtmp->label = dol_basename($dirdesc['fullname']); + $ecmdirtmp->description = ''; + $ecmdirtmp->fk_parent = $fk_parent; + + $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; + dol_syslog($txt); + //print $ecmdirtmp->cachenbofdoc."
\n";exit; + $id = $ecmdirtmp->create($user); + if ($id > 0) + { + $newdirsql = array('id'=>$id, + 'id_mere'=>$ecmdirtmp->fk_parent, + 'label'=>$ecmdirtmp->label, + 'description'=>$ecmdirtmp->description, + 'fullrelativename'=>$relativepathmissing); + $sqltree[] = $newdirsql; // We complete fulltree for following loops + //var_dump($sqltree); + $adirwascreated = 1; + } + else + { + dol_syslog("Failed to create directory ".$ecmdirtmp->label, LOG_ERR); + } + } + else { + $txt = "Parent of ".$dirdesc['fullname']." not found"; + dol_syslog($txt); + //print $txt."
\n"; + } + } + } + + // Loop now on each sql tree to check if dir exists + foreach ($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk + { + $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; if (!dol_is_dir($dirtotest)) { $ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->delete($user, 'databaseonly'); //exit; } - } - - $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" - dol_syslog("sql = ".$sql); - $db->query($sql); - - // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean - // it to be sure that fulltree array is not used without reloading it. - if ($adirwascreated) $sqltree = null; + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" + dol_syslog("sql = ".$sql); + $db->query($sql); + + // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean + // it to be sure that fulltree array is not used without reloading it. + if ($adirwascreated) $sqltree = null; } @@ -310,27 +320,25 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } - if (!empty($conf->societe->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); } - if (!empty($conf->propal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); } - if (!empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); } - if (!empty($conf->commande->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); } - if (!empty($conf->facture->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); } - if (!empty($conf->supplier_proposal->enabled)) { $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } - if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); } - if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } - if (!empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); } - if (!empty($conf->projet->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); } - if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); } - if (!empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); } - if (!empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); } - if (!empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); } - if (!empty($conf->mrp->enabled)) { $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); } - if (!empty($conf->recruitment->enabled)) { $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); } - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users"))); + if (!empty($conf->societe->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); } + if (!empty($conf->propal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals")); } + if (!empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); } + if (!empty($conf->commande->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } + if (!empty($conf->facture->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } + if (!empty($conf->supplier_proposal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBySupplierProposals")); } + if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } + if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } + if (!empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBySocialContributions")); } + if (!empty($conf->projet->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsByProjects")); } + if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsByInterventions")); } + if (!empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsByExpenseReports")); } + if (!empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsByHolidays")); } + if (!empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsByBankAccount")); } + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsByUsers")); } $head = ecm_prepare_dasboard_head(''); -print dol_get_fiche_head($head, 'index_auto', $langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"), -1, ''); +dol_fiche_head($head, 'index_auto', $langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"), -1, ''); @@ -352,7 +360,7 @@ // Toolbar $url = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&module='.$module : '').($section ? '&section='.$section : ''))); -print ''; +print ''; print ''; print ''; @@ -369,7 +377,7 @@ // Confirmation de la suppression d'une ligne categorie if ($action == 'delete_section') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1); } // End confirm @@ -380,12 +388,12 @@ print ''."\n"; print ''."\n"; - print ''; - print ' '.$langs->trans("ECMSections"); + print ''; + print ' '.$langs->trans("ECMSections"); print ''; - $showonrightsize = ''; - // Auto section + $showonrightsize = ''; + // Auto section if (count($sectionauto)) { $htmltooltip = $langs->trans("ECMAreaDesc2"); @@ -393,8 +401,8 @@ $sectionauto = dol_sort_array($sectionauto, 'label', 'ASC', true, false); print ''; - print ''; - print '
    '; + print ''; + print '
      '; $nbofentries = 0; $oldvallevel = 0; @@ -404,32 +412,34 @@ $var = false; - print ''; - - $nbofentries++; + else + { + print ''; + print $val['label']; + print ''; + } + + print '
      '; + // Info + $htmltooltip = ''.$langs->trans("ECMSection").': '.$val['label'].'
      '; + $htmltooltip = ''.$langs->trans("Type").': '.$langs->trans("ECMSectionAuto").'
      '; + $htmltooltip .= ''.$langs->trans("ECMCreationUser").': '.$langs->trans("ECMTypeAuto").'
      '; + $htmltooltip .= ''.$langs->trans("Description").': '.$val['desc']; + print $form->textwithpicto('', $htmltooltip, 1, 'info'); + print '
      '; + print ''; + + $nbofentries++; } - print '
    '; + print '
'; } print ""; @@ -466,7 +476,7 @@ } -print dol_get_fiche_end(); +dol_fiche_end(); llxFooter(); --- /tmp/dsg/dolibarr/htdocs/ecm/github_search.php +++ /tmp/dsg/dolibarr/htdocs/ecm/client_search.php @@ -41,7 +41,7 @@ // Get parameters $socid = GETPOST('socid', 'int'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $section = GETPOST('section'); if (!$section) $section = 0; @@ -97,23 +97,14 @@ // Ajout rubriques automatiques $rowspan = 0; $sectionauto = array(); -if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } -if (!empty($conf->societe->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); } -if (!empty($conf->propal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); } -if (!empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); } -if (!empty($conf->commande->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); } -if (!empty($conf->facture->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); } -if (!empty($conf->supplier_proposal->enabled)) { $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } -if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); } -if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } -if (!empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); } -if (!empty($conf->projet->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); } -if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); } -if (!empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); } -if (!empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); } -if (!empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); } -if (!empty($conf->mrp->enabled)) { $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); } -if (!empty($conf->recruitment->enabled)) { $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); } +if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>$conf->product->enabled, 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } +if (!empty($conf->societe->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); } +if (!empty($conf->propal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals")); } +if (!empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); } +if (!empty($conf->commande->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +if (!empty($conf->facture->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } +if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } //*********************** @@ -128,7 +119,7 @@ // Tool bar $head = ecm_prepare_head_fm($ecmdir, $module, $section); -//print dol_get_fiche_head($head, 'search_form', '', 1); +//dol_fiche_head($head, 'search_form', '', 1); print '
';