Merge pull request #16442 from frederic34/ecm_code_syntax

code syntax ecm emailcollector directories
This commit is contained in:
Laurent Destailleur 2021-02-26 10:35:01 +01:00 committed by GitHub
commit ff2a348ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 1168 additions and 1101 deletions

View File

@ -20,10 +20,18 @@
* \brief File to build ecm database * \brief File to build ecm database
*/ */
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); }
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -40,12 +48,10 @@ top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Load original field value // Load original field value
if (isset($action) && !empty($action)) if (isset($action) && !empty($action)) {
{
$error = 0; $error = 0;
if ($action == 'build' && !empty($element)) if ($action == 'build' && !empty($element)) {
{
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
$ecmdirstatic = new EcmDirectory($db); $ecmdirstatic = new EcmDirectory($db);
@ -68,22 +74,18 @@ if (isset($action) && !empty($action))
// Now we compare both trees to complete missing trees into database // Now we compare both trees to complete missing trees into database
//var_dump($disktree); //var_dump($disktree);
//var_dump($sqltree); //var_dump($sqltree);
foreach ($disktree as $dirdesc) // Loop on tree onto disk foreach ($disktree as $dirdesc) { // Loop on tree onto disk
{
set_time_limit(0); // To force restarts the timeout counter from zero set_time_limit(0); // To force restarts the timeout counter from zero
$dirisindatabase = 0; $dirisindatabase = 0;
foreach ($sqltree as $dirsqldesc) foreach ($sqltree as $dirsqldesc) {
{ if ($conf->$element->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) {
if ($conf->$element->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname'])
{
$dirisindatabase = 1; $dirisindatabase = 1;
break; break;
} }
} }
if (!$dirisindatabase) if (!$dirisindatabase) {
{
$txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it";
dol_syslog($txt); dol_syslog($txt);
@ -92,24 +94,20 @@ if (isset($action) && !empty($action))
$relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']);
$relativepathtosearchparent = $relativepathmissing; $relativepathtosearchparent = $relativepathmissing;
//dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent);
if (preg_match('/\//', $relativepathtosearchparent)) if (preg_match('/\//', $relativepathtosearchparent)) {
//while (preg_match('/\//',$relativepathtosearchparent)) //while (preg_match('/\//',$relativepathtosearchparent))
{
$relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent);
$txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?";
dol_syslog($txt); dol_syslog($txt);
//print $txt." -> "; //print $txt." -> ";
$parentdirisindatabase = 0; $parentdirisindatabase = 0;
foreach ($sqltree as $dirsqldesc) foreach ($sqltree as $dirsqldesc) {
{ if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) {
if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent)
{
$parentdirisindatabase = $dirsqldesc['id']; $parentdirisindatabase = $dirsqldesc['id'];
break; break;
} }
} }
if ($parentdirisindatabase > 0) if ($parentdirisindatabase > 0) {
{
dol_syslog("Yes with id ".$parentdirisindatabase); dol_syslog("Yes with id ".$parentdirisindatabase);
//print "Yes with id ".$parentdirisindatabase."<br>\n"; //print "Yes with id ".$parentdirisindatabase."<br>\n";
$fk_parent = $parentdirisindatabase; $fk_parent = $parentdirisindatabase;
@ -123,8 +121,7 @@ if (isset($action) && !empty($action))
$fk_parent = 0; // Parent is root $fk_parent = 0; // Parent is root
} }
if ($fk_parent >= 0) if ($fk_parent >= 0) {
{
$ecmdirtmp->ref = 'NOTUSEDYET'; $ecmdirtmp->ref = 'NOTUSEDYET';
$ecmdirtmp->label = dol_basename($dirdesc['fullname']); $ecmdirtmp->label = dol_basename($dirdesc['fullname']);
$ecmdirtmp->description = ''; $ecmdirtmp->description = '';
@ -134,8 +131,7 @@ if (isset($action) && !empty($action))
dol_syslog($txt); dol_syslog($txt);
//print $txt."<br>\n"; //print $txt."<br>\n";
$id = $ecmdirtmp->create($user); $id = $ecmdirtmp->create($user);
if ($id > 0) if ($id > 0) {
{
$newdirsql = array('id'=>$id, $newdirsql = array('id'=>$id,
'id_mere'=>$ecmdirtmp->fk_parent, 'id_mere'=>$ecmdirtmp->fk_parent,
'label'=>$ecmdirtmp->label, 'label'=>$ecmdirtmp->label,
@ -156,11 +152,9 @@ if (isset($action) && !empty($action))
} }
// Loop now on each sql tree to check if dir exists // 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->$element->dir_output.'/'.$dirdesc['fullrelativename']; $dirtotest = $conf->$element->dir_output.'/'.$dirdesc['fullrelativename'];
if (!dol_is_dir($dirtotest)) if (!dol_is_dir($dirtotest)) {
{
$mesg .= $dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']."<br>\n"; $mesg .= $dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']."<br>\n";
$ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->id = $dirdesc['id'];
$ecmdirtmp->delete($user, 'databaseonly'); $ecmdirtmp->delete($user, 'databaseonly');

View File

@ -62,31 +62,29 @@ class FormEcm
global $conf, $langs; global $conf, $langs;
$langs->load("ecm"); $langs->load("ecm");
if ($select_name == '') $select_name = "catParent"; if ($select_name == '') {
$select_name = "catParent";
}
$cate_arbo = null; $cate_arbo = null;
if ($module == 'ecm') if ($module == 'ecm') {
{
$cat = new EcmDirectory($this->db); $cat = new EcmDirectory($this->db);
$cate_arbo = $cat->get_full_arbo(); $cate_arbo = $cat->get_full_arbo();
} elseif ($module == 'medias') } elseif ($module == 'medias') {
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$path = $conf->medias->multidir_output[$conf->entity]; $path = $conf->medias->multidir_output[$conf->entity];
$cate_arbo = dol_dir_list($path, 'directories', 1, '', array('(\.meta|_preview.*\.png)$', '^\.'), 'relativename', SORT_ASC); $cate_arbo = dol_dir_list($path, 'directories', 1, '', array('(\.meta|_preview.*\.png)$', '^\.'), 'relativename', SORT_ASC);
} }
$output = '<select class="flat minwidth100 maxwidth500" id="'.$select_name.'" name="'.$select_name.'">'; $output = '<select class="flat minwidth100 maxwidth500" id="'.$select_name.'" name="'.$select_name.'">';
if (is_array($cate_arbo)) if (is_array($cate_arbo)) {
{ if (!count($cate_arbo)) {
if (!count($cate_arbo)) $output .= '<option value="-1" disabled>'.$langs->trans("NoDirectoriesFound").'</option>'; $output .= '<option value="-1" disabled>'.$langs->trans("NoDirectoriesFound").'</option>';
else { } else {
$output .= '<option value="-1">&nbsp;</option>'; $output .= '<option value="-1">&nbsp;</option>';
foreach ($cate_arbo as $key => $value) foreach ($cate_arbo as $key => $value) {
{
$valueforoption = empty($cate_arbo[$key]['id']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['id']; $valueforoption = empty($cate_arbo[$key]['id']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['id'];
if ($selected && $valueforoption == $selected) if ($selected && $valueforoption == $selected) {
{
$add = 'selected '; $add = 'selected ';
} else { } else {
$add = ''; $add = '';

View File

@ -40,23 +40,30 @@ $confirm = GETPOST('confirm', 'alpha');
$module = GETPOST('module', 'alpha'); $module = GETPOST('module', 'alpha');
$website = GETPOST('website', 'alpha'); $website = GETPOST('website', 'alpha');
$pageid = GETPOST('pageid', 'int'); $pageid = GETPOST('pageid', 'int');
if (empty($module)) $module = 'ecm'; if (empty($module)) {
$module = 'ecm';
}
// Get parameters // Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $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; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "name"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$section = GETPOST("section", 'alpha') ? GETPOST("section", 'alpha') : GETPOST("relativedir", 'alpha'); $section = GETPOST("section", 'alpha') ? GETPOST("section", 'alpha') : GETPOST("relativedir", 'alpha');
if (!$section) if (!$section) {
{
dol_print_error('', "ErrorSectionParamNotDefined"); dol_print_error('', "ErrorSectionParamNotDefined");
exit; exit;
} }
@ -64,8 +71,7 @@ if (!$section)
// Load ecm object // Load ecm object
$ecmdir = new EcmDirectory($db); $ecmdir = new EcmDirectory($db);
if ($module == 'ecm') if ($module == 'ecm') {
{
// $section should be an int except if it is dir not yet created into EcmDirectory // $section should be an int except if it is dir not yet created into EcmDirectory
$result = $ecmdir->fetch($section); $result = $ecmdir->fetch($section);
if ($result > 0) { if ($result > 0) {
@ -84,13 +90,11 @@ if ($module == 'ecm')
// Permissions // Permissions
$permtoadd = 0; $permtoadd = 0;
$permtoupload = 0; $permtoupload = 0;
if ($module == 'ecm') if ($module == 'ecm') {
{
$permtoadd = $user->rights->ecm->setup; $permtoadd = $user->rights->ecm->setup;
$permtoupload = $user->rights->ecm->upload; $permtoupload = $user->rights->ecm->upload;
} }
if ($module == 'medias') if ($module == 'medias') {
{
$permtoadd = ($user->rights->mailing->creer || $user->rights->website->write); $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
$permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write);
} }
@ -102,18 +106,14 @@ if ($module == 'medias')
*/ */
// Upload file // Upload file
if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) {
{ if (dol_mkdir($upload_dir) >= 0) {
if (dol_mkdir($upload_dir) >= 0)
{
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']); $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0) if (is_numeric($resupload) && $resupload > 0) {
{
$result = $ecmdir->changeNbOfFiles('+'); $result = $ecmdir->changeNbOfFiles('+');
} else { } else {
$langs->load("errors"); $langs->load("errors");
if ($resupload < 0) // Unknown error if ($resupload < 0) { // Unknown error
{
setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
} elseif (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) { } elseif (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) {
// Files infected by a virus // Files infected by a virus
@ -131,13 +131,15 @@ if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC))
} }
// Remove file // Remove file
if ($action == 'confirm_deletefile' && $confirm == 'yes') if ($action == 'confirm_deletefile' && $confirm == 'yes') {
{
$langs->load("other"); $langs->load("other");
$file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret = dol_delete_file($file); $ret = dol_delete_file($file);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); if ($ret) {
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
} else {
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
}
$result = $ecmdir->changeNbOfFiles('-'); $result = $ecmdir->changeNbOfFiles('-');
} }
@ -164,8 +166,9 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') {
} else { } else {
$resbool = dol_delete_dir($upload_dir, 1); $resbool = dol_delete_dir($upload_dir, 1);
} }
if ($resbool) $result = 1; if ($resbool) {
else { $result = 1;
} else {
$langs->load('errors'); $langs->load('errors');
setEventMessages($langs->trans("ErrorFailToDeleteDir", $upload_dir), null, 'errors'); setEventMessages($langs->trans("ErrorFailToDeleteDir", $upload_dir), null, 'errors');
$result = 0; $result = 0;
@ -178,12 +181,10 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') {
} }
// Update dirname or description // Update dirname or description
if ($action == 'update' && !GETPOST('cancel', 'alpha')) if ($action == 'update' && !GETPOST('cancel', 'alpha')) {
{
$error = 0; $error = 0;
if ($module == 'ecm') if ($module == 'ecm') {
{
$oldlabel = $ecmdir->label; $oldlabel = $ecmdir->label;
$olddir = $ecmdir->getRelativePath(0); $olddir = $ecmdir->getRelativePath(0);
$olddir = $conf->ecm->dir_output.'/'.$olddir; $olddir = $conf->ecm->dir_output.'/'.$olddir;
@ -192,15 +193,16 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha'))
$olddir = $conf->medias->multidir_output[$conf->entity].'/'.$relativepath; $olddir = $conf->medias->multidir_output[$conf->entity].'/'.$relativepath;
} }
if ($module == 'ecm') if ($module == 'ecm') {
{
$db->begin(); $db->begin();
// Fetch was already done // Fetch was already done
$ecmdir->label = dol_sanitizeFileName(GETPOST("label")); $ecmdir->label = dol_sanitizeFileName(GETPOST("label"));
$ecmdir->description = GETPOST("description"); $ecmdir->description = GETPOST("description");
$ret = $extrafields->setOptionalsFromPost(null, $ecmdir); $ret = $extrafields->setOptionalsFromPost(null, $ecmdir);
if ($ret < 0) $error++; if ($ret < 0) {
$error++;
}
if (!$error) { if (!$error) {
// Actions on extra fields // Actions on extra fields
$result = $ecmdir->insertExtraFields(); $result = $ecmdir->insertExtraFields();
@ -210,25 +212,21 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha'))
} }
} }
$result = $ecmdir->update($user); $result = $ecmdir->update($user);
if ($result > 0) if ($result > 0) {
{
// Try to rename file if changed // Try to rename file if changed
if ($oldlabel != $ecmdir->label && file_exists($olddir)) if ($oldlabel != $ecmdir->label && file_exists($olddir)) {
{
$newdir = $ecmdir->getRelativePath(1); // return "xxx/zzz/" from ecm directory $newdir = $ecmdir->getRelativePath(1); // return "xxx/zzz/" from ecm directory
$newdir = $conf->ecm->dir_output.'/'.$newdir; $newdir = $conf->ecm->dir_output.'/'.$newdir;
//print $olddir.'-'.$newdir; //print $olddir.'-'.$newdir;
$result = @rename($olddir, $newdir); $result = @rename($olddir, $newdir);
if (!$result) if (!$result) {
{
$langs->load('errors'); $langs->load('errors');
setEventMessages($langs->trans('ErrorFailToRenameDir', $olddir, $newdir), null, 'errors'); setEventMessages($langs->trans('ErrorFailToRenameDir', $olddir, $newdir), null, 'errors');
$error++; $error++;
} }
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
// Set new value after renaming // Set new value after renaming
@ -245,15 +243,13 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha'))
$newdir = $conf->medias->multidir_output[$conf->entity].'/'.GETPOST('oldrelparentdir', 'alpha').'/'.GETPOST('label', 'alpha'); $newdir = $conf->medias->multidir_output[$conf->entity].'/'.GETPOST('oldrelparentdir', 'alpha').'/'.GETPOST('label', 'alpha');
$result = @rename($olddir, $newdir); $result = @rename($olddir, $newdir);
if (!$result) if (!$result) {
{
$langs->load('errors'); $langs->load('errors');
setEventMessages($langs->trans('ErrorFailToRenameDir', $olddir, $newdir), null, 'errors'); setEventMessages($langs->trans('ErrorFailToRenameDir', $olddir, $newdir), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{
// Set new value after renaming // Set new value after renaming
$relativepath = GETPOST('oldrelparentdir', 'alpha').'/'.GETPOST('label', 'alpha'); $relativepath = GETPOST('oldrelparentdir', 'alpha').'/'.GETPOST('label', 'alpha');
$upload_dir = $conf->medias->multidir_output[$conf->entity].'/'.$relativepath; $upload_dir = $conf->medias->multidir_output[$conf->entity].'/'.$relativepath;
@ -284,8 +280,7 @@ llxHeader();
$filearrayall = dol_dir_list($upload_dir, "all", 0, '', '', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearrayall = dol_dir_list($upload_dir, "all", 0, '', '', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0; $totalsize = 0;
foreach ($filearray as $key => $file) foreach ($filearray as $key => $file) {
{
$totalsize += $file['size']; $totalsize += $file['size'];
} }
@ -294,8 +289,7 @@ $head = ecm_prepare_head($ecmdir, $module, $section);
print dol_get_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), -1, 'dir'); print dol_get_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), -1, 'dir');
if ($action == 'edit') if ($action == 'edit') {
{
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="section" value="'.$section.'">'; print '<input type="hidden" name="section" value="'.$section.'">';
@ -308,23 +302,21 @@ $morehtml = '';
$morehtmlref = '/'.$module.'/'.$relativepath; $morehtmlref = '/'.$module.'/'.$relativepath;
if ($module == 'ecm') if ($module == 'ecm') {
{
$s = ''; $s = '';
$result = 1; $result = 1;
$i = 0; $i = 0;
$tmpecmdir = new EcmDirectory($db); // Need to create a new one $tmpecmdir = new EcmDirectory($db); // Need to create a new one
if ($ecmdir->id > 0) { if ($ecmdir->id > 0) {
$tmpecmdir->fetch($ecmdir->id); $tmpecmdir->fetch($ecmdir->id);
while ($tmpecmdir && $result > 0) while ($tmpecmdir && $result > 0) {
{
$tmpecmdir->ref = $tmpecmdir->label; $tmpecmdir->ref = $tmpecmdir->label;
if ($i == 0 && $action == 'edit') if ($i == 0 && $action == 'edit') {
{
$s = '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">'; $s = '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">';
} else $s = $tmpecmdir->getNomUrl(1).$s; } else {
if ($tmpecmdir->fk_parent) $s = $tmpecmdir->getNomUrl(1).$s;
{ }
if ($tmpecmdir->fk_parent) {
$s = ' -> '.$s; $s = ' -> '.$s;
$result = $tmpecmdir->fetch($tmpecmdir->fk_parent); $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
} else { } else {
@ -337,25 +329,22 @@ if ($module == 'ecm')
} }
$morehtmlref = '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s; $morehtmlref = '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s;
} }
if ($module == 'medias') if ($module == 'medias') {
{
$s = 'medias -> '; $s = 'medias -> ';
$result = 1; $result = 1;
$subdirs = explode('/', $section); $subdirs = explode('/', $section);
$i = 0; $i = 0;
foreach ($subdirs as $subdir) foreach ($subdirs as $subdir) {
{ if ($i == (count($subdirs) - 1)) {
if ($i == (count($subdirs) - 1)) if ($action == 'edit') {
{
if ($action == 'edit')
{
$s .= '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$subdir.'">'; $s .= '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$subdir.'">';
$s .= '<input type="hidden" name="oldrelparentdir" value="'.dirname($section).'">'; $s .= '<input type="hidden" name="oldrelparentdir" value="'.dirname($section).'">';
$s .= '<input type="hidden" name="oldreldir" value="'.basename($section).'">'; $s .= '<input type="hidden" name="oldreldir" value="'.basename($section).'">';
} else $s .= $subdir; } else {
$s .= $subdir;
} }
if ($i < (count($subdirs) - 1)) }
{ if ($i < (count($subdirs) - 1)) {
$s .= $subdir.' -> '; $s .= $subdir.' -> ';
} }
$i++; $i++;
@ -375,15 +364,15 @@ print '<table class="border centpercent tableforfield">';
print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '; print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> ';
print $s; print $s;
print '</td></tr>';*/ print '</td></tr>';*/
if ($module == 'ecm') if ($module == 'ecm') {
{
print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
if ($action == 'edit') if ($action == 'edit') {
{
print '<textarea class="flat quatrevingtpercent" name="description">'; print '<textarea class="flat quatrevingtpercent" name="description">';
print $ecmdir->description; print $ecmdir->description;
print '</textarea>'; print '</textarea>';
} else print dol_nl2br($ecmdir->description); } else {
print dol_nl2br($ecmdir->description);
}
print '</td></tr>'; print '</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans("ECMCreationUser").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("ECMCreationUser").'</td><td>';
@ -395,8 +384,7 @@ if ($module == 'ecm')
print '</td></tr>'; print '</td></tr>';
} }
print '<tr><td class="titlefield">'.$langs->trans("ECMCreationDate").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("ECMCreationDate").'</td><td>';
if ($module == 'ecm') if ($module == 'ecm') {
{
print dol_print_date($ecmdir->date_c, 'dayhour'); print dol_print_date($ecmdir->date_c, 'dayhour');
} else { } else {
//var_dump($upload_dir); //var_dump($upload_dir);
@ -404,8 +392,7 @@ if ($module == 'ecm')
} }
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMDirectoryForFiles").'</td><td>'; print '<tr><td>'.$langs->trans("ECMDirectoryForFiles").'</td><td>';
if ($module == 'ecm') if ($module == 'ecm') {
{
print '/ecm/'.$relativepath; print '/ecm/'.$relativepath;
} else { } else {
print '/'.$module.'/'.$relativepath; print '/'.$module.'/'.$relativepath;
@ -414,11 +401,9 @@ print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>'; print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>';
$nbofiles = count($filearray); $nbofiles = count($filearray);
print $nbofiles; print $nbofiles;
if ($ecmdir->id > 0) if ($ecmdir->id > 0) {
{
// Test if nb is same than in cache // Test if nb is same than in cache
if ($nbofiles != $ecmdir->cachenbofdoc) if ($nbofiles != $ecmdir->cachenbofdoc) {
{
$ecmdir->changeNbOfFiles((string) $nbofiles); $ecmdir->changeNbOfFiles((string) $nbofiles);
} }
} }
@ -429,8 +414,7 @@ print '</td></tr>';
print $object->showOptionals($extrafields, ($action == 'edit' ? 'edit' : 'view')); print $object->showOptionals($extrafields, ($action == 'edit' ? 'edit' : 'view'));
print '</table>'; print '</table>';
if ($action == 'edit') if ($action == 'edit') {
{
print '<br><div align="center">'; print '<br><div align="center">';
print '<input type="submit" class="button button-save" name="submit" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button button-save" name="submit" value="'.$langs->trans("Save").'">';
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';
@ -439,8 +423,7 @@ if ($action == 'edit')
} }
print '</div>'; print '</div>';
if ($action == 'edit') if ($action == 'edit') {
{
print '</form>'; print '</form>';
} }
@ -449,17 +432,14 @@ print dol_get_fiche_end();
// Actions buttons // Actions buttons
if ($action != 'edit' && $action != 'delete') if ($action != 'edit' && $action != 'delete') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($permtoadd) if ($permtoadd) {
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit'.($module ? '&module='.$module : '').'&section='.$section.'">'.$langs->trans('Edit').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit'.($module ? '&module='.$module : '').'&section='.$section.'">'.$langs->trans('Edit').'</a>';
} }
if ($permtoadd) if ($permtoadd) {
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create'.($module ? '&module='.$module : '').'&catParent='.$section.'">'.$langs->trans('ECMAddSection').'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create'.($module ? '&module='.$module : '').'&catParent='.$section.'">'.$langs->trans('ECMAddSection').'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('ECMAddSection').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('ECMAddSection').'</a>';
@ -467,8 +447,7 @@ if ($action != 'edit' && $action != 'delete')
//if (count($filearrayall) == 0) //if (count($filearrayall) == 0)
//{ //{
if ($permtoadd) if ($permtoadd) {
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete_dir&token='.newToken().($module ? '&module='.$module : '').'&section='.$section.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete_dir&token='.newToken().($module ? '&module='.$module : '').'&section='.$section.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.$langs->trans('Delete').'</a>';
} else { } else {
print '<a class="butActionDeleteRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDeleteRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
@ -485,19 +464,16 @@ if ($action != 'edit' && $action != 'delete')
} }
// Confirm remove file // 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'); 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 // Confirm remove file
if ($action == 'delete_dir') if ($action == 'delete_dir') {
{
$relativepathwithoutslash = preg_replace('/[\/]$/', '', $relativepath); $relativepathwithoutslash = preg_replace('/[\/]$/', '', $relativepath);
//Form to close proposal (signed or not) //Form to close proposal (signed or not)
if (count($filearrayall) > 0) if (count($filearrayall) > 0) {
{
$langs->load("other"); $langs->load("other");
$formquestion = array( $formquestion = array(
array('type' => 'checkbox', 'name' => 'deletedirrecursive', 'label' => $langs->trans("ContentOfDirectoryIsNotEmpty").'<br>'.$langs->trans("DeleteAlsoContentRecursively"), 'value' => '0') // Field to complete private note (not replace) array('type' => 'checkbox', 'name' => 'deletedirrecursive', 'label' => $langs->trans("ContentOfDirectoryIsNotEmpty").'<br>'.$langs->trans("DeleteAlsoContentRecursively"), 'value' => '0') // Field to complete private note (not replace)

View File

@ -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")); $langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
// Security check // Security check
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'ecm', 0); $result = restrictedArea($user, 'ecm', 0);
// Get parameters // Get parameters
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$section = GETPOST('section', 'int') ?GETPOST('section', 'int') : GETPOST('section_id', 'int'); $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'); $section_dir = GETPOST('section_dir', 'alpha');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $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; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "fullname"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "fullname";
}
$ecmdir = new EcmDirectory($db); $ecmdir = new EcmDirectory($db);
if ($section > 0) if ($section > 0) {
{
$result = $ecmdir->fetch($section); $result = $ecmdir->fetch($section);
if (!$result > 0) if (!$result > 0) {
{
dol_print_error($db, $ecmdir->error); dol_print_error($db, $ecmdir->error);
exit; exit;
} }
@ -83,21 +91,24 @@ $error = 0;
//include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; //include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
// Upload file (code similar but different than 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 // Define relativepath and upload_dir
$relativepath = ''; $relativepath = '';
if ($ecmdir->id) $relativepath = $ecmdir->getRelativePath(); if ($ecmdir->id) {
else $relativepath = $section_dir; $relativepath = $ecmdir->getRelativePath();
} else {
$relativepath = $section_dir;
}
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath; $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; if (is_array($_FILES['userfile']['tmp_name'])) {
else $userfiles = array($_FILES['userfile']['tmp_name']); $userfiles = $_FILES['userfile']['tmp_name'];
} else {
$userfiles = array($_FILES['userfile']['tmp_name']);
}
foreach ($userfiles as $key => $userfile) foreach ($userfiles as $key => $userfile) {
{ if (empty($_FILES['userfile']['tmp_name'][$key])) {
if (empty($_FILES['userfile']['tmp_name'][$key]))
{
$error++; $error++;
if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) {
setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); 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; $generatethumbs = 0;
$res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', null, '', $generatethumbs); $res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', null, '', $generatethumbs);
if ($res > 0) if ($res > 0) {
{
$result = $ecmdir->changeNbOfFiles('+'); $result = $ecmdir->changeNbOfFiles('+');
} }
} }
} }
// Remove file (code similar but different than actions_linkedfiles.inc.php) // Remove file (code similar but different than actions_linkedfiles.inc.php)
if ($action == 'confirm_deletefile') if ($action == 'confirm_deletefile') {
{ if (GETPOST('confirm') == 'yes') {
if (GETPOST('confirm') == 'yes')
{
// GETPOST('urlfile','alpha') is full relative URL from ecm root dir. Contains path of all sections. // GETPOST('urlfile','alpha') is full relative URL from ecm root dir. Contains path of all sections.
$upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : ''); $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : '');
$file = $upload_dir."/".GETPOST('urlfile', 'alpha'); $file = $upload_dir."/".GETPOST('urlfile', 'alpha');
$ret = dol_delete_file($file); // This include also the delete from file index in database. $ret = dol_delete_file($file); // This include also the delete from file index in database.
if ($ret) if ($ret) {
{
$urlfiletoshow = GETPOST('urlfile', 'alpha'); $urlfiletoshow = GETPOST('urlfile', 'alpha');
$urlfiletoshow = preg_replace('/\.noexe$/', '', $urlfiletoshow); $urlfiletoshow = preg_replace('/\.noexe$/', '', $urlfiletoshow);
setEventMessages($langs->trans("FileWasRemoved", $urlfiletoshow), null, 'mesgs'); setEventMessages($langs->trans("FileWasRemoved", $urlfiletoshow), null, 'mesgs');
@ -144,15 +150,13 @@ if ($action == 'confirm_deletefile')
} }
// Add directory // Add directory
if ($action == 'add' && $user->rights->ecm->setup) if ($action == 'add' && $user->rights->ecm->setup) {
{
$ecmdir->ref = 'NOTUSEDYET'; $ecmdir->ref = 'NOTUSEDYET';
$ecmdir->label = GETPOST("label"); $ecmdir->label = GETPOST("label");
$ecmdir->description = GETPOST("desc"); $ecmdir->description = GETPOST("desc");
$id = $ecmdir->create($user); $id = $ecmdir->create($user);
if ($id > 0) if ($id > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -164,8 +168,7 @@ if ($action == 'add' && $user->rights->ecm->setup)
} }
// Remove directory // Remove directory
if ($action == 'confirm_deletesection' && GETPOST('confirm', 'alpha') == 'yes') if ($action == 'confirm_deletesection' && GETPOST('confirm', 'alpha') == 'yes') {
{
$result = $ecmdir->delete($user); $result = $ecmdir->delete($user);
setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs');
@ -175,8 +178,7 @@ if ($action == 'confirm_deletesection' && GETPOST('confirm', 'alpha') == 'yes')
// Refresh directory view // 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. // 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. // To refresh content of dir with cache, just open the dir in edit mode.
if ($action == 'refreshmanual') if ($action == 'refreshmanual') {
{
$ecmdirtmp = new EcmDirectory($db); $ecmdirtmp = new EcmDirectory($db);
// This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate // 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 // Now we compare both trees to complete missing trees into database
//var_dump($disktree); //var_dump($disktree);
//var_dump($sqltree); //var_dump($sqltree);
foreach ($disktree as $dirdesc) // Loop on tree onto disk foreach ($disktree as $dirdesc) { // Loop on tree onto disk
{
$dirisindatabase = 0; $dirisindatabase = 0;
foreach ($sqltree as $dirsqldesc) foreach ($sqltree as $dirsqldesc) {
{ if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) {
if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname'])
{
$dirisindatabase = 1; $dirisindatabase = 1;
break; break;
} }
} }
if (!$dirisindatabase) if (!$dirisindatabase) {
{
$txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it";
dol_syslog($txt); dol_syslog($txt);
//print $txt."<br>\n"; //print $txt."<br>\n";
@ -219,24 +217,20 @@ if ($action == 'refreshmanual')
$relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']);
$relativepathtosearchparent = $relativepathmissing; $relativepathtosearchparent = $relativepathmissing;
//dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent);
if (preg_match('/\//', $relativepathtosearchparent)) if (preg_match('/\//', $relativepathtosearchparent)) {
//while (preg_match('/\//',$relativepathtosearchparent)) //while (preg_match('/\//',$relativepathtosearchparent))
{
$relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent);
$txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?";
dol_syslog($txt); dol_syslog($txt);
//print $txt." -> "; //print $txt." -> ";
$parentdirisindatabase = 0; $parentdirisindatabase = 0;
foreach ($sqltree as $dirsqldesc) foreach ($sqltree as $dirsqldesc) {
{ if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) {
if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent)
{
$parentdirisindatabase = $dirsqldesc['id']; $parentdirisindatabase = $dirsqldesc['id'];
break; break;
} }
} }
if ($parentdirisindatabase > 0) if ($parentdirisindatabase > 0) {
{
dol_syslog("Yes with id ".$parentdirisindatabase); dol_syslog("Yes with id ".$parentdirisindatabase);
//print "Yes with id ".$parentdirisindatabase."<br>\n"; //print "Yes with id ".$parentdirisindatabase."<br>\n";
$fk_parent = $parentdirisindatabase; $fk_parent = $parentdirisindatabase;
@ -250,8 +244,7 @@ if ($action == 'refreshmanual')
$fk_parent = 0; // Parent is root $fk_parent = 0; // Parent is root
} }
if ($fk_parent >= 0) if ($fk_parent >= 0) {
{
$ecmdirtmp->ref = 'NOTUSEDYET'; $ecmdirtmp->ref = 'NOTUSEDYET';
$ecmdirtmp->label = dol_basename($dirdesc['fullname']); $ecmdirtmp->label = dol_basename($dirdesc['fullname']);
$ecmdirtmp->description = ''; $ecmdirtmp->description = '';
@ -261,8 +254,7 @@ if ($action == 'refreshmanual')
dol_syslog($txt); dol_syslog($txt);
//print $ecmdirtmp->cachenbofdoc."<br>\n";exit; //print $ecmdirtmp->cachenbofdoc."<br>\n";exit;
$id = $ecmdirtmp->create($user); $id = $ecmdirtmp->create($user);
if ($id > 0) if ($id > 0) {
{
$newdirsql = array('id'=>$id, $newdirsql = array('id'=>$id,
'id_mere'=>$ecmdirtmp->fk_parent, 'id_mere'=>$ecmdirtmp->fk_parent,
'label'=>$ecmdirtmp->label, 'label'=>$ecmdirtmp->label,
@ -283,11 +275,9 @@ if ($action == 'refreshmanual')
} }
// Loop now on each sql tree to check if dir exists // 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']; $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename'];
if (!dol_is_dir($dirtotest)) if (!dol_is_dir($dirtotest)) {
{
$ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->id = $dirdesc['id'];
$ecmdirtmp->delete($user, 'databaseonly'); $ecmdirtmp->delete($user, 'databaseonly');
//exit; //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 // 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. // 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();
$morejs = array('includes/jquery/plugins/blockUI/jquery.blockUI.js', 'core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp $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 .= '<script type="text/javascript">'."\n"; $moreheadjs .= '<script type="text/javascript">'."\n";
$moreheadjs .= 'var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n"; $moreheadjs .= 'var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n";

View File

@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts")); $langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
// Security check // Security check
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'ecm', 0); $result = restrictedArea($user, 'ecm', 0);
// Get parameters // Get parameters
@ -42,7 +44,9 @@ $socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$section = GETPOST('section', 'int') ?GETPOST('section', 'int') : GETPOST('section_id', 'int'); $section = GETPOST('section', 'int') ?GETPOST('section', 'int') : GETPOST('section_id', 'int');
$module = GETPOST('module', 'alpha'); $module = GETPOST('module', 'alpha');
if (!$section) $section = 0; if (!$section) {
$section = 0;
}
$section_dir = GETPOST('section_dir', 'alpha'); $section_dir = GETPOST('section_dir', 'alpha');
$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
@ -51,20 +55,26 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $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; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "fullname"; $sortorder = "ASC";
if ($module == 'invoice_supplier' && $sortfield == "fullname") $sortfield = "level1name"; }
if (!$sortfield) {
$sortfield = "fullname";
}
if ($module == 'invoice_supplier' && $sortfield == "fullname") {
$sortfield = "level1name";
}
$ecmdir = new EcmDirectory($db); $ecmdir = new EcmDirectory($db);
if ($section) if ($section) {
{
$result = $ecmdir->fetch($section); $result = $ecmdir->fetch($section);
if (!$result > 0) if (!$result > 0) {
{
dol_print_error($db, $ecmdir->error); dol_print_error($db, $ecmdir->error);
exit; exit;
} }
@ -85,8 +95,7 @@ $error = 0;
$hookmanager->initHooks(array('ecmautocard', 'globalcard')); $hookmanager->initHooks(array('ecmautocard', 'globalcard'));
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
{
$search_doc_ref = ''; $search_doc_ref = '';
} }
@ -94,15 +103,13 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
// Add directory // Add directory
if ($action == 'add' && $user->rights->ecm->setup) if ($action == 'add' && $user->rights->ecm->setup) {
{
$ecmdir->ref = 'NOTUSEDYET'; $ecmdir->ref = 'NOTUSEDYET';
$ecmdir->label = GETPOST("label"); $ecmdir->label = GETPOST("label");
$ecmdir->description = GETPOST("desc"); $ecmdir->description = GETPOST("desc");
$id = $ecmdir->create($user); $id = $ecmdir->create($user);
if ($id > 0) if ($id > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -114,27 +121,28 @@ if ($action == 'add' && $user->rights->ecm->setup)
} }
// Remove file // Remove file
if ($action == 'confirm_deletefile') if ($action == 'confirm_deletefile') {
{ if (GETPOST('confirm') == 'yes') {
if (GETPOST('confirm') == 'yes')
{
$langs->load("other"); $langs->load("other");
if ($section) if ($section) {
{
$result = $ecmdir->fetch($section); $result = $ecmdir->fetch($section);
if (!($result > 0)) if (!($result > 0)) {
{
dol_print_error($db, $ecmdir->error); dol_print_error($db, $ecmdir->error);
exit; exit;
} }
$relativepath = $ecmdir->getRelativePath(); $relativepath = $ecmdir->getRelativePath();
} else $relativepath = ''; } else {
$relativepath = '';
}
$upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : ''); $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : '');
$file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP). $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
$ret = dol_delete_file($file); $ret = dol_delete_file($file);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); if ($ret) {
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
} else {
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
}
$result = $ecmdir->changeNbOfFiles('-'); $result = $ecmdir->changeNbOfFiles('-');
@ -144,8 +152,7 @@ if ($action == 'confirm_deletefile')
} }
// Remove directory // Remove directory
if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') {
{
$result = $ecmdir->delete($user); $result = $ecmdir->delete($user);
setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs');
@ -155,8 +162,7 @@ if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes')
// Refresh directory view // 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. // 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. // To refresh content of dir with cache, just open the dir in edit mode.
if ($action == 'refreshmanual') if ($action == 'refreshmanual') {
{
$ecmdirtmp = new EcmDirectory($db); $ecmdirtmp = new EcmDirectory($db);
// This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate
@ -176,20 +182,16 @@ if ($action == 'refreshmanual')
// Now we compare both trees to complete missing trees into database // Now we compare both trees to complete missing trees into database
//var_dump($disktree); //var_dump($disktree);
//var_dump($sqltree); //var_dump($sqltree);
foreach ($disktree as $dirdesc) // Loop on tree onto disk foreach ($disktree as $dirdesc) { // Loop on tree onto disk
{
$dirisindatabase = 0; $dirisindatabase = 0;
foreach ($sqltree as $dirsqldesc) foreach ($sqltree as $dirsqldesc) {
{ if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) {
if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname'])
{
$dirisindatabase = 1; $dirisindatabase = 1;
break; break;
} }
} }
if (!$dirisindatabase) if (!$dirisindatabase) {
{
$txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it";
dol_syslog($txt); dol_syslog($txt);
//print $txt."<br>\n"; //print $txt."<br>\n";
@ -199,24 +201,20 @@ if ($action == 'refreshmanual')
$relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']);
$relativepathtosearchparent = $relativepathmissing; $relativepathtosearchparent = $relativepathmissing;
//dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent);
if (preg_match('/\//', $relativepathtosearchparent)) if (preg_match('/\//', $relativepathtosearchparent)) {
//while (preg_match('/\//',$relativepathtosearchparent)) //while (preg_match('/\//',$relativepathtosearchparent))
{
$relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent);
$txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?";
dol_syslog($txt); dol_syslog($txt);
//print $txt." -> "; //print $txt." -> ";
$parentdirisindatabase = 0; $parentdirisindatabase = 0;
foreach ($sqltree as $dirsqldesc) foreach ($sqltree as $dirsqldesc) {
{ if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) {
if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent)
{
$parentdirisindatabase = $dirsqldesc['id']; $parentdirisindatabase = $dirsqldesc['id'];
break; break;
} }
} }
if ($parentdirisindatabase > 0) if ($parentdirisindatabase > 0) {
{
dol_syslog("Yes with id ".$parentdirisindatabase); dol_syslog("Yes with id ".$parentdirisindatabase);
//print "Yes with id ".$parentdirisindatabase."<br>\n"; //print "Yes with id ".$parentdirisindatabase."<br>\n";
$fk_parent = $parentdirisindatabase; $fk_parent = $parentdirisindatabase;
@ -230,8 +228,7 @@ if ($action == 'refreshmanual')
$fk_parent = 0; // Parent is root $fk_parent = 0; // Parent is root
} }
if ($fk_parent >= 0) if ($fk_parent >= 0) {
{
$ecmdirtmp->ref = 'NOTUSEDYET'; $ecmdirtmp->ref = 'NOTUSEDYET';
$ecmdirtmp->label = dol_basename($dirdesc['fullname']); $ecmdirtmp->label = dol_basename($dirdesc['fullname']);
$ecmdirtmp->description = ''; $ecmdirtmp->description = '';
@ -241,8 +238,7 @@ if ($action == 'refreshmanual')
dol_syslog($txt); dol_syslog($txt);
//print $ecmdirtmp->cachenbofdoc."<br>\n";exit; //print $ecmdirtmp->cachenbofdoc."<br>\n";exit;
$id = $ecmdirtmp->create($user); $id = $ecmdirtmp->create($user);
if ($id > 0) if ($id > 0) {
{
$newdirsql = array('id'=>$id, $newdirsql = array('id'=>$id,
'id_mere'=>$ecmdirtmp->fk_parent, 'id_mere'=>$ecmdirtmp->fk_parent,
'label'=>$ecmdirtmp->label, 'label'=>$ecmdirtmp->label,
@ -263,11 +259,9 @@ if ($action == 'refreshmanual')
} }
// Loop now on each sql tree to check if dir exists // 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']; $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename'];
if (!dol_is_dir($dirtotest)) if (!dol_is_dir($dirtotest)) {
{
$ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->id = $dirdesc['id'];
$ecmdirtmp->delete($user, 'databaseonly'); $ecmdirtmp->delete($user, 'databaseonly');
//exit; //exit;
@ -280,7 +274,9 @@ if ($action == 'refreshmanual')
// If a directory was added, the fulltree array is not correctly completed and sorted, so we clean // 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. // it to be sure that fulltree array is not used without reloading it.
if ($adirwascreated) $sqltree = null; if ($adirwascreated) {
$sqltree = null;
}
} }
@ -298,7 +294,9 @@ $moreheadjs = '';
//$morejs=array(); //$morejs=array();
$morejs = array('includes/jquery/plugins/blockUI/jquery.blockUI.js', 'core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp $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 .= '<script type="text/javascript">'."\n"; $moreheadjs .= '<script type="text/javascript">'."\n";
$moreheadjs .= 'var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n"; $moreheadjs .= 'var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n";
@ -310,31 +308,63 @@ llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $m
// Add sections to manage // Add sections to manage
$rowspan = 0; $rowspan = 0;
$sectionauto = array(); $sectionauto = array();
if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) {
{ if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts"));
if (!empty($conf->societe->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); } }
if (!empty($conf->propal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); } if (!empty($conf->societe->enabled)) {
if (!empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); } $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
if (!empty($conf->commande->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); } }
if (!empty($conf->facture->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); } if (!empty($conf->propal->enabled)) {
if (!empty($conf->supplier_proposal->enabled)) { $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); } }
if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } if (!empty($conf->contrat->enabled)) {
if (!empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); } $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
if (!empty($conf->projet->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); } }
if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); } if (!empty($conf->commande->enabled)) {
if (!empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); } $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
if (!empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); } }
if (!empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); } if (!empty($conf->facture->enabled)) {
if (!empty($conf->mrp->enabled)) { $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); } $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
if (!empty($conf->recruitment->enabled)) { $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); } }
if (!empty($conf->supplier_proposal->enabled)) {
$langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
}
if (!empty($conf->fournisseur->enabled)) {
$rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
}
if (!empty($conf->fournisseur->enabled)) {
$rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
}
if (!empty($conf->tax->enabled)) {
$langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
}
if (!empty($conf->projet->enabled)) {
$rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
}
if (!empty($conf->ficheinter->enabled)) {
$langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
}
if (!empty($conf->expensereport->enabled)) {
$langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
}
if (!empty($conf->holiday->enabled)) {
$langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
}
if (!empty($conf->banque->enabled)) {
$langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
}
if (!empty($conf->mrp->enabled)) {
$langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
}
if (!empty($conf->recruitment->enabled)) {
$langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
}
$rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users"))); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users")));
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters); $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters);
if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray)>0) if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray)>0) {
{
$sectionauto[]=$hookmanager->resArray; $sectionauto[]=$hookmanager->resArray;
$rowspan += count($hookmanager->resArray); $rowspan += count($hookmanager->resArray);
} }
@ -346,8 +376,7 @@ print dol_get_fiche_head($head, 'index_auto', '', -1, '');
// Confirm remove file (for non javascript users) // Confirm remove file (for non javascript users)
if ($action == 'delete' && empty($conf->use_javascript_ajax)) if ($action == 'delete' && empty($conf->use_javascript_ajax)) {
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1);
} }
@ -378,15 +407,13 @@ print '</div>';
// Confirmation de la suppression d'une ligne categorie // Confirmation de la suppression d'une ligne categorie
if ($action == 'delete_section') if ($action == 'delete_section') {
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1);
} }
// End confirm // End confirm
if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'delete') if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'delete') {
{
print '<table width="100%" class="liste noborderbottom">'."\n"; print '<table width="100%" class="liste noborderbottom">'."\n";
print '<!-- Title for auto directories -->'."\n"; print '<!-- Title for auto directories -->'."\n";
@ -397,8 +424,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $act
$showonrightsize = ''; $showonrightsize = '';
// Auto section // Auto section
if (count($sectionauto)) if (count($sectionauto)) {
{
$htmltooltip = $langs->trans("ECMAreaDesc2"); $htmltooltip = $langs->trans("ECMAreaDesc2");
$sectionauto = dol_sort_array($sectionauto, 'label', 'ASC', true, false); $sectionauto = dol_sort_array($sectionauto, 'label', 'ASC', true, false);
@ -409,15 +435,15 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $act
$nbofentries = 0; $nbofentries = 0;
$oldvallevel = 0; $oldvallevel = 0;
foreach ($sectionauto as $key => $val) foreach ($sectionauto as $key => $val) {
{ if (empty($val['test'])) {
if (empty($val['test'])) continue; // If condition to show is ok continue; // If condition to show is ok
}
$var = false; $var = false;
print '<li class="directory collapsed">'; print '<li class="directory collapsed">';
if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
{
print '<a class="fmdirlia jqft ecmjqft" href="'.$_SERVER["PHP_SELF"].'?module='.$val['module'].'">'; print '<a class="fmdirlia jqft ecmjqft" href="'.$_SERVER["PHP_SELF"].'?module='.$val['module'].'">';
print $val['label']; print $val['label'];
print '</a>'; print '</a>';

View File

@ -33,7 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts")); $langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
// Security check // Security check
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'ecm', ''); $result = restrictedArea($user, 'ecm', '');
// Load permissions // Load permissions
@ -43,12 +45,16 @@ $user->getrights('ecm');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$section = GETPOST('section'); $section = GETPOST('section');
if (!$section) $section = 0; if (!$section) {
$section = 0;
}
$module = GETPOST('module', 'alpha'); $module = GETPOST('module', 'alpha');
$website = GETPOST('website', 'alpha'); $website = GETPOST('website', 'alpha');
$pageid = GETPOST('pageid', 'int'); $pageid = GETPOST('pageid', 'int');
if (empty($module)) $module = 'ecm'; if (empty($module)) {
$module = 'ecm';
}
$upload_dir = $conf->ecm->dir_output.'/'.$section; $upload_dir = $conf->ecm->dir_output.'/'.$section;
@ -56,19 +62,23 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $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; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "label"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "label";
}
$ecmdir = new EcmDirectory($db); $ecmdir = new EcmDirectory($db);
if (!empty($section)) if (!empty($section)) {
{
$result = $ecmdir->fetch($section); $result = $ecmdir->fetch($section);
if (!$result > 0) if (!$result > 0) {
{
dol_print_error($db, $ecmdir->error); dol_print_error($db, $ecmdir->error);
exit; exit;
} }
@ -97,23 +107,57 @@ $userstatic = new User($db);
// Ajout rubriques automatiques // Ajout rubriques automatiques
$rowspan = 0; $rowspan = 0;
$sectionauto = array(); $sectionauto = array();
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
if (!empty($conf->societe->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); } $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts"));
if (!empty($conf->propal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); } }
if (!empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); } if (!empty($conf->societe->enabled)) {
if (!empty($conf->commande->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); } $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
if (!empty($conf->facture->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); } }
if (!empty($conf->supplier_proposal->enabled)) { $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } if (!empty($conf->propal->enabled)) {
if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); } $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } }
if (!empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); } if (!empty($conf->contrat->enabled)) {
if (!empty($conf->projet->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); } $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); } }
if (!empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); } if (!empty($conf->commande->enabled)) {
if (!empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); } $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
if (!empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); } }
if (!empty($conf->mrp->enabled)) { $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); } if (!empty($conf->facture->enabled)) {
if (!empty($conf->recruitment->enabled)) { $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); } $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
}
if (!empty($conf->supplier_proposal->enabled)) {
$langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
}
if (!empty($conf->fournisseur->enabled)) {
$rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
}
if (!empty($conf->fournisseur->enabled)) {
$rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
}
if (!empty($conf->tax->enabled)) {
$langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
}
if (!empty($conf->projet->enabled)) {
$rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
}
if (!empty($conf->ficheinter->enabled)) {
$langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
}
if (!empty($conf->expensereport->enabled)) {
$langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
}
if (!empty($conf->holiday->enabled)) {
$langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
}
if (!empty($conf->banque->enabled)) {
$langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
}
if (!empty($conf->mrp->enabled)) {
$langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
}
if (!empty($conf->recruitment->enabled)) {
$langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
}
//*********************** //***********************
@ -160,9 +204,10 @@ print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
$buthtml = '<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; $buthtml = '<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
$butshown = 0; $butshown = 0;
foreach ($sectionauto as $sectioncur) foreach ($sectionauto as $sectioncur) {
{ if (!$sectioncur['test']) {
if (!$sectioncur['test']) continue; continue;
}
print '<tr class="impair">'; print '<tr class="impair">';
print "<td>".$sectioncur['label'].':</td>'; print "<td>".$sectioncur['label'].':</td>';
print '<td'; print '<td';

View File

@ -19,8 +19,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) if (empty($conf) || !is_object($conf)) {
{
print "Error, template enablefiletreeajax.tpl.php can't be called as URL"; print "Error, template enablefiletreeajax.tpl.php can't be called as URL";
exit; exit;
} }
@ -33,7 +32,9 @@ if (empty($conf) || !is_object($conf))
<script type="text/javascript"> <script type="text/javascript">
<?php <?php
if (empty($module)) $module = 'ecm'; if (empty($module)) {
$module = 'ecm';
}
$paramwithoutsection = preg_replace('/&?section=(\d+)/', '', $param); $paramwithoutsection = preg_replace('/&?section=(\d+)/', '', $param);
$openeddir = '/'; // The root directory shown $openeddir = '/'; // The root directory shown

File diff suppressed because it is too large Load Diff

View File

@ -155,25 +155,24 @@ class EmailCollectorAction extends CommonObject
$this->db = $db; $this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; $this->fields['rowid']['visible'] = 0;
}
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
// Unset fields that are disabled // Unset fields that are disabled
foreach ($this->fields as $key => $val) foreach ($this->fields as $key => $val) {
{ if (isset($val['enabled']) && empty($val['enabled'])) {
if (isset($val['enabled']) && empty($val['enabled']))
{
unset($this->fields[$key]); unset($this->fields[$key]);
} }
} }
// Translate some data of arrayofkeyval // Translate some data of arrayofkeyval
foreach ($this->fields as $key => $val) foreach ($this->fields as $key => $val) {
{ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) foreach ($val['arrayofkeyval'] as $key2 => $val2) {
{
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
$this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
} }
} }
@ -190,8 +189,7 @@ class EmailCollectorAction extends CommonObject
public function create(User $user, $notrigger = false) public function create(User $user, $notrigger = false)
{ {
global $langs; global $langs;
if (empty($this->type)) if (empty($this->type)) {
{
$langs->load("errors"); $langs->load("errors");
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"));
return -1; return -1;
@ -230,14 +228,11 @@ class EmailCollectorAction extends CommonObject
$object->title = $langs->trans("CopyOf")." ".$object->title; $object->title = $langs->trans("CopyOf")." ".$object->title;
// ... // ...
// Clear extrafields that are unique // Clear extrafields that are unique
if (is_array($object->array_options) && count($object->array_options) > 0) if (is_array($object->array_options) && count($object->array_options) > 0) {
{
$extrafields->fetch_name_optionals_label($this->table_element); $extrafields->fetch_name_optionals_label($this->table_element);
foreach ($object->array_options as $key => $option) foreach ($object->array_options as $key => $option) {
{
$shortkey = preg_replace('/options_/', '', $key); $shortkey = preg_replace('/options_/', '', $key);
if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) {
{
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit; //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
unset($object->array_options[$key]); unset($object->array_options[$key]);
} }
@ -275,7 +270,9 @@ class EmailCollectorAction extends CommonObject
public function fetch($id, $ref = null) public function fetch($id, $ref = null)
{ {
$result = $this->fetchCommon($id, $ref); $result = $this->fetchCommon($id, $ref);
if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); if ($result > 0 && !empty($this->table_element_line)) {
$this->fetchLines();
}
return $result; return $result;
} }
@ -333,7 +330,9 @@ class EmailCollectorAction extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = ''; $result = '';
$companylink = ''; $companylink = '';
@ -344,19 +343,20 @@ class EmailCollectorAction extends CommonObject
$url = dol_buildpath('/emailcollector/emailcollectoraction_card.php', 1).'?id='.$this->id; $url = dol_buildpath('/emailcollector/emailcollectoraction_card.php', 1).'?id='.$this->id;
if ($option != 'nolink') if ($option != 'nolink') {
{
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
} }
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowEmailcollectorAction"); $label = $langs->trans("ShowEmailcollectorAction");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
@ -369,15 +369,21 @@ class EmailCollectorAction extends CommonObject
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint; if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/ */
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend = '</a>'; $linkend = '</a>';
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); if ($withpicto) {
if ($withpicto != 2) $result .= $this->ref; $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend; $result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -385,8 +391,11 @@ class EmailCollectorAction extends CommonObject
$hookmanager->initHooks(array('emailcollectoractiondao')); $hookmanager->initHooks(array('emailcollectoractiondao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint; if ($reshook > 0) {
else $result .= $hookmanager->resPrint; $result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }
@ -413,40 +422,47 @@ class EmailCollectorAction extends CommonObject
public function LibStatut($status, $mode = 0) public function LibStatut($status, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
if (empty($this->labelStatus)) if (empty($this->labelStatus)) {
{
global $langs; global $langs;
//$langs->load("emailcollector"); //$langs->load("emailcollector");
$this->labelStatus[1] = $langs->trans('Enabled'); $this->labelStatus[1] = $langs->trans('Enabled');
$this->labelStatus[0] = $langs->trans('Disabled'); $this->labelStatus[0] = $langs->trans('Disabled');
} }
if ($mode == 0) if ($mode == 0) {
{
return $this->labelStatus[$status]; return $this->labelStatus[$status];
} elseif ($mode == 1) } elseif ($mode == 1) {
{
return $this->labelStatus[$status]; return $this->labelStatus[$status];
} elseif ($mode == 2) } elseif ($mode == 2) {
{ if ($status == 1) {
if ($status == 1) return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status];
elseif ($status == 0) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; } elseif ($status == 0) {
} elseif ($mode == 3) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status];
{ }
if ($status == 1) return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 3) {
elseif ($status == 0) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); if ($status == 1) {
} elseif ($mode == 4) return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
{ } elseif ($status == 0) {
if ($status == 1) return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
elseif ($status == 0) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; }
} elseif ($mode == 5) } elseif ($mode == 4) {
{ if ($status == 1) {
if ($status == 1) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status];
elseif ($status == 0) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($status == 0) {
} elseif ($mode == 6) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status];
{ }
if ($status == 1) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 5) {
elseif ($status == 0) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); if ($status == 1) {
return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
} elseif ($status == 0) {
return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
}
} elseif ($mode == 6) {
if ($status == 1) {
return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
} elseif ($status == 0) {
return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
}
} }
} }
@ -463,28 +479,23 @@ class EmailCollectorAction extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id; $sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{ if ($this->db->num_rows($result)) {
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
if ($obj->fk_user_author) if ($obj->fk_user_author) {
{
$cuser = new User($this->db); $cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author); $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser; $this->user_creation = $cuser;
} }
if ($obj->fk_user_valid) if ($obj->fk_user_valid) {
{
$vuser = new User($this->db); $vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid); $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser; $this->user_validation = $vuser;
} }
if ($obj->fk_user_cloture) if ($obj->fk_user_cloture) {
{
$cluser = new User($this->db); $cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture); $cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser; $this->user_cloture = $cluser;

View File

@ -124,25 +124,24 @@ class EmailCollectorFilter extends CommonObject
$this->db = $db; $this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; $this->fields['rowid']['visible'] = 0;
}
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
// Unset fields that are disabled // Unset fields that are disabled
foreach ($this->fields as $key => $val) foreach ($this->fields as $key => $val) {
{ if (isset($val['enabled']) && empty($val['enabled'])) {
if (isset($val['enabled']) && empty($val['enabled']))
{
unset($this->fields[$key]); unset($this->fields[$key]);
} }
} }
// Translate some data of arrayofkeyval // Translate some data of arrayofkeyval
foreach ($this->fields as $key => $val) foreach ($this->fields as $key => $val) {
{ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) foreach ($val['arrayofkeyval'] as $key2 => $val2) {
{
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
$this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
} }
} }
@ -159,14 +158,12 @@ class EmailCollectorFilter extends CommonObject
public function create(User $user, $notrigger = false) public function create(User $user, $notrigger = false)
{ {
global $langs; global $langs;
if (empty($this->type)) if (empty($this->type)) {
{
$langs->load("errors"); $langs->load("errors");
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"));
return -1; return -1;
} }
if (!in_array($this->type, array('seen', 'unseen', 'unanswered', 'answered', 'withtrackingidinmsgid', 'withouttrackingidinmsgid', 'withtrackingid', 'withouttrackingid', 'isanswer', 'isnotanswer')) && empty($this->rulevalue)) if (!in_array($this->type, array('seen', 'unseen', 'unanswered', 'answered', 'withtrackingidinmsgid', 'withouttrackingidinmsgid', 'withtrackingid', 'withouttrackingid', 'isanswer', 'isnotanswer')) && empty($this->rulevalue)) {
{
$langs->load("errors"); $langs->load("errors");
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SearchString")); $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SearchString"));
return -2; return -2;
@ -205,14 +202,11 @@ class EmailCollectorFilter extends CommonObject
$object->title = $langs->trans("CopyOf")." ".$object->title; $object->title = $langs->trans("CopyOf")." ".$object->title;
// ... // ...
// Clear extrafields that are unique // Clear extrafields that are unique
if (is_array($object->array_options) && count($object->array_options) > 0) if (is_array($object->array_options) && count($object->array_options) > 0) {
{
$extrafields->fetch_name_optionals_label($this->table_element); $extrafields->fetch_name_optionals_label($this->table_element);
foreach ($object->array_options as $key => $option) foreach ($object->array_options as $key => $option) {
{
$shortkey = preg_replace('/options_/', '', $key); $shortkey = preg_replace('/options_/', '', $key);
if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) {
{
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit; //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
unset($object->array_options[$key]); unset($object->array_options[$key]);
} }
@ -250,7 +244,9 @@ class EmailCollectorFilter extends CommonObject
public function fetch($id, $ref = null) public function fetch($id, $ref = null)
{ {
$result = $this->fetchCommon($id, $ref); $result = $this->fetchCommon($id, $ref);
if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); if ($result > 0 && !empty($this->table_element_line)) {
$this->fetchLines();
}
return $result; return $result;
} }
@ -308,7 +304,9 @@ class EmailCollectorFilter extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = ''; $result = '';
$companylink = ''; $companylink = '';
@ -319,19 +317,20 @@ class EmailCollectorFilter extends CommonObject
$url = dol_buildpath('/emailcollector/emailcollectorfilter_card.php', 1).'?id='.$this->id; $url = dol_buildpath('/emailcollector/emailcollectorfilter_card.php', 1).'?id='.$this->id;
if ($option != 'nolink') if ($option != 'nolink') {
{
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
} }
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowEmailcollectorFilter"); $label = $langs->trans("ShowEmailcollectorFilter");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
@ -344,15 +343,21 @@ class EmailCollectorFilter extends CommonObject
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint; if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/ */
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend = '</a>'; $linkend = '</a>';
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); if ($withpicto) {
if ($withpicto != 2) $result .= $this->ref; $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend; $result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -360,8 +365,11 @@ class EmailCollectorFilter extends CommonObject
$hookmanager->initHooks(array('emailcollectorfilterdao')); $hookmanager->initHooks(array('emailcollectorfilterdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint; if ($reshook > 0) {
else $result .= $hookmanager->resPrint; $result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }
@ -388,40 +396,47 @@ class EmailCollectorFilter extends CommonObject
public function LibStatut($status, $mode = 0) public function LibStatut($status, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
if (empty($this->labelStatus)) if (empty($this->labelStatus)) {
{
global $langs; global $langs;
//$langs->load("emailcollector"); //$langs->load("emailcollector");
$this->labelStatus[1] = $langs->trans('Enabled'); $this->labelStatus[1] = $langs->trans('Enabled');
$this->labelStatus[0] = $langs->trans('Disabled'); $this->labelStatus[0] = $langs->trans('Disabled');
} }
if ($mode == 0) if ($mode == 0) {
{
return $this->labelStatus[$status]; return $this->labelStatus[$status];
} elseif ($mode == 1) } elseif ($mode == 1) {
{
return $this->labelStatus[$status]; return $this->labelStatus[$status];
} elseif ($mode == 2) } elseif ($mode == 2) {
{ if ($status == 1) {
if ($status == 1) return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status];
elseif ($status == 0) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; } elseif ($status == 0) {
} elseif ($mode == 3) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status];
{ }
if ($status == 1) return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 3) {
elseif ($status == 0) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); if ($status == 1) {
} elseif ($mode == 4) return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
{ } elseif ($status == 0) {
if ($status == 1) return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
elseif ($status == 0) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status]; }
} elseif ($mode == 5) } elseif ($mode == 4) {
{ if ($status == 1) {
if ($status == 1) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); return img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status];
elseif ($status == 0) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); } elseif ($status == 0) {
} elseif ($mode == 6) return img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelStatus[$status];
{ }
if ($status == 1) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 5) {
elseif ($status == 0) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); if ($status == 1) {
return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
} elseif ($status == 0) {
return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
}
} elseif ($mode == 6) {
if ($status == 1) {
return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
} elseif ($status == 0) {
return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
}
} }
} }
@ -438,28 +453,23 @@ class EmailCollectorFilter extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id; $sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{ if ($this->db->num_rows($result)) {
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
if ($obj->fk_user_author) if ($obj->fk_user_author) {
{
$cuser = new User($this->db); $cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author); $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser; $this->user_creation = $cuser;
} }
if ($obj->fk_user_valid) if ($obj->fk_user_valid) {
{
$vuser = new User($this->db); $vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid); $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser; $this->user_validation = $vuser;
} }
if ($obj->fk_user_cloture) if ($obj->fk_user_cloture) {
{
$cluser = new User($this->db); $cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture); $cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser; $this->user_cloture = $cluser;