Code

Removed unused code block
[gosa.git] / plugins / admin / systems / class_printerPPDSelectionDialog.inc
1 <?php
3 class printerPPDSelectionDialog 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       = FALSE;
12   var $attributes           = array("currentPos","currentSel");
13   var $objectclasses        = array("whatever");
15   var $list                 =array();
16   var $header               =array();
18   var $currentPos           = "";
19   var $currentSel           = -1;
20   var $selectedPPD          = "";
22   function printerPPDSelectionDialog ($config, $dn= NULL,$list=false,$headers=false,$ppd=false)
23   {
24     plugin::plugin ($config, $dn);
25     $this->list       = $list;
26     $this->header     = $headers;
27     $this->depselect  = $this->config->current['BASE'];
28     
29     /* If there is already a ppd file selected, use this as preselected object in our ppds list
30      * /
31     if(isset($ppd)){
32       print_a( $ppd);
33       $tmp2 = split("\n",$ppd['ppd']);
34       if(count($tmp2)==2){
35         $this->currentPos = $tmp2[0];
36         $this->currentSel = preg_replace("/^ -/","",$tmp2[1]);
37       }
38     }
39   
40      */
41     if(!isset($_SESSION['printerPPDSelectionDialog'])){
42       $_SESSION['printerPPDSelectionDialog']['regex'] = "*";
43     }  
45     /* Order the manufacturers index */
46     ksort($this->header);
47   }
49   function execute()
50   {
51         /* Call parent execute */
52         plugin::execute();
54     /* Fill templating stuff */
55     $smarty= get_smarty();
56     $display= "";
57     $s_action = "none";
58   
59     $regex = $_SESSION['printerPPDSelectionDialog']['regex'];
61     if(isset($_GET['search'])){
62       $regex = $_GET['search']."*";
63     }
64   
65     if(isset($_POST['regex'])){
66       $regex= $_POST['regex'];
67     }
68     
69     $regex = str_replace("**","*",$regex);
70     $_SESSION['printerPPDSelectionDialog']['regex'] = $regex;
71   
73     /* if manufacturer is selected and a ppd file 
74      * Set this selected file to our return value.
75      */ 
76     if(isset($this->list[$this->currentPos][$this->currentSel])){
77       $this->selectedPPD = $this->list[$this->currentPos][$this->currentSel];
78     }
80     /** Added **/
81     $list = array();
82     foreach($this->list as $cat => $ppds){
83       foreach($ppds as $ppd){
84         if(preg_match("/^".str_replace("*",".*",$regex)."/i",$ppd['ppd'])){
85           $list[$ppd['link']] = $ppd['ppd'];
86         }
87       }
88     }
90     $smarty->assign("objects",      $list);
91     $smarty->assign("objectKeys",   array_flip($list));
92     $smarty->assign("search_image", get_template_path('images/search.png'));
93     $smarty->assign("launchimage",  get_template_path('images/small_filter.png'));
94     $smarty->assign("tree_image",   get_template_path('images/tree.png'));
95     $smarty->assign("alphabet",     generate_alphabet());
96     $smarty->assign("apply",        apply_filter());
97     $smarty->assign("regex",        $regex);
98   
99     $display.= $smarty->fetch(get_template_path('printerPPDSelectionDialog.tpl', TRUE,dirname(__FILE__)));
100     return($display);
101   }
103   function save_object()
104   {
105   } 
107   function check(){
108   }
110   /* Save to LDAP */
111   function save()
112   {
113     return $this->selectedPPD;
114   }
116 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
117 ?>