CommonITILTask::post_updateItem PHP Method

post_updateItem() public method

public post_updateItem ( $history = 1 )
    function post_updateItem($history = 1)
    {
        global $CFG_GLPI;
        if (in_array("begin", $this->updates)) {
            PlanningRecall::managePlanningUpdates($this->getType(), $this->getID(), $this->fields["begin"]);
        }
        $update_done = false;
        $itemtype = $this->getItilObjectItemType();
        $item = new $itemtype();
        if ($item->getFromDB($this->fields[$item->getForeignKeyField()])) {
            $item->updateDateMod($this->fields[$item->getForeignKeyField()]);
            if (count($this->updates)) {
                $update_done = true;
                if (in_array("actiontime", $this->updates)) {
                    $item->updateActionTime($this->input[$item->getForeignKeyField()]);
                }
                // change ticket status (from splitted button)
                $itemtype = $this->getItilObjectItemType();
                $this->input['_job'] = new $itemtype();
                if (!$this->input['_job']->getFromDB($this->input[$this->input['_job']->getForeignKeyField()])) {
                    return false;
                }
                if (isset($this->input['_status']) && $this->input['_status'] != $this->input['_job']->fields['status']) {
                    $update['status'] = $this->input['_status'];
                    $update['id'] = $this->input['_job']->fields['id'];
                    $update['_disablenotif'] = true;
                    $this->input['_job']->update($update);
                }
                if (!empty($this->fields['begin']) && $item->isStatusExists(CommonITILObject::PLANNED) && ($item->fields["status"] == CommonITILObject::INCOMING || $item->fields["status"] == CommonITILObject::ASSIGNED)) {
                    $input2['id'] = $item->getID();
                    $input2['status'] = CommonITILObject::PLANNED;
                    $input2['_disablenotif'] = true;
                    $item->update($input2);
                }
                if ($CFG_GLPI["use_mailing"]) {
                    $options = array('task_id' => $this->fields["id"], 'is_private' => $this->isPrivate());
                    NotificationEvent::raiseEvent('update_task', $item, $options);
                }
            }
        }
        if ($update_done) {
            // Add log entry in the ITIL object
            $changes[0] = 0;
            $changes[1] = '';
            $changes[2] = $this->fields['id'];
            Log::history($this->getField($item->getForeignKeyField()), $itemtype, $changes, $this->getType(), Log::HISTORY_UPDATE_SUBITEM);
        }
    }