FIX Can delete a directory created manually that can not be indexed
This commit is contained in:
parent
d1d4914684
commit
6421f757dc
@ -345,7 +345,7 @@ class EcmDirectory extends CommonObject
|
|||||||
$sql .= " t.date_c as date_c,";
|
$sql .= " t.date_c as date_c,";
|
||||||
$sql .= " t.tms as date_m";
|
$sql .= " t.tms as date_m";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
|
$sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
|
||||||
$sql .= " WHERE t.rowid = ".$id;
|
$sql .= " WHERE t.rowid = ".((int) $id);
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|||||||
@ -54,7 +54,7 @@ $pagenext = $page + 1;
|
|||||||
if (!$sortorder) $sortorder = "ASC";
|
if (!$sortorder) $sortorder = "ASC";
|
||||||
if (!$sortfield) $sortfield = "name";
|
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");
|
||||||
@ -66,15 +66,15 @@ $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
|
||||||
$result = $ecmdir->fetch($section);
|
$result = $ecmdir->fetch($section);
|
||||||
if (!$result > 0)
|
if ($result > 0) {
|
||||||
{
|
$relativepath = $ecmdir->getRelativePath();
|
||||||
dol_print_error($db, $ecmdir->error);
|
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
|
||||||
exit;
|
} else {
|
||||||
|
$relativepath = $section;
|
||||||
|
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
$relativepath = $ecmdir->getRelativePath();
|
|
||||||
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
|
|
||||||
} else // For example $module == 'medias'
|
} else // For example $module == 'medias'
|
||||||
{
|
{
|
||||||
$relativepath = $section;
|
$relativepath = $section;
|
||||||
@ -143,28 +143,23 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove dir
|
// Remove dir
|
||||||
if ($action == 'confirm_deletedir' && $confirm == 'yes')
|
if ($action == 'confirm_deletedir' && $confirm == 'yes') {
|
||||||
{
|
|
||||||
$backtourl = DOL_URL_ROOT."/ecm/index.php";
|
$backtourl = DOL_URL_ROOT."/ecm/index.php";
|
||||||
if ($module == 'medias')
|
if ($module == 'medias') {
|
||||||
{
|
|
||||||
$backtourl = DOL_URL_ROOT."/website/index.php?file_manager=1";
|
$backtourl = DOL_URL_ROOT."/website/index.php?file_manager=1";
|
||||||
}
|
}
|
||||||
|
|
||||||
$deletedirrecursive = (GETPOST('deletedirrecursive', 'alpha') == 'on' ? 1 : 0);
|
$deletedirrecursive = (GETPOST('deletedirrecursive', 'alpha') == 'on' ? 1 : 0);
|
||||||
|
|
||||||
if ($module == 'ecm')
|
if ($module == 'ecm' && $ecmdir->id > 0) { // If manual ECM and directory is indexed into database
|
||||||
{
|
|
||||||
// Fetch was already done
|
// Fetch was already done
|
||||||
$result = $ecmdir->delete($user, 'all', $deletedirrecursive);
|
$result = $ecmdir->delete($user, 'all', $deletedirrecursive);
|
||||||
if ($result <= 0)
|
if ($result <= 0) {
|
||||||
{
|
|
||||||
$langs->load('errors');
|
$langs->load('errors');
|
||||||
setEventMessages($langs->trans($ecmdir->error, $ecmdir->label), null, 'errors');
|
setEventMessages($langs->trans($ecmdir->error, $ecmdir->label), null, 'errors');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($deletedirrecursive)
|
if ($deletedirrecursive) {
|
||||||
{
|
|
||||||
$resbool = dol_delete_dir_recursive($upload_dir, 0, 1);
|
$resbool = dol_delete_dir_recursive($upload_dir, 0, 1);
|
||||||
} else {
|
} else {
|
||||||
$resbool = dol_delete_dir($upload_dir, 1);
|
$resbool = dol_delete_dir($upload_dir, 1);
|
||||||
@ -176,8 +171,7 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes')
|
|||||||
$result = 0;
|
$result = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
header("Location: ".$backtourl);
|
header("Location: ".$backtourl);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -269,10 +263,9 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha'))
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
/*******************************************************************
|
* View
|
||||||
* View
|
*/
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
@ -281,9 +274,7 @@ $extrafields = new ExtraFields($db);
|
|||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
|
||||||
|
if ($module == 'ecm' && $ecmdir->id > 0) {
|
||||||
if ($module == 'ecm')
|
|
||||||
{
|
|
||||||
$object->fetch($ecmdir->id);
|
$object->fetch($ecmdir->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,24 +314,27 @@ if ($module == 'ecm')
|
|||||||
$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
|
||||||
$tmpecmdir->fetch($ecmdir->id);
|
if ($ecmdir->id > 0) {
|
||||||
while ($tmpecmdir && $result > 0)
|
$tmpecmdir->fetch($ecmdir->id);
|
||||||
{
|
while ($tmpecmdir && $result > 0)
|
||||||
$tmpecmdir->ref = $tmpecmdir->label;
|
|
||||||
if ($i == 0 && $action == 'edit')
|
|
||||||
{
|
{
|
||||||
$s = '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">';
|
$tmpecmdir->ref = $tmpecmdir->label;
|
||||||
} else $s = $tmpecmdir->getNomUrl(1).$s;
|
if ($i == 0 && $action == 'edit')
|
||||||
if ($tmpecmdir->fk_parent)
|
{
|
||||||
{
|
$s = '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">';
|
||||||
$s = ' -> '.$s;
|
} else $s = $tmpecmdir->getNomUrl(1).$s;
|
||||||
$result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
|
if ($tmpecmdir->fk_parent)
|
||||||
} else {
|
{
|
||||||
$tmpecmdir = 0;
|
$s = ' -> '.$s;
|
||||||
|
$result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
|
||||||
|
} else {
|
||||||
|
$tmpecmdir = 0;
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
$i++;
|
} else {
|
||||||
|
$s .= join(' -> ', explode('/', $section));
|
||||||
}
|
}
|
||||||
|
|
||||||
$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')
|
||||||
@ -393,9 +387,11 @@ if ($module == 'ecm')
|
|||||||
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>';
|
||||||
$userecm = new User($db);
|
if ($ecmdir->fk_user_c > 0) {
|
||||||
$userecm->fetch($ecmdir->fk_user_c);
|
$userecm = new User($db);
|
||||||
print $userecm->getNomUrl(1);
|
$userecm->fetch($ecmdir->fk_user_c);
|
||||||
|
print $userecm->getNomUrl(1);
|
||||||
|
}
|
||||||
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>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user