Code

Some updates for glpi
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 5 Jan 2006 13:02:09 +0000 (13:02 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 5 Jan 2006 13:02:09 +0000 (13:02 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2417 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_glpiAccount.inc
plugins/admin/systems/class_glpiAttachmentPool.inc [new file with mode: 0644]
plugins/admin/systems/glpi.tpl
plugins/admin/systems/glpiAttachmentEdit.tpl [new file with mode: 0644]
plugins/admin/systems/glpiAttachmentPool.tpl [new file with mode: 0644]
plugins/admin/systems/workstation.tpl

index c3015a316e6b9da784bac736b591bc41dfac8efb..f1e56d8f8bf3835a2a7961a7d9b039a8526df81b 100644 (file)
@@ -151,13 +151,31 @@ class glpiAccount extends plugin
       return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
     } 
 
-    /*  All check are ok
+    /*  All checks are ok
         Lets handle Posts, templates etc below ...
      */
     
     $users = $this->handle->getUsers();
     $ldap= $this->config->get_ldap_link();
-  
+    /* Check for Trading button Post
+     */
+    if(isset($_POST['Trading'])){
+      print_red(_("This feature is not implemented yet."));
+    }
+
+    /* Check for Software button Post
+     */
+    if(isset($_POST['Software'])){
+      print_red(_("This feature is not implemented yet."));
+    }
+
+    /* Check for Contract button Post
+     */
+    if(isset($_POST['Contracts'])){
+      print_red(_("This feature is not implemented yet."));
+    }
     /* Add Device was requested, open new dialog
      */
     if(isset($_POST['AddDevice'])){
diff --git a/plugins/admin/systems/class_glpiAttachmentPool.inc b/plugins/admin/systems/class_glpiAttachmentPool.inc
new file mode 100644 (file)
index 0000000..eebbb9e
--- /dev/null
@@ -0,0 +1,277 @@
+<?php
+
+class glpiAttachmentPool extends plugin
+{
+  /* CLI vars */
+  var $cli_summary= "Manage server basic objects";
+  var $cli_description= "Some longer text\nfor help";
+  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  /* attribute list for save action */
+  var $ignore_account = TRUE;
+  var $attributes     = array("name","comment","mime","filename");
+  var $objectclasses  = array("whatever");
+
+  var $parent;
+  var $edit = false;
+  var $entry = false;
+
+  var $name     ="";
+  var $comment  ="";
+  var $mime     ="";
+  var $filename ="";  
+
+  var $Selected = array();
+
+  function glpiAttachmentPool ($config, $dn= NULL,$used=NULL)
+  {
+    plugin::plugin ($config, $dn);
+    if(!isset($_SESSION['GlpiAttachmentFilter'])){
+      $_SESSION['GlpiAttachmentFilter'] = array("filter"=>"*");
+    }
+    if($used != NULL){
+      $this->Selected = $used;
+    }
+  }
+
+  function execute()
+  {
+    plugin::execute();
+    $attach = $this->parent->handle->getAttachments();
+    /* Fill templating stuff */
+    $smarty= get_smarty();
+    $display= "";
+    $only_once = true; 
+    foreach($_POST as $name => $value){
+
+      if(preg_match("/new_attach/",$name)){
+        $this->edit = true;
+        $this->entry=array();
+        foreach($this->attributes as $attr) {
+          $this->$attr = "";
+          $this->entry[$attr]="";
+        }
+      }
+  
+      if((preg_match("/^delAttach_/",$name))&&($only_once)){
+        $only_once = false;
+        $str = preg_replace("/^delAttach_/","",$name);
+        $str = base64_decode(preg_replace("/_.*$/","",$str));
+        $this->parent->handle->deleteAttachment($str);
+      }
+      
+      if((preg_match("/^editAttach_/",$name))&&($only_once)){
+        $only_once = false;
+        $str = preg_replace("/^editAttach_/","",$name);
+        $str = base64_decode(preg_replace("/_.*$/","",$str));
+          
+        $this->edit = true;
+        foreach($attach as $att ){
+      
+          if($att['ID'] == $str ){
+            $this->entry  = $att;        
+          } 
+        }
+      }
+    }
+
+    if(($this->edit == true)&&(isset($_POST['upload']))){
+      if(!isset($_FILES['filename'])){
+        print_red(_("There is no valid file uploaded."));
+      }else{
+        $FILE = $_FILES['filename'];  
+        if(!isset($FILE['name'])){
+          print_red(_("There is no valid file uploaded."));
+        }else{
+          if($FILE['error']!=0) {
+            print_red(_("Upload wasn't successfull."));
+          }else{
+            if(!is_dir("/etc/gosa/glpi/")){
+              print_red(_("Missing directory '/etc/gosa/glpi/' to store glpi uploads."));
+            }else{
+              $filen = "/etc/gosa/glpi/".$FILE['name'];
+              $fh = fopen($filen,"w");
+              if(!$fh){
+                print_red(sprintf(_("Can't create file '%s'."),$filen));
+              }else{
+                $str = file_get_contents($FILE['tmp_name']);
+                fwrite($fh,$str,strlen($str));
+                fclose($fh);
+                $this->mime     = $FILE['type'];   
+                $this->filename = $FILE['name'];   
+              }
+            }
+          } // Check if any error occured
+        } // check if valid filename was uploaded
+      } // ende check if file was uploaded 
+    }// upload post
+
+    if(($this->edit == true)&&(isset($_POST['SaveAttachment']))){
+      if(count($this->check())==0){
+        $this->save_entry();
+        $this->edit= false;
+        $this->entry = array();
+        $attach = $this->parent->handle->getAttachments();
+      }else{
+        foreach($this->check() as $msg){
+          print_red($msg);
+        }
+      }
+    }
+
+    if(($this->edit == true)&&(isset($_POST['CancelAttachment']))){
+      $this->edit  = false;
+      $this->entry = array();
+    }
+
+    if($this->edit == true){
+      foreach($this->attributes as $attr){
+        $smarty->assign($attr,$this->$attr);
+      }
+      if(!empty($this->filename)){
+        if(is_readable("/etc/gosa/glpi/".$this->filename)){
+          $status =_("File is available.");
+        }else{
+          $status =_("File is not readable, possibly the file is missing.");
+        }
+      }else{
+        $status = _("Currently no file uploaded.");
+      }
+      $smarty->assign("status",$status); 
+      return($smarty->fetch(get_template_path('glpiAttachmentEdit.tpl', TRUE)));
+    }
+
+
+
+
+
+    $divlist = new divlist("Attachment");  
+    $divlist->SetHeader(array(
+          array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"),
+          array("string" => _("Name")),
+          array("string" => _("Mime"),"attach"=>"style='width:200px;'"),
+          array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
+
+    $divlist->SetSummary(_("This table displays all available attachments."));
+    $divlist->SetEntriesPerPage(0);
+
+    $editdel = "<input type='image' name='editAttach_%s' src='images/edit.png'>";
+    $editdel.= "<input type='image' name='delAttach_%s'  src='images/edittrash.png'>";
+
+    foreach($attach as $entry){
+      
+        if((empty($entry['name']))||(empty($entry['comment']))){
+          
+          if(empty($entry['name'])){
+            $str1 = "<i>"._("empty")."</i>";
+          }else{ 
+            $str1 = $entry['name'];
+          }
+          
+          if(!empty($entry['comment'])){
+            $str1.= " [".$entry['comment']."]";
+          }
+        }else{
+          $str1 = $entry['name']." [".$entry['comment']."]";
+        }
+
+        $edit = str_replace("%s",base64_encode($entry['ID']),$editdel);
+        $str2 = $entry['mime']."&nbsp;";      
+
+        $chkbox = "<input type='hidden' name='wasOnPage_%s'>".
+                  "<input type='checkbox' name='useMe_%s' value='%s' %CHECKED%>";
+        
+        if(in_array($entry['ID'],$this->Selected)){
+          $chkbox = preg_replace("/%CHECKED%/"," checked ",$chkbox);
+        }else {
+          $chkbox = preg_replace("/%CHECKED%/"," ",$chkbox);
+        }
+        $chkbox = preg_replace("/%s/",$entry['ID'],$chkbox);
+        $divlist->AddEntry(array(
+                                  array("string" => $chkbox, 
+                                        "attach" => "style='text-align:center;width:20px;'"),
+                                  array("string"=> $str1),
+                                  array("string"=> $str2,"attach"=>"style='width:200px;'"),
+                                  array("string"=> $edit ,"attach" => "style='width:60px;border-right:0px;text-align:right;'")
+                                ));
+    }
+
+    $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+              "   <input class='center' type='image' 
+                    src='images/new.png' align='middle' title='"._("Create new attachment")."' 
+                    name='new_attach' alt='"._("New Attachment"). "'>&nbsp;".
+              "</div>";
+
+
+    $smarty->assign("attachments",      $divlist->DrawList());
+    $smarty->assign("attachmenthead",   $listhead);
+    $smarty->assign("search_image",     get_template_path('images/search.png'));
+    $smarty->assign("searchu_image",    get_template_path('images/search_user.png'));
+    $smarty->assign("tree_image",       get_template_path('images/tree.png'));
+    $smarty->assign("infoimage",        get_template_path('images/info.png'));
+    $smarty->assign("launchimage",      get_template_path('images/launch.png'));
+    $smarty->assign("apply",            apply_filter());
+    $smarty->assign("alphabet",         generate_alphabet());
+    $smarty->assign("attachment_regex", $_SESSION['GlpiAttachmentFilter']['filter']);
+
+
+    $display.= $smarty->fetch(get_template_path('glpiAttachmentPool.tpl', TRUE));
+    return($display);
+  }
+
+  function save()
+  {
+    return($this->Selected);
+  }
+
+  function save_entry()
+  {
+    if($this->edit){
+      $tmp = array();
+      foreach($this->attributes as $attr){
+        $tmp[$attr] = $this->$attr;
+      } 
+      $id = -1;
+      if(isset($this->entry['ID'])){
+        $id = $this->entry['ID'];
+      }
+      $this->parent->handle->saveAttachments($tmp,$id);
+    }
+  }
+
+  function save_object()
+  {
+    foreach($this->attributes as $attr){
+      if(isset($_POST[$attr])){
+        $this->$attr = $_POST[$attr];
+      }
+    }
+
+    foreach($_POST as $name => $value){
+      if(preg_match("/wasOnPage_/",$name)){
+        $id=preg_replace("/wasOnPage_/","",$name);
+        if(isset($_POST["useMe_".$id])){
+          $this->Selected[$id]=$id;
+        }else{
+          if(isset($this->Selected[$id])){
+            unset($this->Selected[$id]);
+          }
+        }
+      }
+    }
+  }
+
+  function check()
+  {
+    $message = array();
+    if($this->edit){
+      if(empty($this->name)){
+        $message[] = _("Please specify a valid name for this attachment.");
+      }
+    }
+    return($message);
+  }
+
+}// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
index 8832d2cb1ba4c04448c4f103f3be09d6e5d7a34d..c945c46f0cde1bdeaf277537295891f4ca8976bb 100644 (file)
@@ -4,7 +4,7 @@
                        <!--Upper left-->       
                        
                        <h2>{t}Generic{/t}</h2>
-                       <table summary="">
+                       <table summary="" cellpadding=5>
                                <tr>
                                        <td width="150">{t}System type{/t}
                                        </td>
@@ -71,7 +71,7 @@
                                        </td>
                                        <td>
                                                <i>{$contact_num}&nbsp; </i>&nbsp;
-                                               <input {$contact_numACL} type="submit" name="SelectContactPerson" value="{t}Edit{/t}"><img src="images/mailto.png" class="center" alt="{t}mailto{/t}">  
+                                               <input {$contact_numACL} type="submit" name="SelectContactPerson" value="{t}Edit{/t}">
                                        </td>
                                </tr>
                                <tr>
diff --git a/plugins/admin/systems/glpiAttachmentEdit.tpl b/plugins/admin/systems/glpiAttachmentEdit.tpl
new file mode 100644 (file)
index 0000000..3b33cf6
--- /dev/null
@@ -0,0 +1,72 @@
+<br>
+<h2>{t}Attachment{/t}</h2>
+       
+<table summary="" width="100%">
+       <tr>
+               <td width="50%" style="vertical-align:top;">
+                       <table summary="" width="100%">
+                               <tr>
+                                       <td  style="vertical-align:top;">
+                                               {t}Name{/t}
+                                       </td>
+                                       <td>
+                                               <input type="text" value="{$name}" name="name">
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td style="vertical-align:top;">
+                                               {t}Comment{/t}
+                                       </td>
+                                       <td style="vertical-align:top;">
+                                               <textarea name="comment">{$comment}</textarea>
+                                       </td>
+                               </tr>
+                       </table>
+               </td>
+               <td  style="vertical-align:top;">
+                       <table summary="" width="100%">
+                               <tr>
+                                       <td style="vertical-align:top;">
+                                               {t}File{/t}
+                                       </td>
+                                       <td style="vertical-align:top;">
+                                               <input type="file" value="" name="filename"><input type="submit" name="upload" value="{t}Upload{/t}">
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td style="vertical-align:top;">
+                                               {t}Status{/t}
+                                       </td>
+                                       <td style="vertical-align:top;">
+                                               {$status}
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td style="vertical-align:top;">
+                                               {t}Filename{/t}
+                                       </td>
+                                       <td style="vertical-align:top;">
+                                               {$filename}
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td style="vertical-align:top;">
+                                               {t}Mime-type{/t}
+                                       </td>
+                                       <td style="vertical-align:top;">
+                                               {$mime}
+                                       </td>
+                               </tr>
+                       </table>
+               </td>
+       </tr>
+</table>
+
+
+<p class="seperator">&nbsp;</p>
+<div align="right">
+       <p>
+               <input type="submit" name="SaveAttachment"              value="{t}Save{/t}">
+               <input type="submit" name="CancelAttachment"    value="{t}Cancel{/t}">
+       </p>
+</div>
diff --git a/plugins/admin/systems/glpiAttachmentPool.tpl b/plugins/admin/systems/glpiAttachmentPool.tpl
new file mode 100644 (file)
index 0000000..c60d609
--- /dev/null
@@ -0,0 +1,56 @@
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+<tr>
+  <td style="vertical-align:top;width:50%;" >
+  <div class="contentboxh">
+    <p class="contentboxh">
+     {t}List of attachments{/t}
+    </p>
+  </div>
+  <div class="contentboxb">
+      {$attachmenthead}
+  </div>
+  <div style='height:4px;'></div>
+  <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+      {$attachments}
+    <input type=hidden name="edit_helper">
+  </div>
+  </td>
+  <td style="vertical-align:top;">
+   <div class="contentboxh">
+    <p class="contentboxh"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
+   </div>
+   <div class="contentboxb">
+   <p class="contentboxb">
+    {t}This dialog allow you to attach additional objects (like manuals, guides, etc.)  to your currently edited computer.{/t}
+   </p>
+   </div>
+   <br>
+   <div class="contentboxh">
+    <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
+   </div>
+   <div class="contentboxb">
+     <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+      {$alphabet}
+     </table>
+<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+<tr>
+<td><LABEL for="regex"><img alt="{t}Display attachments matching{/t}" src="{$search_image}" align=middle></label></td>
+<td width="99%">
+<input type='text' style='width:99%' name='attachment_regex' maxlength='20' value='{$attachment_regex}' title='{t}Regular expression for matching attachment names{/t}' onChange="mainform.submit()">
+</td>
+</tr>
+</table>
+   {$apply}
+   </div>
+  </td>
+</tr>
+</table>
+
+<input type="hidden" name="ignore">
+<p class="seperator">&nbsp;</p>
+<div align="right">
+       <p>
+       <input type="submit" name="UseAttachment" value="{t}Use{/t}">
+       <input type="submit" name="AbortAttachment" value="{t}Cancel{/t}">
+       </p>
+</div>
index 4dbdad767514eca64d3ec221a3154f428cddafb8..ddb7cabb81f830d9e59c4cdbc5b387f7b5fafb12 100644 (file)
@@ -80,7 +80,7 @@
  <tr>
   <td>
    <select size="1" name="saction" {$actionACL} title="{t}Select action to execute for this terminal{/t}">
-    <option disabled>&nbsp;</option>
+    <option>&nbsp;</option>
     {html_options options=$actions}
    </select>
   </td>