$redirect = GETPOST('redirect', 'alpha'); $action = GETPOST('action'); if (empty($leadid) || $leadid == -1) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lead")), null, 'errors'); $error++; } if (!$error) { $result = $object->fetch($leadid); if ($result < 0) { setEventMessages(null, $object->errors, 'errors'); $error++; } } if (!$error) { if ($action == 'link') { $result = $object->add_object_linked($tablename, $elementselectid); if ($result < 0) { setEventMessages(null, $object->errors, 'errors'); } } if ($action == 'unlink') { $sourceid = GETPOST('sourceid'); $sourcetype = GETPOST('sourcetype'); $result = $object->deleteObjectLinked($sourceid, $sourcetype); if ($result < 0) { setEventMessages(null, $object->errors, 'errors'); } } } header("Location:" . $redirect); exit;