function prepareInputForAdd($input)
 {
     global $LANG;
     manageBeginAndEndPlanDates($input['plan']);
     //      $input["_isadmin"] = haveRight("global_add_tasks","1");
     $input["_job"] = new Ticket();
     if (!$input["_job"]->getFromDB($input["tickets_id"])) {
         return false;
     }
     // 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;
     unset($input["add"]);
     if (!isset($input["users_id"]) && ($uid = getLoginUserID())) {
         $input["users_id"] = $uid;
     }
     //      if ($input["_isadmin"] && $input["_type"]!="update") {
     if (isset($input['plan'])) {
         $input['_plan'] = $input['plan'];
         unset($input['plan']);
     }
     /* not used for task
           if (isset($input["add_close"])) {
              $input['_close'] = 1;
              unset($input["add_close"]);
           }
           if (isset($input["add_reopen"])) {
              $input['_reopen'] = 1;
              unset($input["add_reopen"]);
           }
     */
     if (!isset($input["hour"])) {
         $input["hour"] = 0;
     }
     if (!isset($input["minute"])) {
         $input["minute"] = 0;
     }
     if ($input["hour"] > 0 || $input["minute"] > 0) {
         $input["actiontime"] = $input["hour"] * HOUR_TIMESTAMP + $input["minute"] * MINUTE_TIMESTAMP;
     }
     //      }
     unset($input["minute"]);
     unset($input["hour"]);
     $input["date"] = $_SESSION["glpi_currenttime"];
     return $input;
 }
 function prepareInputForUpdate($input)
 {
     global $LANG;
     manageBeginAndEndPlanDates($input['plan']);
     $input["name"] = trim($input["name"]);
     if (empty($input["name"])) {
         $input["name"] = $LANG['reminder'][15];
     }
     if (isset($input['plan'])) {
         if (!empty($input['plan']["begin"]) && !empty($input['plan']["end"]) && $input['plan']["begin"] < $input['plan']["end"]) {
             $input['_plan'] = $input['plan'];
             unset($input['plan']);
             $input['is_planned'] = 1;
             $input["begin"] = $input['_plan']["begin"];
             $input["end"] = $input['_plan']["end"];
             $input["state"] = $input['_plan']["state"];
         } else {
             addMessageAfterRedirect($LANG['planning'][1], false, ERROR);
         }
     }
     if (isset($input['is_helpdesk_visible']) && $input['is_helpdesk_visible'] && (!isset($input['is_private']) || $input['is_private'])) {
         unset($input['is_helpdesk_visible']);
     }
     if (isset($input['is_recursive']) && $input['is_recursive'] && !$input['is_private']) {
         if (!haveRecursiveAccessToEntity($input["entities_id"])) {
             unset($input['is_recursive']);
             addMessageAfterRedirect($LANG['common'][75], false, ERROR);
         }
     }
     return $input;
 }