';
- if ($permtoadd)
- {
+ if ($permtoadd) {
print '
'.$langs->trans('Edit').'';
}
- if ($permtoadd)
- {
+ if ($permtoadd) {
print '
'.$langs->trans('ECMAddSection').'';
} else {
print '
'.$langs->trans('ECMAddSection').'';
@@ -467,8 +447,7 @@ if ($action != 'edit' && $action != 'delete')
//if (count($filearrayall) == 0)
//{
- if ($permtoadd)
- {
+ if ($permtoadd) {
print '
'.$langs->trans('Delete').'';
} else {
print '
'.$langs->trans('Delete').'';
@@ -485,19 +464,16 @@ if ($action != 'edit' && $action != 'delete')
}
// Confirm remove file
-if ($action == 'delete')
-{
+if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST("section", 'alpha').'&urlfile='.urlencode($_GET["urlfile"]).($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
}
// Confirm remove file
-if ($action == 'delete_dir')
-{
+if ($action == 'delete_dir') {
$relativepathwithoutslash = preg_replace('/[\/]$/', '', $relativepath);
//Form to close proposal (signed or not)
- if (count($filearrayall) > 0)
- {
+ if (count($filearrayall) > 0) {
$langs->load("other");
$formquestion = array(
array('type' => 'checkbox', 'name' => 'deletedirrecursive', 'label' => $langs->trans("ContentOfDirectoryIsNotEmpty").'
'.$langs->trans("DeleteAlsoContentRecursively"), 'value' => '0') // Field to complete private note (not replace)
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index 8feff24e4c3..26bf242b0f2 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -35,33 +35,41 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
// Security check
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'ecm', 0);
// Get parameters
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09');
$section = GETPOST('section', 'int') ?GETPOST('section', 'int') : GETPOST('section_id', 'int');
-if (!$section) $section = 0;
+if (!$section) {
+ $section = 0;
+}
$section_dir = GETPOST('section_dir', 'alpha');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) {
+ $page = 0;
+} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if (!$sortorder) $sortorder = "ASC";
-if (!$sortfield) $sortfield = "fullname";
+if (!$sortorder) {
+ $sortorder = "ASC";
+}
+if (!$sortfield) {
+ $sortfield = "fullname";
+}
$ecmdir = new EcmDirectory($db);
-if ($section > 0)
-{
+if ($section > 0) {
$result = $ecmdir->fetch($section);
- if (!$result > 0)
- {
+ if (!$result > 0) {
dol_print_error($db, $ecmdir->error);
exit;
}
@@ -83,21 +91,24 @@ $error = 0;
//include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
// Upload file (code similar but different than actions_linkedfiles.inc.php)
-if (GETPOST("sendit", 'alphanohtml') && !empty($conf->global->MAIN_UPLOAD_DOC))
-{
+if (GETPOST("sendit", 'alphanohtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) {
// Define relativepath and upload_dir
$relativepath = '';
- if ($ecmdir->id) $relativepath = $ecmdir->getRelativePath();
- else $relativepath = $section_dir;
+ if ($ecmdir->id) {
+ $relativepath = $ecmdir->getRelativePath();
+ } else {
+ $relativepath = $section_dir;
+ }
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
- if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name'];
- else $userfiles = array($_FILES['userfile']['tmp_name']);
+ if (is_array($_FILES['userfile']['tmp_name'])) {
+ $userfiles = $_FILES['userfile']['tmp_name'];
+ } else {
+ $userfiles = array($_FILES['userfile']['tmp_name']);
+ }
- foreach ($userfiles as $key => $userfile)
- {
- if (empty($_FILES['userfile']['tmp_name'][$key]))
- {
+ foreach ($userfiles as $key => $userfile) {
+ if (empty($_FILES['userfile']['tmp_name'][$key])) {
$error++;
if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) {
setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors');
@@ -107,29 +118,24 @@ if (GETPOST("sendit", 'alphanohtml') && !empty($conf->global->MAIN_UPLOAD_DOC))
}
}
- if (!$error)
- {
+ if (!$error) {
$generatethumbs = 0;
$res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', null, '', $generatethumbs);
- if ($res > 0)
- {
+ if ($res > 0) {
$result = $ecmdir->changeNbOfFiles('+');
}
}
}
// Remove file (code similar but different than actions_linkedfiles.inc.php)
-if ($action == 'confirm_deletefile')
-{
- if (GETPOST('confirm') == 'yes')
- {
+if ($action == 'confirm_deletefile') {
+ if (GETPOST('confirm') == 'yes') {
// GETPOST('urlfile','alpha') is full relative URL from ecm root dir. Contains path of all sections.
$upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : '');
$file = $upload_dir."/".GETPOST('urlfile', 'alpha');
$ret = dol_delete_file($file); // This include also the delete from file index in database.
- if ($ret)
- {
+ if ($ret) {
$urlfiletoshow = GETPOST('urlfile', 'alpha');
$urlfiletoshow = preg_replace('/\.noexe$/', '', $urlfiletoshow);
setEventMessages($langs->trans("FileWasRemoved", $urlfiletoshow), null, 'mesgs');
@@ -144,15 +150,13 @@ if ($action == 'confirm_deletefile')
}
// Add directory
-if ($action == 'add' && $user->rights->ecm->setup)
-{
+if ($action == 'add' && $user->rights->ecm->setup) {
$ecmdir->ref = 'NOTUSEDYET';
$ecmdir->label = GETPOST("label");
$ecmdir->description = GETPOST("desc");
$id = $ecmdir->create($user);
- if ($id > 0)
- {
+ if ($id > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
@@ -164,8 +168,7 @@ if ($action == 'add' && $user->rights->ecm->setup)
}
// Remove directory
-if ($action == 'confirm_deletesection' && GETPOST('confirm', 'alpha') == 'yes')
-{
+if ($action == 'confirm_deletesection' && GETPOST('confirm', 'alpha') == 'yes') {
$result = $ecmdir->delete($user);
setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs');
@@ -175,8 +178,7 @@ if ($action == 'confirm_deletesection' && GETPOST('confirm', 'alpha') == 'yes')
// Refresh directory view
// This refresh list of dirs, not list of files (for preformance reason). List of files is refresh only if dir was not synchronized.
// To refresh content of dir with cache, just open the dir in edit mode.
-if ($action == 'refreshmanual')
-{
+if ($action == 'refreshmanual') {
$ecmdirtmp = new EcmDirectory($db);
// This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate
@@ -196,20 +198,16 @@ if ($action == 'refreshmanual')
// Now we compare both trees to complete missing trees into database
//var_dump($disktree);
//var_dump($sqltree);
- foreach ($disktree as $dirdesc) // Loop on tree onto disk
- {
+ foreach ($disktree as $dirdesc) { // Loop on tree onto disk
$dirisindatabase = 0;
- foreach ($sqltree as $dirsqldesc)
- {
- if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname'])
- {
+ foreach ($sqltree as $dirsqldesc) {
+ if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) {
$dirisindatabase = 1;
break;
}
}
- if (!$dirisindatabase)
- {
+ if (!$dirisindatabase) {
$txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it";
dol_syslog($txt);
//print $txt."
\n";
@@ -219,24 +217,20 @@ if ($action == 'refreshmanual')
$relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']);
$relativepathtosearchparent = $relativepathmissing;
//dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent);
- if (preg_match('/\//', $relativepathtosearchparent))
- //while (preg_match('/\//',$relativepathtosearchparent))
- {
+ if (preg_match('/\//', $relativepathtosearchparent)) {
+ //while (preg_match('/\//',$relativepathtosearchparent))
$relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent);
$txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?";
dol_syslog($txt);
//print $txt." -> ";
$parentdirisindatabase = 0;
- foreach ($sqltree as $dirsqldesc)
- {
- if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent)
- {
+ foreach ($sqltree as $dirsqldesc) {
+ if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) {
$parentdirisindatabase = $dirsqldesc['id'];
break;
}
}
- if ($parentdirisindatabase > 0)
- {
+ if ($parentdirisindatabase > 0) {
dol_syslog("Yes with id ".$parentdirisindatabase);
//print "Yes with id ".$parentdirisindatabase."
\n";
$fk_parent = $parentdirisindatabase;
@@ -250,8 +244,7 @@ if ($action == 'refreshmanual')
$fk_parent = 0; // Parent is root
}
- if ($fk_parent >= 0)
- {
+ if ($fk_parent >= 0) {
$ecmdirtmp->ref = 'NOTUSEDYET';
$ecmdirtmp->label = dol_basename($dirdesc['fullname']);
$ecmdirtmp->description = '';
@@ -261,8 +254,7 @@ if ($action == 'refreshmanual')
dol_syslog($txt);
//print $ecmdirtmp->cachenbofdoc."
\n";exit;
$id = $ecmdirtmp->create($user);
- if ($id > 0)
- {
+ if ($id > 0) {
$newdirsql = array('id'=>$id,
'id_mere'=>$ecmdirtmp->fk_parent,
'label'=>$ecmdirtmp->label,
@@ -283,11 +275,9 @@ if ($action == 'refreshmanual')
}
// Loop now on each sql tree to check if dir exists
- foreach ($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk
- {
+ foreach ($sqltree as $dirdesc) { // Loop on each sqltree to check dir is on disk
$dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename'];
- if (!dol_is_dir($dirtotest))
- {
+ if (!dol_is_dir($dirtotest)) {
$ecmdirtmp->id = $dirdesc['id'];
$ecmdirtmp->delete($user, 'databaseonly');
//exit;
@@ -300,7 +290,9 @@ if ($action == 'refreshmanual')
// If a directory was added, the fulltree array is not correctly completed and sorted, so we clean
// it to be sure that fulltree array is not used without reloading it.
- if ($adirwascreated) $sqltree = null;
+ if ($adirwascreated) {
+ $sqltree = null;
+ }
}
@@ -318,7 +310,9 @@ $moreheadjs = '';
//$morejs=array();
$morejs = array('includes/jquery/plugins/blockUI/jquery.blockUI.js', 'core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp
-if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
+if (empty($conf->global->MAIN_ECM_DISABLE_JS)) {
+ $morejs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
+}
$moreheadjs .= '