27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
35 $langs->loadLangs(array(
"ecm",
"companies",
"other",
"users",
"orders",
"propal",
"bills",
"contracts"));
38 if ($user->societe_id) $socid=$user->societe_id;
43 $action=
GETPOST(
'action',
'aZ09');
45 if (! $section) $section=0;
46 $section_dir=
GETPOST(
'section_dir',
'alpha');
48 $sortfield =
GETPOST(
"sortfield",
'alpha');
49 $sortorder =
GETPOST(
"sortorder",
'alpha');
51 if (empty($page) || $page == -1) { $page = 0; }
52 $offset = $conf->liste_limit * $page;
53 $pageprev = $page - 1;
54 $pagenext = $page + 1;
55 if (! $sortorder) $sortorder=
"ASC";
56 if (! $sortfield) $sortfield=
"fullname";
61 $result=$ecmdir->fetch($section);
71 $userstatic =
new User($db);
85 if (
GETPOST(
"sendit",
'none') && ! empty($conf->global->MAIN_UPLOAD_DOC))
89 if ($ecmdir->id) $relativepath=$ecmdir->getRelativePath();
90 else $relativepath=$section_dir;
91 $upload_dir = $conf->ecm->dir_output.
'/'.$relativepath;
93 if (is_array($_FILES[
'userfile'][
'tmp_name'])) $userfiles=$_FILES[
'userfile'][
'tmp_name'];
94 else $userfiles=array($_FILES[
'userfile'][
'tmp_name']);
96 foreach($userfiles as $key => $userfile)
98 if (empty($_FILES[
'userfile'][
'tmp_name'][$key]))
101 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2){
105 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")), null,
'errors');
116 $result=$ecmdir->changeNbOfFiles(
'+');
122 if ($action ==
'confirm_deletefile')
124 if (
GETPOST(
'confirm') ==
'yes')
129 $upload_dir = $conf->ecm->dir_output.($relativepath?
'/'.$relativepath:
'');
130 $file = $upload_dir .
"/" .
GETPOST(
'urlfile',
'alpha');
136 $result=$ecmdir->changeNbOfFiles(
'-');
145 $action=
'file_manager';
149 if ($action ==
'add' && $user->rights->ecm->setup)
151 $ecmdir->ref =
'NOTUSEDYET';
152 $ecmdir->label =
GETPOST(
"label");
153 $ecmdir->description =
GETPOST(
"desc");
155 $id = $ecmdir->create($user);
158 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
171 if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm') ==
'yes')
173 $result=$ecmdir->delete($user);
174 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label), null,
'mesgs');
182 if ($action ==
'refreshmanual')
189 $diroutputslash=str_replace(
'\\',
'/',$conf->ecm->dir_output);
190 $diroutputslash.=
'/';
193 $disktree=
dol_dir_list($conf->ecm->dir_output,
'directories',1,
'',
'^temp$',
'',
'',0);
196 $sqltree=$ecmdirstatic->get_full_arbo(0);
203 foreach($disktree as $dirdesc)
206 foreach($sqltree as $dirsqldesc)
208 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname'])
215 if (! $dirisindatabase)
217 $txt=
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
223 $relativepathmissing=str_replace($diroutputslash,
'',$dirdesc[
'fullname']);
224 $relativepathtosearchparent=$relativepathmissing;
226 if (preg_match(
'/\//',$relativepathtosearchparent))
229 $relativepathtosearchparent=preg_replace(
'/\/[^\/]*$/',
'',$relativepathtosearchparent);
230 $txt=
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
233 $parentdirisindatabase=0;
234 foreach($sqltree as $dirsqldesc)
236 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent)
238 $parentdirisindatabase=$dirsqldesc[
'id'];
242 if ($parentdirisindatabase > 0)
244 dol_syslog(
"Yes with id ".$parentdirisindatabase);
246 $fk_parent=$parentdirisindatabase;
263 $ecmdirtmp->ref =
'NOTUSEDYET';
265 $ecmdirtmp->description =
'';
266 $ecmdirtmp->fk_parent = $fk_parent;
268 $txt=
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
271 $id = $ecmdirtmp->create($user);
274 $newdirsql=array(
'id'=>$id,
275 'id_mere'=>$ecmdirtmp->fk_parent,
276 'label'=>$ecmdirtmp->label,
277 'description'=>$ecmdirtmp->description,
278 'fullrelativename'=>$relativepathmissing);
279 $sqltree[]=$newdirsql;
285 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
289 $txt=
"Parent of ".$dirdesc[
'fullname'].
" not found";
297 foreach($sqltree as $dirdesc)
299 $dirtotest=$conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
302 $ecmdirtmp->id=$dirdesc[
'id'];
303 $ecmdirtmp->delete($user,
'databaseonly');
308 $sql=
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
314 if ($adirwascreated) $sqltree=null;
325 $maxheightwin=(isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466)?($_SESSION[
"dol_screenheight"]-136):660;
331 $morejs=array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
332 if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[]=
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
334 $moreheadjs.=
'<script type="text/javascript">'.
"\n";
335 $moreheadjs.=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n"; 336 $moreheadjs.='</script>
'."\n"; 338 llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECMArea"),'','','','',$morejs,'',0,0); 340 $head = ecm_prepare_dasboard_head(''); 341 dol_fiche_head($head, 'index
', $langs->trans("ECMArea").' -
'.$langs->trans("ECMFileManager"), -1, ''); 344 // Add filemanager component 346 include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php
'; GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
Class to manage Dolibarr users.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_is_dir($folder)
Test if filename is a directory.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1)
Get and save an upload file (for example after submitting a new file a mail form).
dol_basename($pathfile)
Make a basename working with all page code (default PHP basenamed fails with cyrillic).
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
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.
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
Class to manage ECM directories.