23if (!defined(
'NOTOKENRENEWAL')) {
24 define(
'NOTOKENRENEWAL',
'1');
26if (!defined(
'NOREQUIREMENU')) {
27 define(
'NOREQUIREMENU',
'1');
29if (!defined(
'NOREQUIREAJAX')) {
30 define(
'NOREQUIREAJAX',
'1');
32if (!defined(
'NOREQUIRESOC')) {
33 define(
'NOREQUIRESOC',
'1');
37require
'../../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
40$action =
GETPOST(
'action',
'aZ09');
41$element =
GETPOST(
'element',
'alpha');
53if (isset($action) && !empty($action)) {
56 if ($action ==
'build' && !empty($element)) {
57 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
65 $diroutputslash = str_replace(
'\\',
'/', $conf->$element->dir_output);
66 $diroutputslash .=
'/';
69 $disktree =
dol_dir_list($conf->$element->dir_output,
'directories', 1,
'', array(
'^temp$'),
'',
'', 0);
72 $sqltree = $ecmdirstatic->get_full_arbo(0);
79 foreach ($disktree as $dirdesc) {
83 foreach ($sqltree as $dirsqldesc) {
84 if ($conf->$element->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
90 if (!$dirisindatabase) {
91 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into table ecm_directories, so we add it";
96 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
97 $relativepathtosearchparent = $relativepathmissing;
99 if (preg_match(
'/\//', $relativepathtosearchparent)) {
101 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
102 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
105 $parentdirisindatabase = 0;
106 foreach ($sqltree as $dirsqldesc) {
107 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
108 $parentdirisindatabase = $dirsqldesc[
'id'];
112 if ($parentdirisindatabase > 0) {
113 dol_syslog(
"Yes with id ".$parentdirisindatabase);
115 $fk_parent = $parentdirisindatabase;
126 if ($fk_parent >= 0) {
127 $ecmdirtmp->ref =
'NOTUSEDYET';
129 $ecmdirtmp->description =
'';
130 $ecmdirtmp->fk_parent = $fk_parent;
132 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
135 $id = $ecmdirtmp->create($user);
137 $newdirsql = array(
'id'=>$id,
138 'id_mere'=>$ecmdirtmp->fk_parent,
139 'label'=>$ecmdirtmp->label,
140 'description'=>$ecmdirtmp->description,
141 'fullrelativename'=>$relativepathmissing);
142 $sqltree[] = $newdirsql;
146 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
149 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
157 foreach ($sqltree as $dirdesc) {
158 $dirtotest = $conf->$element->dir_output.
'/'.$dirdesc[
'fullrelativename'];
160 dol_syslog($dirtotest.
" not found onto disk. We delete from database dir with id=".$dirdesc[
'id']);
161 $ecmdirtmp->id = $dirdesc[
'id'];
162 $ecmdirtmp->delete($user,
'databaseonly');
167 dol_syslog(
"Nb of directories added into database = ".$adirwascreated);
169 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
Class to manage ECM directories.
dol_basename($pathfile)
Make a basename working with all page code (default PHP basenamed fails with cyrillic).
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_is_dir($folder)
Test if filename is a directory.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.