23 if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL',
'1');
24 if (!defined(
'NOREQUIREMENU')) define(
'NOREQUIREMENU',
'1');
25 if (!defined(
'NOREQUIREAJAX')) define(
'NOREQUIREAJAX',
'1');
26 if (!defined(
'NOREQUIRESOC')) define(
'NOREQUIRESOC',
'1');
28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31 $action =
GETPOST(
'action',
'aZ09');
32 $element =
GETPOST(
'element',
'alpha');
43 if (isset($action) && !empty($action))
47 if ($action ==
'build' && !empty($element))
49 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
57 $diroutputslash = str_replace(
'\\',
'/', $conf->$element->dir_output);
58 $diroutputslash .=
'/';
61 $disktree =
dol_dir_list($conf->$element->dir_output,
'directories', 1,
'', array(
'^temp$'),
'',
'', 0);
64 $sqltree = $ecmdirstatic->get_full_arbo(0);
71 foreach ($disktree as $dirdesc)
76 foreach ($sqltree as $dirsqldesc)
78 if ($conf->$element->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname'])
85 if (!$dirisindatabase)
87 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
92 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
93 $relativepathtosearchparent = $relativepathmissing;
95 if (preg_match(
'/\//', $relativepathtosearchparent))
98 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
99 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
102 $parentdirisindatabase = 0;
103 foreach ($sqltree as $dirsqldesc)
105 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent)
107 $parentdirisindatabase = $dirsqldesc[
'id'];
111 if ($parentdirisindatabase > 0)
113 dol_syslog(
"Yes with id ".$parentdirisindatabase);
115 $fk_parent = $parentdirisindatabase;
128 $ecmdirtmp->ref =
'NOTUSEDYET';
130 $ecmdirtmp->description =
'';
131 $ecmdirtmp->fk_parent = $fk_parent;
133 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
136 $id = $ecmdirtmp->create($user);
139 $newdirsql = array(
'id'=>$id,
140 'id_mere'=>$ecmdirtmp->fk_parent,
141 'label'=>$ecmdirtmp->label,
142 'description'=>$ecmdirtmp->description,
143 'fullrelativename'=>$relativepathmissing);
144 $sqltree[] = $newdirsql;
148 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
151 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
159 foreach ($sqltree as $dirdesc)
161 $dirtotest = $conf->$element->dir_output.
'/'.$dirdesc[
'fullrelativename'];
164 $mesg .= $dirtotest.
" not found onto disk. We delete from database dir with id=".$dirdesc[
'id'].
"<br>\n";
165 $ecmdirtmp->id = $dirdesc[
'id'];
166 $ecmdirtmp->delete($user,
'databaseonly');
171 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_is_dir($folder)
Test if filename is a directory.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype= 'text/html', $forcenocache=0)
Show HTTP header.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_basename($pathfile)
Make a basename working with all page code (default PHP basenamed fails with cyrillic).
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Class to manage ECM directories.