diff --git a/htdocs/ecm/ajax/ecmdatabase.php b/htdocs/ecm/ajax/ecmdatabase.php
new file mode 100644
index 00000000000..a0d7e8b351b
--- /dev/null
+++ b/htdocs/ecm/ajax/ecmdatabase.php
@@ -0,0 +1,170 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/ecm/ajax/ecmdatabases.php
+ * \brief File to build ecm database
+ */
+
+if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
+if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
+if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
+if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
+
+require '../../main.inc.php';
+require DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
+
+$action = GETPOST('action','alpha');
+
+/*
+ * View
+ */
+
+top_httphead();
+
+//print ''."\n";
+
+// Load original field value
+if (isset($action) && ! empty($action))
+{
+ $error=0;
+
+ if ($action == 'build')
+ {
+ require DOL_DOCUMENT_ROOT . '/ecm/class/ecmdirectory.class.php';
+
+ $ecmdirstatic = new EcmDirectory($db);
+
+ clearstatcache();
+
+ $diroutputslash=str_replace('\\', '/', $conf->ecm->dir_output);
+ $diroutputslash.='/';
+
+ // Scan directory tree on disk
+ $disktree=dol_dir_list($conf->ecm->dir_output,'directories',1,'',array('^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
+ {
+ set_time_limit(0); // To force restarts the timeout counter from zero
+
+ $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);
+
+ // 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
+ {
+ dol_syslog("No");
+ //print "No
\n";
+ }
+ }
+ else
+ {
+ dol_syslog("Parent is root");
+ $fk_parent=0; // Parent is root
+ }
+
+ if ($fk_parent >= 0)
+ {
+ $ecmdirtmp=new EcmDirectory($db);
+ $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 $txt."
\n";
+ $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";
+ }
+ }
+ }
+
+ $sql="UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown"
+ $db->query($sql);
+ }
+}
+
+?>
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index 17b00274582..c15fc75023c 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -24,6 +24,7 @@
*/
if (! defined('REQUIRE_JQUERY_LAYOUT')) define('REQUIRE_JQUERY_LAYOUT','1');
+if (! defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1);
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
@@ -430,8 +431,9 @@ else
print '
';
print '';
}
-print '';
-print '
';
+$url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'§ion='.$section:'')));
+print '';
+print '
';
print '';
print '';
@@ -565,57 +567,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
print '
| ';
// Show filemanager tree
- print ' ';
-
- print ' ';
-
- $openeddir='/';
- ?>
-
-
- ';
if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile');
@@ -815,7 +767,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
// To attach new file
-if (empty($conf->global->MAIN_ECM_DISABLE_JS) || ! empty($section))
+if ((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || ! empty($section))
{
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/index.php', 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48);
@@ -832,6 +784,9 @@ else print ' ';
use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
+ include 'tpl/builddatabase.tpl.php';
+}
llxFooter();
diff --git a/htdocs/ecm/tpl/builddatabase.tpl.php b/htdocs/ecm/tpl/builddatabase.tpl.php
new file mode 100644
index 00000000000..76b5d9e2d42
--- /dev/null
+++ b/htdocs/ecm/tpl/builddatabase.tpl.php
@@ -0,0 +1,78 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+$openeddir='/';
+
+?>
+
+
+
+
\ No newline at end of file
|