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.= " WHERE fk_object=" . $this->id;
@ -6469,7 +6469,7 @@ abstract class CommonObject
$this->errors[] = $this->db->lasterror();
$error++;
}
}*/
}
if (! $error)
{

View File

@ -41,9 +41,13 @@ class MyObject extends CommonObject
*/
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;
/**
* @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
*/

View File

@ -235,7 +235,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = '';
// 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);
}

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.
{
@ -656,6 +647,8 @@ if ($action == 'addcontainer')
// Delete page
if ($action == 'delete')
{
$error = 0;
$db->begin();
$res = $object->fetch(0, $website);
@ -665,27 +658,24 @@ if ($action == 'delete')
if ($res > 0)
{
$res = $objectpage->delete($user);
if (! $res > 0)
if ($res <= 0)
{
$error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
exit;
}
else
{
$db->rollback();
}
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
exit;
}
else
{
$db->rollback();
dol_print_error($db);
}
}