function prepareInputForAdd($input)
{
global $CFG_GLPI;
$input["_job"] = new Ticket();
if (empty($input['content']) && !isset($input['add_close']) && !isset($input['add_reopen'])) {
Session::addMessageAfterRedirect(__("You can't add a followup without description"), false, ERROR);
return false;
}
if (!$input["_job"]->getFromDB($input["tickets_id"])) {
return false;
}
if ($CFG_GLPI["use_rich_text"]) {
$input['content'] = $input["_job"]->setSimpleTextContent($input["content"]);
}
// Manage File attached (from mailgate)
// Pass filename if set to ticket
if (isset($input['_filename'])) {
$input["_job"]->input['_filename'] = $input['_filename'];
}
// Add docs without notif
$docadded = $input["_job"]->addFiles(0, 1);
if (count($docadded) > 0) {
$input['content'] .= "\n";
foreach ($docadded as $name) {
//TRANS: %s is tha document name
$input['content'] .= "\n" . sprintf(__('Added document: %s'), Toolbox::addslashes_deep($name['data']));
}
}
// Pass old assign From Ticket in case of assign change
// if (isset($input["_old_assign"])) {
// $input["_job"]->fields["_old_assign"] = $input["_old_assign"];
// }
// if (!isset($input["type"])) {
// $input["type"] = "followup";
// }
// $input["_type"] = $input["type"];
// unset($input["type"]);
$input['_close'] = 0;
if (!isset($input["users_id"])) {
$input["users_id"] = 0;
if ($uid = Session::getLoginUserID()) {
$input["users_id"] = $uid;
}
}
// if ($input["_isadmin"] && $input["_type"]!="update") {
if (isset($input["add_close"])) {
$input['_close'] = 1;
if (empty($input['content'])) {
$input['content'] = __('Solution approved');
}
}
unset($input["add_close"]);
if (!isset($input["is_private"])) {
$input['is_private'] = 0;
}
if (isset($input["add_reopen"])) {
if ($input["content"] == '') {
if (isset($input["_add"])) {
// Reopen using add form
Session::addMessageAfterRedirect(__('If you want to reopen the ticket, you must specify a reason'), false, ERROR);
} else {
// Refuse solution
Session::addMessageAfterRedirect(__('If you reject the solution, you must specify a reason'), false, ERROR);
}
return false;
}
$input['_reopen'] = 1;
}
unset($input["add_reopen"]);
// }
unset($input["add"]);
$input["date"] = $_SESSION["glpi_currenttime"];
return $input;
}