Code

Glpi template, etc
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 22 Dec 2005 13:16:08 +0000 (13:16 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 22 Dec 2005 13:16:08 +0000 (13:16 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2382 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_config.inc
plugins/admin/systems/class_glpiAccount.inc
plugins/admin/systems/glpi.tpl

index fdfeb3d7b71fc5efe933ee29b2e87c6d06097dd4..84f9b176406c77c57cee97603b4e32ecd22916fe 100644 (file)
@@ -367,7 +367,7 @@ class config  {
                                                'SERVER'        => $attrs['cn'][0],
                                                'LOGIN'         => $attrs['goGlpiAdmin'][0],
                                                'PASSWORD'      => $attrs['goGlpiPassword'][0],
-                                               'DB'            => $attrs['goGpliDatabase'][0]);
+                                               'DB'            => $attrs['goGlpiDatabase'][0]);
        }
        /* Get logdb server */
        $ldap->cd ($this->current['BASE']);
index 0d532c8714635b4671477b6fd47263c5d72c5b35..5632cb462ae2c242a49b10f3e2c7193ed26d4cde 100644 (file)
@@ -12,25 +12,88 @@ class glpiAccount extends plugin
   var $attributes= array();
   var $objectclasses= array("whatever");
 
+  var $initialy_was_account = false;
+
+  var $data;
+  var $handle = NULL;
+
   /* Contructor 
      Sets default values and checks if we already hae an existing glpi account
   */
   function glpiAccount ($config, $dn= NULL)
   {
     plugin::plugin ($config, $dn);
-    print $this->is_account;
-    print $this->initialy_was_account;
+
+    if(!isset($this->config->data['SERVERS']['GLPI'])){
+      return;
+    }
+    
+    $this->data = $this->config->data['SERVERS']['GLPI'];
+    
+    if(!is_callable("mysql_connect")){
+      return;
+    }
+    
+    $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+    
+    if(!$this->handle->is_connected){
+      return;
+    } 
+
+    if($this->handle->is_account($this->dn)){
+      $this->is_account = true;
+    }else{
+      $this->is_account = false;
+    }
+
+    $this->initialy_was_account = $this->is_account;
   }
 
   function execute()
   {
-       /* Call parent execute */
-       plugin::execute();
+       /* Call parent execute */
+         plugin::execute();
 
     /* Fill templating stuff */
     $smarty= get_smarty();
     $display= "";
 
+    /* Assign smarty defaults */ 
+    foreach(array("SystemTypes","Manufacturers","OSs","TechnicalResponsibles","InstalledDevices","Attachments") as $attr){
+      $smarty->assign($attr,array());
+      $smarty->assign($attr."ACL"," disabled ");
+    }
+
+    foreach(array("SystemType","Manufacturer","OS","TechnicalResponsible") as $attr){
+      $smarty->assign($attr,"");
+      $smarty->assign($attr."ACL"," disabled ");
+    }
+
+    /* Perform some checks
+     *  arround the database
+     */ 
+    if(!isset($this->config->data['SERVERS']['GLPI'])){
+      print_red(_("There is no valid configuration for glpi database available."));
+      return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+    }
+    $this->data = $this->config->data['SERVERS']['GLPI'];
+
+    if(!is_callable("mysql_connect")){
+      print_red(_("The php mysql extension is missing. Can't perform any queries."));
+      return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+    }
+
+    $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+
+    if(!$this->handle->is_connected){
+      print_red(_("Can't copnnect to specified database."));
+      return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+    }
+
+    /* If we reach this this 
+     * the database connection seams to ok
+     */
+
     /* Do we need to flip is_account state? */
     if (isset($_POST['modify_state'])){
       $this->is_account= !$this->is_account;
@@ -46,6 +109,26 @@ class glpiAccount extends plugin
       return ($display);
     }
 
+
+    foreach(array("SystemType","Manufacturer","OS","TechnicalResponsible","InstalledDevices","Attachments") as $attr){
+      $smarty->assign($attr,"");
+      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
+    }
+    
+
+    $smarty->assign("SystemTypes",$this->handle->getSystemTypes());
+    $smarty->assign("SystemType","os");
+
+    $smarty->assign("OSs",$this->handle->getOSTypes());
+    $smarty->assign("OS","is");
+
+    $smarty->assign("Manufacturers",$this->handle->getEnterprisesTypes());
+    $smarty->assign("Manufacturer","still");
+
+    $smarty->assign("TechnicalResponsibles",array("os","is","still","missing"));
+    $smarty->assign("TechnicalResponsible","missing");
+
+
     $display.= $smarty->fetch(get_template_path('glpi.tpl', TRUE));
     return($display);
   }
