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';
45$langs->loadLangs(array(
'ecm',
'companies',
'other',
'users',
'orders',
'propal',
'bills',
'contracts'));
49$action =
GETPOST(
'action',
'aZ09');
54$section_dir =
GETPOST(
'section_dir',
'alpha');
58$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61if (empty($page) || $page == -1) {
64$offset = $limit * $page;
76 $result = $ecmdir->fetch($section);
85$userstatic =
new User($db);
91 $socid = $user->socid;
94$hookmanager->initHooks(array(
'ecmindexcard',
'globalcard'));
98$permissiontoread = $user->hasRight(
'ecm',
'read');
99$permissiontocreate = $user->hasRight(
'ecm',
'upload');
100$permissiontocreatedir = $user->hasRight(
'ecm',
'setup');
101$permissiontodelete = $user->hasRight(
'ecm',
'upload');
102$permissiontodeletedir = $user->hasRight(
'ecm',
'setup');
117 $relativepath = $ecmdir->getRelativePath();
119 $relativepath = $section_dir;
121 $upload_dir =
$conf->ecm->dir_output.
'/'.$relativepath;
124 if (is_array($_FILES[
'userfile'])) {
125 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
126 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
128 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
132 foreach ($userfiles as $key => $userfile) {
133 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
135 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
138 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
145 $res =
dol_add_file_process($upload_dir, $overwritefile, 1,
'userfile',
'',
null,
'', $generatethumbs);
147 $result = $ecmdir->changeNbOfFiles(
'+');
153if ($action ==
'confirm_deletefile' && $permissiontodelete) {
154 if (
GETPOST(
'confirm') ==
'yes') {
157 $upload_dir =
$conf->ecm->dir_output.($relativepath ?
'/'.$relativepath :
'');
158 $file = $upload_dir.
"/".
GETPOST(
'urlfile',
'alpha');
161 $urlfiletoshow =
GETPOST(
'urlfile',
'alpha');
162 $urlfiletoshow = preg_replace(
'/\.noexe$/',
'', $urlfiletoshow);
163 setEventMessages($langs->trans(
"FileWasRemoved", $urlfiletoshow),
null,
'mesgs');
164 $result = $ecmdir->changeNbOfFiles(
'-');
171 $action =
'file_manager';
175if ($action ==
'add' && $permissiontocreatedir) {
176 $ecmdir->ref =
'NOTUSEDYET';
177 $ecmdir->label =
GETPOST(
"label");
178 $ecmdir->description =
GETPOST(
"desc");
180 $id = $ecmdir->create($user);
182 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
193if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontodeletedir) {
194 $result = $ecmdir->delete($user);
195 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
203if ($action ==
'refreshmanual' && $permissiontoread) {
209 $diroutputslash = str_replace(
'\\',
'/',
$conf->ecm->dir_output);
210 $diroutputslash .=
'/';
213 $disktree =
dol_dir_list(
$conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'', 0, 0);
216 $sqltree = $ecmdirstatic->get_full_arbo(0);
223 foreach ($disktree as $dirdesc) {
224 $dirisindatabase = 0;
225 foreach ($sqltree as $dirsqldesc) {
226 if (
$conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
227 $dirisindatabase = 1;
232 if (!$dirisindatabase) {
233 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
239 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
240 $relativepathtosearchparent = $relativepathmissing;
242 if (preg_match(
'/\//', $relativepathtosearchparent)) {
244 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
245 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
248 $parentdirisindatabase = 0;
249 foreach ($sqltree as $dirsqldesc) {
250 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
251 $parentdirisindatabase = $dirsqldesc[
'id'];
255 if ($parentdirisindatabase > 0) {
256 dol_syslog(
"Yes with id ".$parentdirisindatabase);
258 $fk_parent = $parentdirisindatabase;
269 if ($fk_parent >= 0) {
270 $ecmdirtmp->ref =
'NOTUSEDYET';
272 $ecmdirtmp->description =
'';
273 $ecmdirtmp->fk_parent = $fk_parent;
275 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
278 $id = $ecmdirtmp->create($user);
280 $newdirsql = array(
'id'=>$id,
281 'id_mere'=>$ecmdirtmp->fk_parent,
282 'label'=>$ecmdirtmp->label,
283 'description'=>$ecmdirtmp->description,
284 'fullrelativename'=>$relativepathmissing);
285 $sqltree[] = $newdirsql;
289 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
292 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
300 foreach ($sqltree as $dirdesc) {
301 $dirtotest =
$conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
303 $ecmdirtmp->id = $dirdesc[
'id'];
304 $ecmdirtmp->delete($user,
'databaseonly');
309 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
315 if ($adirwascreated) {
328$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
334$morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
336 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
339$moreheadjs .=
'<script type="text/javascript">'.
"\n";
340$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".
$conf->theme.
"/img/working.gif".
'\';
'."\n";
341$moreheadjs .= '</script>
'."\n";
343llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', 0, 0, $morejs, '', '', 'mod-ecm page-index
');
345$head = ecm_prepare_dasboard_head();
346print dol_get_fiche_head($head, 'index
', '', -1, '');
349// Add filemanager component
352 $url = DOL_URL_ROOT.'/ecm/index.php
'; // Must be an url without param
354include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php
';
357print 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, $forceFullTestIndexation='')
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.