diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6a1ef4b0004..60e491162f2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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) { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 616b7ec495d..e40b6b178e6 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -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 */ diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 94123008244..68cefa714c3 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -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); } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index f57d28a2acb..26c4243d382 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -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); } }