index b16551d0328999cb61ed4933463f01737d95cfe3..120ca6e652fd283c9fe2c7eefa74299418b9f982 100644 (file)
@@ -1 +1,98 @@
-dasfasd
+<table summary="" style="width:100%;">
+       <tr>
+               <td style="width:50%;">
+                       <!--Upper left-->       
+                       
+                       <h2>{t}Generic{/t}</h2>
+                       <table summary="">
+                               <tr>
+                                       <td>{t}System type{/t}
+                                       </td>
+                                       <td>
+                                               <select name="SystemType" {$SystemTypeACL}>
+                                                       {html_options values=$SystemTypes output=$SystemTypes selected=$SystemType}
+                                               </select>       
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>{t}Operating system{/t}
+                                       </td>
+                                       <td>
+                                               <select name="OS" {$OSACL}>
+                                                       {html_options values=$OSs output=$OSs selected=$OS}
+                                               </select>       
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>{t}Manufacturer{/t}
+                                       </td>
+                                       <td>
+                                               <select name="Manufacturer" {$ManufacturerACL}>
+                                                       {html_options values=$Manufacturers output=$Manufacturers selected=$Manufacturer}
+                                               </select>       
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>{t}Technicalresposible{/t}
+                                       </td>
+                                       <td>
+                                               <select name="TechnicalResponsible" {$TechnicalResponsibleACL}>
+                                                       {html_options values=$TechnicalResponsibles output=$TechnicalResponsibles selected=$TechnicalResponsible}
+                                               </select>       
+                                       </td>
+                               </tr>
+                       </table>
+                       <p class="seperator" >&nbsp;</p>
+                       <h2>{t}Installed devices{/t}</h2>
+                       <table summary="" width="100%"> 
+                               <tr>
+                                       <td>
+                                               <select name="InstalledDevices" {$InstalledDevicesACL} style="height:120px;width:100%;" multiple>
+                                                       {html_options values=$InstalledDevices output=$InstalledDevices}
+                                               </select>
+                                               <input name="AddDevice" value="{t}Add{/t}" type="submit">       
+                                       </td>
+                               </tr>
+                       </table>
+                       <p class="seperator" >&nbsp;</p>
+                       <input type="submit" value="{t}Trading{/t}" name="Trading">     
+                       <input type="submit" value="{t}Software{/t}" name="Software">   
+                       <input type="submit" value="{t}Contracts{/t}" name="Contracts"> 
+               </td>
+               <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
+                       <!--Upper right-->
+                       <h2>{t}Contacts{/t}</h2>
+                       <table summary="" width="100%">
+                               <tr>
+                                       <td>
+                                               {t}Contact person{/t}
+                                       </td>
+                                       <td>
+                                               contact person sdasd <input type="submit" value="{t}Edit{/t}"><img src="images/mailto.png" class="center" alt="{t}mailto{/t}">  
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>
+                                               {t}Comments{/t}
+                                       </td>
+                                       <td>
+                                               <textarea name="Comments" style="width:100%;height:110px;" ></textarea>
+                                       </td>
+                               </tr>
+                       </table>
+                       <p class="seperator" >&nbsp;</p>
+                       <h2>{t}Attachments{/t}</h2>
+                       <table summary="" width="100%"> 
+                               <tr>
+                                       <td>
+                                               <select name="Attachments" {$AttachmentsACL} style="height:120px;width:100%;" multiple>
+                                                       {html_options values=$Attachments output=$Attachments}
+                                               </select>
+                                               <input name="AddDevice" value="{t}Add{/t}" type="submit">       
+                                       </td>
+                               </tr>
+                       </table>
+                       
+               </td>
+       </tr>
+</table>