diff --git a/include/class_objects.inc b/include/class_objects.inc index aaf4945b07e25a4deb218b9b4de13992f2bb7cc8..9692f425c8260a0f5b2db61d4680cc7efdbde4d2 100644 --- a/include/class_objects.inc +++ b/include/class_objects.inc @@ -391,6 +391,22 @@ class objects return static::open('new', $type); } + static function createTemplate ($type) + { + $infos = static::infos($type); + $tabClass = $infos['tabClass']; + + /* Pass fake attrs object to force template mode */ + $attrsObject = new stdClass(); + $attrsObject->attrs = []; + $attrsObject->is_template = TRUE; + + $tabObject = new $tabClass($type, 'new', $attrsObject); + @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Create template of $type"); + + return $tabObject; + } + static function &infos ($type) { global $config; diff --git a/include/management/class_management.inc b/include/management/class_management.inc index 289fc914d7feacf5d42a0e880691e455c5a2a672..0bb9b11119ac7c09b98ec4b8c04019a9f19cf284 100644 --- a/include/management/class_management.inc +++ b/include/management/class_management.inc @@ -722,9 +722,15 @@ class management if (static::$skipTemplates) { return; } - $action['subaction'] = preg_replace('/^template_/', '', $action['subaction']); - $this->newEntry($action); - $this->tabObject->setTemplateMode('template_cn'); + $type = preg_replace('/^template_/', '', $action['subaction']); + + $this->currentDn = 'new'; + + set_object_info($this->currentDn); + + // Open object + $this->openTabObject(objects::createTemplate($type)); + @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->currentDn, 'Create template entry initiated'); } function newEntryFromTemplate (array $action)