24if (!defined(
'NOTOKENRENEWAL')) {
25 define(
'NOTOKENRENEWAL',
'1');
27if (!defined(
'NOREQUIREMENU')) {
28 define(
'NOREQUIREMENU',
'1');
30if (!defined(
'NOREQUIREAJAX')) {
31 define(
'NOREQUIREAJAX',
'1');
33if (!defined(
'NOREQUIRESOC')) {
34 define(
'NOREQUIRESOC',
'1');
38require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
48$action =
GETPOST(
'action',
'aZ09');
49$element =
GETPOST(
'element',
'alpha');
51$permissiontoread = $user->hasRight(
'ecm',
'read');
70if (isset($action) && !empty($action)) {
73 if ($action ==
'build' && !empty($element) && $permissiontoread) {
74 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
82 $diroutputslash = str_replace(
'\\',
'/',
$conf->$element->dir_output);
83 $diroutputslash .=
'/';
86 $disktree =
dol_dir_list(
$conf->$element->dir_output,
'directories', 1,
'', array(
'^temp$'),
'', 0, 0);
89 $sqltree = $ecmdirstatic->get_full_arbo(0);
96 foreach ($disktree as $dirdesc) {
100 foreach ($sqltree as $dirsqldesc) {
101 if (
$conf->$element->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
102 $dirisindatabase = 1;
107 if (!$dirisindatabase) {
108 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into table ecm_directories, so we add it";
113 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
114 $relativepathtosearchparent = $relativepathmissing;
116 if (preg_match(
'/\//', $relativepathtosearchparent)) {
118 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
119 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
122 $parentdirisindatabase = 0;
123 foreach ($sqltree as $dirsqldesc) {
124 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
125 $parentdirisindatabase = $dirsqldesc[
'id'];
129 if ($parentdirisindatabase > 0) {
130 dol_syslog(
"Yes with id ".$parentdirisindatabase);
132 $fk_parent = $parentdirisindatabase;
143 if ($fk_parent >= 0) {
144 $ecmdirtmp->ref =
'NOTUSEDYET';
146 $ecmdirtmp->description =
'';
147 $ecmdirtmp->fk_parent = $fk_parent;
149 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
152 $id = $ecmdirtmp->create($user);
154 $newdirsql = array(
'id'=>
$id,
155 'id_mere'=>$ecmdirtmp->fk_parent,
156 'label'=>$ecmdirtmp->label,
157 'description'=>$ecmdirtmp->description,
158 'fullrelativename'=>$relativepathmissing);
159 $sqltree[] = $newdirsql;
163 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
166 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
174 foreach ($sqltree as $dirdesc) {
175 $dirtotest =
$conf->$element->dir_output.
'/'.$dirdesc[
'fullrelativename'];
177 dol_syslog($dirtotest.
" not found onto disk. We delete from database dir with id=".$dirdesc[
'id']);
178 $ecmdirtmp->id = $dirdesc[
'id'];
179 $ecmdirtmp->delete($user,
'databaseonly');
184 dol_syslog(
"Nb of directories added into database = ".$adirwascreated);
186 $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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...