From 3acaa86e7054c3b16026214b5e53fe202436db1a Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 28 Feb 2006 07:58:43 +0000 Subject: [PATCH] Added rename dialog git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2759 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/class_glpiPrinterAccount.inc | 55 +++++++++++++++---- .../admin/systems/glpi_edit_printer_type.tpl | 31 ++++++++--- 2 files changed, 65 insertions(+), 21 deletions(-) diff --git a/plugins/admin/systems/class_glpiPrinterAccount.inc b/plugins/admin/systems/class_glpiPrinterAccount.inc index c6185e46c..abaa32acb 100644 --- a/plugins/admin/systems/class_glpiPrinterAccount.inc +++ b/plugins/admin/systems/class_glpiPrinterAccount.inc @@ -39,6 +39,9 @@ class glpiPrinterAccount extends plugin var $contact = ""; // Empty var $deleted = "N"; // Deleted entries should have this set to Y + var $rename = false; + var $select_type ; + var $editManufacturer = false; /* Not necessary, cause we use mysql databse */ @@ -207,6 +210,29 @@ class glpiPrinterAccount extends plugin * Dialog */ + /* Rename was requested */ + if(isset($_POST['Rename_PType_OK'])){ + $tmp = $this->handle->getPrinterTypes(); + $allok = true; + foreach($tmp as $id => $name){ + if(trim($name) == trim($_POST['string'])){ + $allok = false; + } + } + if($allok){ + $this->handle->updatePrinterType($_POST['string'],$this->select_type); + $this->rename = false; + }else{ + print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['string'])); + } + } + + /* abort rename + */ + if(isset($_POST['Rename_Cancel'])){ + $this->rename = false; + } + /* Printer type management */ if(isset($_POST['edit_type'])){ @@ -257,25 +283,30 @@ class glpiPrinterAccount extends plugin /* Rename selected printer type to given string */ - if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))&&(!empty($_POST['type_string']))){ + if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename)){ + $this->rename = true; + + $smarty->assign("Method","rename"); + $tmp = $this->handle->getPrinterTypes(); - $allok = true; - foreach($tmp as $id => $name){ - if(trim($name) == trim($_POST['type_string'])){ - $allok = false; - } - } - if($allok){ - $this->handle->updatePrinterType($_POST['type_string'],$_POST['select_type']); - }else{ - print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['type_string'])); + + if(isset($_POST['select_type'])){ + $this->select_type = $_POST['select_type']; + } + $smarty->assign("string",$tmp[$this->select_type]); + if(isset($_POST['string'])){ + $smarty->assign("string",$_POST['string']); } - } + + $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE)); + return($display); + } /* Someone wants to edit the printer 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("PrinterTypes", $this->handle->getPrinterTypes()); $smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes())); $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE)); diff --git a/plugins/admin/systems/glpi_edit_printer_type.tpl b/plugins/admin/systems/glpi_edit_printer_type.tpl index 108a6c2a7..3e3bf2d3a 100644 --- a/plugins/admin/systems/glpi_edit_printer_type.tpl +++ b/plugins/admin/systems/glpi_edit_printer_type.tpl @@ -1,18 +1,31 @@
-
+{if $Method == "edit"} +
-

 

-
-

- -

-
+

 

+
+

+ +

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

 

+

+

+ + +
+

+{/if} +