29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
37$langs->loadLangs(array(
'ecm',
'companies',
'other',
'users',
'orders',
'propal',
'bills',
'contracts'));
41$action =
GETPOST(
'action',
'aZ09');
46$section_dir =
GETPOST(
'section_dir',
'alpha');
50$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53if (empty($page) || $page == -1) {
56$offset = $limit * $page;
68 $result = $ecmdir->fetch($section);
77$userstatic =
new User($db);
83 $socid = $user->socid;
86$hookmanager->initHooks(array(
'ecmindexcard',
'globalcard'));
90$permissiontoread = $user->hasRight(
'ecm',
'read');
91$permissiontocreate = $user->hasRight(
'ecm',
'upload');
92$permissiontocreatedir = $user->hasRight(
'ecm',
'setup');
93$permissiontodelete = $user->hasRight(
'ecm',
'upload');
94$permissiontodeletedir = $user->hasRight(
'ecm',
'setup');
109 $relativepath = $ecmdir->getRelativePath();
111 $relativepath = $section_dir;
113 $upload_dir = $conf->ecm->dir_output.
'/'.$relativepath;
116 if (is_array($_FILES[
'userfile'])) {
117 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
118 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
120 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
124 foreach ($userfiles as $key => $userfile) {
125 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
127 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
130 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
137 $res =
dol_add_file_process($upload_dir, $overwritefile, 1,
'userfile',
'',
null,
'', $generatethumbs);
139 $result = $ecmdir->changeNbOfFiles(
'+');
145if ($action ==
'confirm_deletefile' && $permissiontodelete) {
146 if (
GETPOST(
'confirm') ==
'yes') {
149 $upload_dir = $conf->ecm->dir_output.($relativepath ?
'/'.$relativepath :
'');
150 $file = $upload_dir.
"/".
GETPOST(
'urlfile',
'alpha');
153 $urlfiletoshow =
GETPOST(
'urlfile',
'alpha');
154 $urlfiletoshow = preg_replace(
'/\.noexe$/',
'', $urlfiletoshow);
155 setEventMessages($langs->trans(
"FileWasRemoved", $urlfiletoshow),
null,
'mesgs');
156 $result = $ecmdir->changeNbOfFiles(
'-');
163 $action =
'file_manager';
167if ($action ==
'add' && $permissiontocreatedir) {
168 $ecmdir->ref =
'NOTUSEDYET';
169 $ecmdir->label =
GETPOST(
"label");
170 $ecmdir->description =
GETPOST(
"desc");
172 $id = $ecmdir->create($user);
174 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
185if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontodeletedir) {
186 $result = $ecmdir->delete($user);
187 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
195if ($action ==
'refreshmanual' && $permissiontoread) {
201 $diroutputslash = str_replace(
'\\',
'/', $conf->ecm->dir_output);
202 $diroutputslash .=
'/';
205 $disktree =
dol_dir_list($conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'', 0, 0);
208 $sqltree = $ecmdirstatic->get_full_arbo(0);
215 foreach ($disktree as $dirdesc) {
216 $dirisindatabase = 0;
217 foreach ($sqltree as $dirsqldesc) {
218 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
219 $dirisindatabase = 1;
224 if (!$dirisindatabase) {
225 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
231 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
232 $relativepathtosearchparent = $relativepathmissing;
234 if (preg_match(
'/\//', $relativepathtosearchparent)) {
236 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
237 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
240 $parentdirisindatabase = 0;
241 foreach ($sqltree as $dirsqldesc) {
242 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
243 $parentdirisindatabase = $dirsqldesc[
'id'];
247 if ($parentdirisindatabase > 0) {
248 dol_syslog(
"Yes with id ".$parentdirisindatabase);
250 $fk_parent = $parentdirisindatabase;
261 if ($fk_parent >= 0) {
262 $ecmdirtmp->ref =
'NOTUSEDYET';
264 $ecmdirtmp->description =
'';
265 $ecmdirtmp->fk_parent = $fk_parent;
267 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
270 $id = $ecmdirtmp->create($user);
272 $newdirsql = array(
'id'=>$id,
273 'id_mere'=>$ecmdirtmp->fk_parent,
274 'label'=>$ecmdirtmp->label,
275 'description'=>$ecmdirtmp->description,
276 'fullrelativename'=>$relativepathmissing);
277 $sqltree[] = $newdirsql;
281 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
284 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
292 foreach ($sqltree as $dirdesc) {
293 $dirtotest = $conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
295 $ecmdirtmp->id = $dirdesc[
'id'];
296 $ecmdirtmp->delete($user,
'databaseonly');
301 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
307 if ($adirwascreated) {
320$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
326$morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
328 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
331$moreheadjs .=
'<script type="text/javascript">'.
"\n";
332$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
333$moreheadjs .= '</script>
'."\n";
335llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', 0, 0, $morejs, '', '', 'mod-ecm page-index
');
337$head = ecm_prepare_dasboard_head();
338print dol_get_fiche_head($head, 'index
', '', -1, '');
341// Add filemanager component
344 $url = DOL_URL_ROOT.'/ecm/index.php
'; // Must be an url without param
346include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php
';
349print dol_get_fiche_end();
Class to manage ECM directories.
Class to manage Dolibarr users.
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, $nolog=0)
Remove a file or several files with a mask.
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null)
Get and save an upload file (for example after submitting a new file a mail form).
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.