diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index b26438fd9e9..1ee9812f4fd 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -240,10 +240,24 @@ class FormSetup
* saveConfFromPost
*
* @param bool $noMessageInUpdate display event message on errors and success
- * @return void|null
+ * @return int -1 if KO, 1 if OK
*/
public function saveConfFromPost($noMessageInUpdate = false)
{
+ global $hookmanager;
+
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('formSetupBeforeSaveConfFromPost', $parameters, $this); // Note that $action and $object may have been modified by some hooks
+ if ($reshook < 0) {
+ $this->setErrors($hookmanager->errors);
+ return -1;
+ }
+
+ if ($reshook > 0) {
+ return $reshook;
+ }
+
+
if (empty($this->items)) {
return null;
}
@@ -265,11 +279,13 @@ class FormSetup
if (empty($noMessageInUpdate)) {
setEventMessages($this->langs->trans("SetupSaved"), null);
}
+ return 1;
} else {
$this->db->rollback();
if (empty($noMessageInUpdate)) {
setEventMessages($this->langs->trans("SetupNotSaved"), null, 'errors');
}
+ return -1;
}
}
@@ -652,8 +668,22 @@ class FormSetupItem
*/
public function saveConfValue()
{
+ global $hookmanager;
+
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('formSetupBeforeSaveConfValue', $parameters, $this); // Note that $action and $object may have been modified by some hooks
+ if ($reshook < 0) {
+ $this->setErrors($hookmanager->errors);
+ return -1;
+ }
+
+ if ($reshook > 0) {
+ return $reshook;
+ }
+
+
if (!empty($this->saveCallBack) && is_callable($this->saveCallBack)) {
- return call_user_func($this->saveCallBack);
+ return call_user_func($this->saveCallBack, $this);
}
// Modify constant only if key was posted (avoid resetting key to the null value)
@@ -1013,6 +1043,7 @@ class FormSetupItem
}
$out.= $this->langs->trans($template->label);
} elseif (preg_match('/category:/', $this->type)) {
+ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$c = new Categorie($this->db);
$result = $c->fetch($this->fieldValue);
if ($result < 0) {