Code

Added rename dialog for glpi edit OS / Types
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Feb 2006 07:40:43 +0000 (07:40 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Feb 2006 07:40:43 +0000 (07:40 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2758 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_glpiAccount.inc
plugins/admin/systems/glpi_edit_os.tpl
plugins/admin/systems/glpi_edit_type.tpl

index 1aa1a4b6a1f3443e10e77c500c932c4b300d2dc9..617b8f9b3081134e690b09f7c59e496f3da5f64e 100644 (file)
@@ -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
      */
index 6db21ce609aa488d11c0bf4b32300779f9701b44..6ccdb09c8034af735a04474a999e15a2b9f25a39 100644 (file)
@@ -1,11 +1,13 @@
 <h2>{t}Manage OS-types{/t}</h2>
-<select name="select_os" size="12" style="width:100%">
-                   {html_options values=$OSKeys output=$OSs}
-</select><br>
-<input name="is_string">
-<input type="submit" name="add_os"             value="{t}Add{/t}" >
-<input type="submit" name="rename_os"  value="{t}Rename{/t}" >
-<input type="submit" name="del_os"             value="{t}Delete{/t}" >
+{if $Method == "edit"}
+
+       <select name="select_os" size="12" style="width:100%">
+                               {html_options values=$OSKeys output=$OSs}
+       </select><br>
+       <input name="is_string">
+       <input type="submit" name="add_os"              value="{t}Add{/t}" >
+       <input type="submit" name="rename_os"   value="{t}Rename{/t}" >
+       <input type="submit" name="del_os"              value="{t}Delete{/t}" >
 
 <p class="seperator">&nbsp;</p>
 <div align="right">
 <input name="close_edit_os" value="{t}Close{/t}" type="submit">
 </p>
 </div>
+{else}
+{t}Please enter a new name{/t}&nbsp;<input name="string" value="{$string}">
+<p class="seperator">&nbsp;</p>
+    <p>
+        <div align="right" style="text-align: right;">
+            <input type="submit" name="Rename_os_OK"       value="{t}Rename{/t}" >
+            <input type="submit" name="Rename_Cancel"   value="{t}Cancel{/t}" >
+        </div>
+    </p>
+{/if}
+
 <script language="JavaScript" type="text/javascript">
   <!-- // First input field on page
   document.mainform.is_string.focus();
index bab7e5f8785ee98d997d8cdd4ed5afcd67b5a9a8..69577736b27f150a4404795244c4dc09043f4a09 100644 (file)
@@ -1,4 +1,6 @@
 <h2>{t}Manage System-types{/t}</h2>
+{if $Method == "edit"}
+
      <select name="select_type" size="12" style="width:100%">
                             {html_options values=$SystemTypeKeys output=$SystemTypes}
      </select><br>
 <input name="close_edit_type" value="{t}Close{/t}" type="submit">
 </p>
 </div>
+{else}
+{t}Please enter a new name{/t}&nbsp;<input name="string" value="{$string}">
+<p class="seperator">&nbsp;</p>
+       <p>
+               <div align="right" style="text-align: right;">
+                       <input type="submit" name="Rename_type_OK"              value="{t}Rename{/t}" >
+                       <input type="submit" name="Rename_Cancel"       value="{t}Cancel{/t}" >
+               </div>
+       </p>
+{/if}
 <script language="JavaScript" type="text/javascript">
   <!-- // First input field on page
   document.mainform.type_string.focus();