CommonITILTask::prepareInputForAdd PHP Method

prepareInputForAdd() public method

public prepareInputForAdd ( $input )
    function prepareInputForAdd($input)
    {
        $itemtype = $this->getItilObjectItemType();
        Toolbox::manageBeginAndEndPlanDates($input['plan']);
        if (isset($input["plan"])) {
            $input["begin"] = $input['plan']["begin"];
            $input["end"] = $input['plan']["end"];
            $timestart = strtotime($input["begin"]);
            $timeend = strtotime($input["end"]);
            $input["actiontime"] = $timeend - $timestart;
            unset($input["plan"]);
            if (!$this->test_valid_date($input)) {
                Session::addMessageAfterRedirect(__('Error in entering dates. The starting date is later than the ending date'), false, ERROR);
                return false;
            }
        }
        $input["_job"] = new $itemtype();
        if (!$input["_job"]->getFromDB($input[$input["_job"]->getForeignKeyField()])) {
            return false;
        }
        // Pass old assign From object in case of assign change
        if (isset($input["_old_assign"])) {
            $input["_job"]->fields["_old_assign"] = $input["_old_assign"];
        }
        if (!isset($input["users_id"]) && ($uid = Session::getLoginUserID())) {
            $input["users_id"] = $uid;
        }
        if (!isset($input["date"])) {
            $input["date"] = $_SESSION["glpi_currenttime"];
        }
        if (!isset($input["is_private"])) {
            $input['is_private'] = 0;
        }
        // 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);
        return $input;
    }