Fix delete when no extrafields used

This commit is contained in:
Laurent Destailleur 2018-02-15 00:01:25 +01:00
parent 5f0f9ff326
commit b515448bbd
4 changed files with 20 additions and 25 deletions

View File

@ -6458,7 +6458,7 @@ abstract class CommonObject
} }
} }
/*if (! $error) if (! $error && ! empty($this->isextrafieldmanaged))
{ {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element."_extrafields"; $sql = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element."_extrafields";
$sql.= " WHERE fk_object=" . $this->id; $sql.= " WHERE fk_object=" . $this->id;
@ -6469,7 +6469,7 @@ abstract class CommonObject
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
$error++; $error++;
} }
}*/ }
if (! $error) if (! $error)
{ {

View File

@ -41,9 +41,13 @@ class MyObject extends CommonObject
*/ */
public $table_element = 'mymodule_myobject'; public $table_element = 'mymodule_myobject';
/** /**
* @var array Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/ */
public $ismultientitymanaged = 0; public $ismultientitymanaged = 0;
/**
* @var int Does myobject support extrafields ? 0=No, 1=Yes
*/
public $isextrafieldmanaged = 1;
/** /**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/ */

View File

@ -235,7 +235,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = ''; $formconfirm = '';
// Confirmation to delete // Confirmation to delete
if ($action == 'delete') { if ($action == 'delete')
{
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
} }

View File

@ -188,15 +188,6 @@ if ($action == 'adddir' && $permtouploadfile)
} }
*/ */
// Remove directory
if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes')
{
//$result=$ecmdir->delete($user);
setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs');
clearstatcache();
}
if (GETPOST('refreshsite')) // If we change the site, we reset the pageid and cancel addsite action. if (GETPOST('refreshsite')) // If we change the site, we reset the pageid and cancel addsite action.
{ {
@ -656,6 +647,8 @@ if ($action == 'addcontainer')
// Delete page // Delete page
if ($action == 'delete') if ($action == 'delete')
{ {
$error = 0;
$db->begin(); $db->begin();
$res = $object->fetch(0, $website); $res = $object->fetch(0, $website);
@ -665,27 +658,24 @@ if ($action == 'delete')
if ($res > 0) if ($res > 0)
{ {
$res = $objectpage->delete($user); $res = $objectpage->delete($user);
if (! $res > 0) if ($res <= 0)
{ {
$error++; $error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors'); setEventMessages($objectpage->error, $objectpage->errors, 'errors');
} }
}
if (! $error) if (! $error)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs'); setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website); header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
exit; exit;
}
else
{
$db->rollback();
}
} }
else else
{ {
$db->rollback();
dol_print_error($db); dol_print_error($db);
} }
} }