Clsoe #13464 Try implementation to allow use of objectonoff for most

modules.
This commit is contained in:
Laurent Destailleur 2020-04-13 15:12:26 +02:00
parent 4ab3bf99ec
commit ceab7f9ce3

View File

@ -39,9 +39,13 @@ $element = GETPOST('element', 'alpha');
$object = new GenericObject($db);
// Security check
if (!empty($user->socid))
if (!empty($user->socid)) {
$socid = $user->socid;
}
if (empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
accessforbidden('Calling this file is allowed only when MAIN_DIRECT_STATUS_UPDATE is set');
}
/*
@ -52,20 +56,27 @@ top_httphead();
print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
if ($element == 'societe' && in_array($field, array('status')))
{
$result = restrictedArea($user, 'societe', $id);
}
elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch')))
if ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) // Special case for products
{
$result = restrictedArea($user, 'produit|service', $id, 'product&product', '', '', 'rowid');
}
else
{
accessforbidden("Bad value for combination of parameters element/field.", 0, 0, 1);
exit;
if (in_array($field, array('status'))) {
$result = restrictedArea($user, $element, $id);
} else {
accessforbidden("Bad value for combination of parameters element/field.", 0, 0, 1);
exit;
}
}
// Registering new values
if (($action == 'set') && !empty($id))
$object->setValueFrom($field, $value, $element, $id);
if (($action == 'set') && !empty($id)) {
$triggerkey = strtoupper($element).'_UPDATE';
// Special case
if ($triggerkey == 'SOCIETE_UPDATE') {
$triggerkey = 'COMPANY_UPDATE';
}
$object->setValueFrom($field, $value, $element, $id, $user, $triggerkey);
}