Code

Added missing files
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 30 Aug 2005 11:10:36 +0000 (11:10 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 30 Aug 2005 11:10:36 +0000 (11:10 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1262 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_selectUserToPrinterDialog.inc [new file with mode: 0644]
plugins/admin/systems/selectUserToPrinterDialog.tpl [new file with mode: 0644]

diff --git a/plugins/admin/systems/class_selectUserToPrinterDialog.inc b/plugins/admin/systems/class_selectUserToPrinterDialog.inc
new file mode 100644 (file)
index 0000000..945d6f6
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+
+class selectUserToPrinterDialog 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();
+  var $objectclasses        = array("whatever");
+  var $regex                = "*";
+  var $depselect            = "/";
+  var $deplist              = "/";
+
+  var $searchObjects        = "";
+  var $searchAttrs          = "";
+  var $searchAppend         = "";
+  var $type                 = "";
+  
+  function selectUserToPrinterDialog ($config, $dn= NULL,$type=false )
+  {
+    plugin::plugin ($config, $dn);
+    $this->depselect = $this->config->current['BASE'];
+
+    switch($type){
+      case "AddUser" : 
+        $this->searchObjects = "(objectClass=person)(objectClass=inetOrgPerson)";
+        $this->searchAttrs   = array("cn","uid");
+        $this->searchAppend  = "uid"; 
+          ;break;
+      case "AddGroup" :
+        $this->searchObjects = "(objectClass=posixGroup)";
+        $this->searchAttrs   = array("cn","description");
+        $this->searchAppend  = "cn"; 
+          ;break;
+      case "AddAdminUser" : 
+        $this->searchObjects = "(objectClass=person)(objectClass=inetOrgPerson)";
+        $this->searchAttrs   = array("cn","uid");
+        $this->searchAppend  = "uid"; 
+          ;break;
+      case "AddAdminGroup" :
+        $this->searchObjects = "(objectClass=posixGroup)";
+        $this->searchAttrs   = array("cn","description");
+        $this->searchAppend  = "cn"; 
+          ;break;
+    }
+    $this->type = $type;
+
+  }
+
+  function execute()
+  {
+    /* Fill templating stuff */
+    $smarty= get_smarty();
+    $display= "";
+
+    if(isset($_POST['dialogissubmitted'])){
+      $this->regex=$_POST['regexPrinter'];
+      $this->depselect = $_POST['depselectPrinter'];
+    }
+
+    if((isset($_GET['search']))&&(!empty($_GET['search']))){
+      $this->regex=$_GET['search']."*";
+      $this->regex=preg_replace("/\*\*/","*",$this->regex);
+    }
+
+    $this->deplist=array_flip($this->config->departments);
+
+    $smarty->assign("regexPrinter"        , $this->regex);
+    $smarty->assign("deplistPrinter"      , $this->deplist);
+    $smarty->assign("depselectPrinter"    , $this->depselect);
+    $smarty->assign("gotoPrinters"        , $this->getPrinter());
+    $smarty->assign("gotoPrinterKeys"     , array_flip($this->getPrinter()));
+    $smarty->assign("apply"               , apply_filter());
+    $smarty->assign("alphabet"            , generate_alphabet());
+    $smarty->assign("search_image"        , get_template_path('images/search.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("deplist"             , $this->config->idepartments);
+
+    $display.= $smarty->fetch(get_template_path('selectUserToPrinterDialog.tpl', TRUE,dirname(__FILE__)));
+    return($display);
+  }
+
+  function check(){
+    $message=array();
+    if(empty($_POST['gotoPrinter'])){
+      $message[] = _("Please select a printer or press cancel.");
+    }
+    return $message;
+  }
+
+  /* Save to LDAP */
+  function save()
+  {
+    $a_return['type']=$this->type;
+    
+    foreach($_POST['gotoPrinter'] as $name){
+      $data = $this->getPrinter(true);
+      $a_return[$name]= $data[$name];
+    }
+    return($a_return);
+  }
+
+  /* This function generates the Printerlist
+   * All printers are returned that match regex and and depselect
+   */
+  function getPrinter($detailed = false)
+  {
+    $a_return=array();
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->depselect);
+    $ldap->search("(&".$this->searchObjects."(cn=".$this->regex."))",$this->searchAttrs);
+    while($printer = $ldap->fetch()){
+      if(($detailed ==true)){
+        if(isset($printer[$this->searchAppend])){
+          $a_return[$printer[$this->searchAppend][0]] = $printer;
+        }
+      }else{
+        if(isset($printer[$this->searchAppend])){
+          if(isset($printer['description'][0])){
+            $a_return[$printer[$this->searchAppend][0]] = $printer['cn'][0]." - ".$printer['description'][0]; 
+          }else{
+            $a_return[$printer[$this->searchAppend][0]] = $printer['cn'][0];
+          }
+        }
+      }
+    }
+    return($a_return);
+  }
+}
+
+
+
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/selectUserToPrinterDialog.tpl b/plugins/admin/systems/selectUserToPrinterDialog.tpl
new file mode 100644 (file)
index 0000000..1f2dc32
--- /dev/null
@@ -0,0 +1,77 @@
+<h2><img alt="" src="images/house.png" align="middle">&nbsp;{t}Select printer entry{/t}</h2>
+
+    <input type="hidden" name="dialogissubmitted" value="1">
+
+       <table summary="{t}Select printer to add{/t}" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+        <tr>
+            <td width="50%">
+                               <div class="contentboxh" style="height:20px;">
+                               <p class="contentboxh" style="font-size:12px">
+                                       <b><LABEL for="gotoPrinter">{t}Select printer to add{/t}</LABEL></b>
+                               </p>
+                               </div>
+                               <div class="contentboxb">
+                               <p class="contentboxb" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
+                               <select style="width:550px;" size=20 name="gotoPrinter[]" id="gotoPrinter" multiple>
+                               {html_options values=$gotoPrinterKeys output=$gotoPrinters}
+                               <option disabled>&nbsp;</option>
+                                        </select><br>
+                                       </p>
+                               </div>
+            </td>
+            <td valign="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 menu allows you to create, edit and delete selected printers. 
+                                                       Having a great number of printers, you may want to use the range selectors on top of the printers list.{/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="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
+                                       <tr>
+                                               <td width="50%">
+                                                       <img alt="" src="{$tree_image}" align=middle>&nbsp;{t}Display printers of department{/t}
+                                               </td>
+                                               <td>
+                                                       <select name="depselectPrinter" size=1 onChange="mainform.submit()" title="{t}Choose the department the search will be based on{/t}">
+                                                         {html_options options=$deplistPrinter selected=$depselectPrinter}
+                                                       </select>
+                                               </td>
+                                       </tr>
+                               </table>
+                               </div>
+                               <div class="contentboxb">
+                               <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+                               {$alphabet}
+                               </table>
+                                       <table summary="" width="100%" style="border-top:1px solid #B0B0B0;">
+                                                       <tr>
+                                                               <td>
+                                                                       <LABEL for='filter'><img alt="Search" src="{$search_image}" align="middle" title="{t}Display printers matching{/t}">
+                                                                       </LABEL>
+                                                               </td>
+                                                       <td width="99%">
+                                                                       <input id='filter' style='width:99%' type='text' name='regexPrinter' maxlength='20' value='{$regexPrinter}' 
+                                                                                       title='{t}Regular expression for matching printer names{/t}' onChange="mainform.submit()">
+                                                               </td>
+                                                       </tr>
+                                               </table>
+                                       {$apply}
+                               </div>
+               </td>
+       </tr>
+    </table>
+
+    <p align="right">
+    <input type="submit" name="PrinterSave"     value="{t}Use{/t}">
+    <input type="submit" name="PrinterCancel"   value="{t}Cancel{/t}">
+    </p>
+