function initForm($ID, array $options = array())
{
if (isset($options['withtemplate']) && $options['withtemplate'] == 2 && !$this->isNewID($ID)) {
// Create item from template
// Check read right on the template
$this->check($ID, READ);
// Restore saved input or template data
$input = $this->restoreInput($this->fields);
// If entity assign force current entity to manage recursive templates
if ($this->isEntityAssign()) {
$input['entities_id'] = $_SESSION['glpiactive_entity'];
}
// Check create right
$this->check(-1, CREATE, $input);
} else {
if ($this->isNewID($ID)) {
// Restore saved input if available
$input = $this->restoreInput($options);
// Create item
$this->check(-1, CREATE, $input);
} else {
// Existing item
$this->check($ID, READ);
}
}
return isset($options['withtemplate']) ? $options['withtemplate'] : '';
}