Fix Add doaction hook
This commit is contained in:
parent
d791476708
commit
76bee57553
@ -66,64 +66,72 @@ $extrafields = new ExtraFields($db);
|
|||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
|
||||||
if ($action == 'confirm_add_resource')
|
$hookmanager->initHooks(array('resource_card_add','globalcard'));
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
if (! $cancel)
|
|
||||||
{
|
|
||||||
$error='';
|
|
||||||
|
|
||||||
$ref=GETPOST('ref','alpha');
|
if ($action == 'confirm_add_resource')
|
||||||
$description=GETPOST('description','alpha');
|
{
|
||||||
$fk_code_type_resource=GETPOST('fk_code_type_resource','alpha');
|
if (! $cancel)
|
||||||
|
{
|
||||||
|
$error='';
|
||||||
|
|
||||||
if (empty($ref))
|
$ref=GETPOST('ref','alpha');
|
||||||
{
|
$description=GETPOST('description','alpha');
|
||||||
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
|
$fk_code_type_resource=GETPOST('fk_code_type_resource','alpha');
|
||||||
setEventMessages($mesg, null, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
if (empty($ref))
|
||||||
{
|
{
|
||||||
$object=new Dolresource($db);
|
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
|
||||||
$object->ref=$ref;
|
setEventMessages($mesg, null, 'errors');
|
||||||
$object->description=$description;
|
$error++;
|
||||||
$object->fk_code_type_resource=$fk_code_type_resource;
|
}
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
if (! $error)
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
{
|
||||||
if ($ret < 0) {
|
$object=new Dolresource($db);
|
||||||
$error ++;
|
$object->ref=$ref;
|
||||||
}
|
$object->description=$description;
|
||||||
|
$object->fk_code_type_resource=$fk_code_type_resource;
|
||||||
|
|
||||||
$result=$object->create($user);
|
// Fill array 'array_options' with data from add form
|
||||||
if ($result > 0)
|
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||||
{
|
if ($ret < 0) {
|
||||||
// Creation OK
|
$error ++;
|
||||||
$db->commit();
|
}
|
||||||
setEventMessages($langs->trans('ResourceCreatedWithSuccess'), null, 'mesgs');
|
|
||||||
Header("Location: card.php?id=" . $object->id);
|
$result=$object->create($user);
|
||||||
return;
|
if ($result > 0)
|
||||||
}
|
{
|
||||||
else
|
// Creation OK
|
||||||
{
|
$db->commit();
|
||||||
// Creation KO
|
setEventMessages($langs->trans('ResourceCreatedWithSuccess'), null, 'mesgs');
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
Header("Location: card.php?id=" . $object->id);
|
||||||
$action = '';
|
return;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
// Creation KO
|
||||||
$action = '';
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
$action = '';
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
Header("Location: list.php");
|
{
|
||||||
}
|
$action = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Header("Location: list.php");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user