Code

Corrected kioskpath parsing
[gosa.git] / plugins / personal / environment / class_selectPrinterDialog.inc
1 <?php
3 class selectPrinterDialog extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary          = "Manage server basic objects";
7   var $cli_description      = "Some longer text\nfor help";
8   var $cli_parameters       = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $ignore_account       = TRUE;
12   var $attributes           = array();
13   var $objectclasses        = array("whatever");
14   var $use_existing         = false;  
15   var $regex                = "*";
16   var $depselect            = "/";
17   var $deplist              = "/";
19   function selectPrinterDialog ($config, $dn= NULL,$use_existing=false )
20   {
21     $this->use_existing = $use_existing;
22     plugin::plugin ($config, $dn);
23     $this->depselect = $this->config->current['BASE'];
24   }
26   function execute()
27   {
28     /* Fill templating stuff */
29     $smarty= get_smarty();
30     $display= "";
32     if(isset($_POST['dialogissubmitted'])){
33       $this->regex=$_POST['regexPrinter'];
34       $this->depselect = $_POST['depselectPrinter'];
35     }
37     if((isset($_GET['search']))&&(!empty($_GET['search']))){
38       $this->regex=$_GET['search']."*";
39       $this->regex=preg_replace("/\*\*/","*",$this->regex);
40     }
42     $this->deplist=array_flip($this->config->departments);
44     $smarty->assign("regexPrinter"    ,$this->regex);
45     $smarty->assign("deplistPrinter"  ,$this->deplist);
46     $smarty->assign("depselectPrinter",$this->depselect);
47     $smarty->assign("gotoPrinters",$this->getPrinter());
48     $smarty->assign("gotoPrinterKeys",array_flip($this->getPrinter()));
49     $smarty->assign("apply", apply_filter());
50     $smarty->assign("alphabet", generate_alphabet());
51     $smarty->assign("search_image", get_template_path('images/search.png'));
52     $smarty->assign("tree_image", get_template_path('images/tree.png'));
53     $smarty->assign("infoimage", get_template_path('images/info.png'));
54     $smarty->assign("launchimage", get_template_path('images/launch.png'));
55     $smarty->assign("deplist", $this->config->idepartments);
57     $display.= $smarty->fetch(get_template_path('selectPrinterDialog.tpl', TRUE,dirname(__FILE__)));
58     return($display);
59   }
61   function check(){
62     $message=array();
63     if(empty($_POST['gotoPrinter'])){
64       $message[] = _("Please select a printer or press cancel.");
65     }
66     return $message;
67   }
69   /* Save to LDAP */
70   function save()
71   {
72     return($_POST['gotoPrinter']);
73   }
75   /* This function generates the Printerlist
76    * All printers are returned that match regex and and depselect
77    */
78   function getPrinter($detailed = false)
79   {
80     $a_return=array();
81     $ldap = $this->config->get_ldap_link();
82     $ldap->cd($this->depselect);
83     $ldap->search("(&(objectClass=gotoPrinter)(cn=".$this->regex."))",array("*"));
84     while($printer = $ldap->fetch()){
85       if($detailed ==true){
86         $a_return[$printer['cn'][0]] = $printer;
87       }else{
88         if(isset($printer['description'][0])){
89           $a_return[$printer['cn'][0]] = $printer['cn'][0]." - ".$printer['description'][0];  
90         }else{
91           $a_return[$printer['cn'][0]] = $printer['cn'][0];  
92         }
93       }
94     }
95     return($a_return);
96   }
97 }
103 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
104 ?>