function prepareInputForAdd($input)
{
// Clean values
$input['tickets_id_1'] = Toolbox::cleanInteger($input['tickets_id_1']);
$input['tickets_id_2'] = Toolbox::cleanInteger($input['tickets_id_2']);
// Check of existance of rights on both Ticket(s) is done by the parent
if ($input['tickets_id_2'] == $input['tickets_id_1']) {
return false;
}
if (!isset($input['link'])) {
$input['link'] = self::LINK_TO;
}
// No multiple links
$tickets = self::getLinkedTicketsTo($input['tickets_id_1']);
if (count($tickets)) {
foreach ($tickets as $key => $t) {
if ($t['tickets_id'] == $input['tickets_id_2']) {
// Delete old simple link
if ($input['link'] == self::DUPLICATE_WITH && $t['link'] == self::LINK_TO) {
$tt = new Ticket_Ticket();
$tt->delete(array("id" => $key));
} else {
// No duplicate link
return false;
}
}
}
}
return parent::prepareInputForAdd($input);
}