From 3081d463fdc06a4b0be017fbaa1d026b8ac71704 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 28 Feb 2006 07:40:43 +0000 Subject: [PATCH] Added rename dialog for glpi edit OS / Types git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2758 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_glpiAccount.inc | 65 ++++++++++++++++++--- plugins/admin/systems/glpi_edit_os.tpl | 27 ++++++--- plugins/admin/systems/glpi_edit_type.tpl | 12 ++++ 3 files changed, 89 insertions(+), 15 deletions(-) diff --git a/plugins/admin/systems/class_glpiAccount.inc b/plugins/admin/systems/class_glpiAccount.inc index 1aa1a4b6a..617b8f9b3 100644 --- a/plugins/admin/systems/class_glpiAccount.inc +++ b/plugins/admin/systems/class_glpiAccount.inc @@ -36,6 +36,10 @@ class glpiAccount extends plugin var $FK_glpi_enterprise = 0; // Manufacturer id var $deleted = "N"; // Deleted entries should have this set to Y + var $renameTypeDialog = false; + var $renameOSDialog = false; + var $select_type ; + /* Not necessary, cause we use mysql databse */ var $objectclasses= array("whatever"); @@ -275,6 +279,11 @@ class glpiAccount extends plugin $this->dialog = false; } + if(isset($_POST['Rename_Cancel'])){ + $this->renameTypeDialog = false; + $this->renameOSDialog = false; + } + /* This appends a new system to our sytem types */ if((isset($_POST['add_type']))&&(!empty($_POST['type_string']))){ @@ -308,19 +317,40 @@ class glpiAccount extends plugin /* Rename selected system type to given string */ - if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))&&(!empty($_POST['type_string']))){ + if(isset($_POST['Rename_type_OK'])){ $attr = $this->handle->getSystemTypes(); - if(in_array(trim($_POST['type_string']),$attr)){ + if(in_array(trim($_POST['string']),$attr)){ print_red(_("Rename failed, this system type name is already used.")) ; }else{ - $this->handle->updateSystemType($_POST['type_string'],trim($_POST['select_type'])); + $this->renameTypeDialog = false; + $this->handle->updateSystemType($_POST['string'],trim($this->select_type)); } } + + + if((isset($_POST['rename_type'])&&(!empty($_POST['select_type'])))||($this->renameTypeDialog)){ + if(isset($_POST['select_type'])){ + $this->select_type = $_POST['select_type']; + } + $this->renameTypeDialog = true; + $tmp = $this->handle->getSystemTypes(); + + $smarty->assign("string",$tmp[$this->select_type]); + if(isset($_POST['string'])){ + $smarty->assign("string",$_POST['string']); + } + $smarty->assign("Method","rename"); + $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE)); + return($display); + } + + /* Someone wants to edit the system types ... So, lets open a new dialog which provides some buttons to edit the types */ if($this->edit_type){ + $smarty->assign("Method","edit"); $smarty->assign("SystemTypes", $this->handle->getSystemTypes()); $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes())); $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE)); @@ -377,24 +407,43 @@ class glpiAccount extends plugin /* Rename selected os to given string */ - if((isset($_POST['rename_os']))&&(!empty($_POST['select_os']))&&(!empty($_POST['is_string']))){ + if(isset($_POST['Rename_os_OK'])){ $attr = $this->handle->getOSTypes(); - if(in_array(trim($_POST['is_string']),$attr)){ + if(in_array(trim($_POST['string']),$attr)){ print_red(_("Updating operating system failed, specifed name is already used.")) ; }else{ - $this->handle->updateOS($_POST['is_string'],$_POST['select_os']); + $this->handle->updateOS($_POST['string'],$this->select_type); + $this->renameOSDialog = false; + } + } + if((isset($_POST['rename_os'])&&(!empty($_POST['select_os'])))||($this->renameOSDialog)){ + if(isset($_POST['select_os'])){ + $this->select_type = $_POST['select_os']; } + $this->renameOSDialog = true; + $tmp = $this->handle->getOSTypes(); + + $smarty->assign("string",$tmp[$this->select_type]); + if(isset($_POST['string'])){ + $smarty->assign("string",$_POST['string']); + } + $smarty->assign("Method","rename"); + $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE)); + return($display); } /* Open dialog to edit os types */ if($this->edit_os){ - $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes())); - $smarty->assign("OSs", $this->handle->getOSTypes()); + $smarty->assign("Method","edit"); + $smarty->assign("OSs", $this->handle->getOSTypes()); + $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes())); $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE)); return($display); } + + /* Show dialog to select a new contact person * Select a contact person */ diff --git a/plugins/admin/systems/glpi_edit_os.tpl b/plugins/admin/systems/glpi_edit_os.tpl index 6db21ce60..6ccdb09c8 100644 --- a/plugins/admin/systems/glpi_edit_os.tpl +++ b/plugins/admin/systems/glpi_edit_os.tpl @@ -1,11 +1,13 @@

{t}Manage OS-types{/t}

-
- - - - +{if $Method == "edit"} + +
+ + + +

 

@@ -13,6 +15,17 @@

+{else} +{t}Please enter a new name{/t}  +

 

+

+

+ + +
+

+{/if} +