|
@@ -17,7 +17,8 @@
|
|
|
|
|
|
/**
|
|
|
* \file /htdocs/core/ajax/extraparams.php
|
|
|
- * \brief File to make Ajax action on setting extra parameters of elements
|
|
|
+ * \brief File to make Ajax action on setting extra parameters of elements.
|
|
|
+ * Called bu bloc_showhide.tpl.php, itself called when MAIN_DISABLE_CONTACTS_TAB or MAIN_DISABLE_NOTES_TAB are set
|
|
|
*/
|
|
|
|
|
|
if (!defined('NOTOKENRENEWAL')) {
|
|
@@ -39,10 +40,29 @@ if (!defined('NOREQUIRESOC')) {
|
|
|
include '../../main.inc.php';
|
|
|
|
|
|
$id = GETPOST('id', 'int');
|
|
|
-$element = GETPOST('element', 'alpha');
|
|
|
+$element = GETPOST('element', 'aZ09arobase');
|
|
|
$htmlelement = GETPOST('htmlelement', 'alpha');
|
|
|
$type = GETPOST('type', 'alpha');
|
|
|
|
|
|
+// Load object according to $id and $element
|
|
|
+$object = fetchObjectByElement($id, $element);
|
|
|
+
|
|
|
+$module = $object->module;
|
|
|
+$element = $object->element;
|
|
|
+$usesublevelpermission = ($module != $element ? $element : '');
|
|
|
+if ($usesublevelpermission && !isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly
|
|
|
+ $usesublevelpermission = '';
|
|
|
+}
|
|
|
+
|
|
|
+//print $object->id.' - '.$object->module.' - '.$object->element.' - '.$object->table_element.' - '.$usesublevelpermission."\n";
|
|
|
+
|
|
|
+// Security check
|
|
|
+$result = restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission, 'fk_soc', 'rowid', 0, 1); // Call with mode return
|
|
|
+if (!$result) {
|
|
|
+ httponly_accessforbidden('Not allowed by restrictArea');
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
/*
|
|
|
* View
|
|
|
*/
|
|
@@ -57,47 +77,10 @@ if (!empty($id) && !empty($element) && !empty($htmlelement) && !empty($type)) {
|
|
|
|
|
|
dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG);
|
|
|
|
|
|
- $classpath = $subelement = $element;
|
|
|
-
|
|
|
- // For compatibility
|
|
|
- if ($element == 'order' || $element == 'commande') {
|
|
|
- $classpath = $subelement = 'commande';
|
|
|
- } elseif ($element == 'propal') {
|
|
|
- $classpath = 'comm/propal';
|
|
|
- $subelement = 'propal';
|
|
|
- } elseif ($element == 'facture') {
|
|
|
- $classpath = 'compta/facture';
|
|
|
- $subelement = 'facture';
|
|
|
- } elseif ($element == 'contract') {
|
|
|
- $classpath = $subelement = 'contrat';
|
|
|
- } elseif ($element == 'shipping') {
|
|
|
- $classpath = $subelement = 'expedition';
|
|
|
- } elseif ($element == 'deplacement') {
|
|
|
- $classpath = 'compta/deplacement';
|
|
|
- $subelement = 'deplacement';
|
|
|
- } elseif ($element == 'order_supplier') {
|
|
|
- $classpath = 'fourn';
|
|
|
- $subelement = 'fournisseur.commande';
|
|
|
- } elseif ($element == 'invoice_supplier') {
|
|
|
- $classpath = 'fourn';
|
|
|
- $subelement = 'fournisseur.facture';
|
|
|
- }
|
|
|
-
|
|
|
- dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php');
|
|
|
+ if (is_object($object)) {
|
|
|
+ $params[$htmlelement] = array($type => $value);
|
|
|
+ $object->extraparams = array_merge($object->extraparams, $params);
|
|
|
|
|
|
- if ($element == 'order_supplier') {
|
|
|
- $classname = 'CommandeFournisseur';
|
|
|
- } elseif ($element == 'invoice_supplier') {
|
|
|
- $classname = 'FactureFournisseur';
|
|
|
- } else {
|
|
|
- $classname = ucfirst($subelement);
|
|
|
+ $result = $object->setExtraParameters();
|
|
|
}
|
|
|
-
|
|
|
- $object = new $classname($db);
|
|
|
- $object->fetch($id);
|
|
|
-
|
|
|
- $params[$htmlelement] = array($type => $value);
|
|
|
- $object->extraparams = array_merge($object->extraparams, $params);
|
|
|
-
|
|
|
- $result = $object->setExtraParameters();
|
|
|
}
|