Code

Sort list of objectgroups
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_SelectDeviceType.inc
1 <?php
3 class SelectDeviceType extends plugin
4 {
5   /* attribute list for save action */
6   var $ignore_account= TRUE;
7   var $attributes= array("ObjectGroup","SystemType");
8   var $objectclasses= array("whatever");
10   var $ObjectGroups   = array();
11   var $SystemTypes       = array();
13   var $ObjectGroup    = "";
14   var $SystemType        = "";
16   function SelectDeviceType  (&$config, $dn= NULL)
17   {
18     plugin::plugin ($config, $dn);
20     /* Get object groups */
21     $ldap = $this->config->get_ldap_link();
22     $ldap->cd ($this->config->current['BASE']);
23     $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn"));
24     $this->ObjectGroups['none']=_("none");
25     while($attrs = $ldap->fetch()){
26       $this->ObjectGroups[$attrs['dn']]= $attrs['cn'][0];
27     }
28     asort($this->ObjectGroups);
30     $this->SystemTypes =array("workstation"=>_("Workstation"), "terminal"=>_("Terminal"), "server"=>_("Server"));
31   }
33   function execute()
34   {
35     /* Call parent execute */
36     plugin::execute();
38     /* Fill templating stuff */
39     $smarty= get_smarty();
40     $display= "";
42     $smarty->assign("ObjectGroups"    ,$this->ObjectGroups);
43     $smarty->assign("ObjectGroupKeys" ,array_flip($this->ObjectGroups));
44     $smarty->assign("SystemTypes"     ,$this->SystemTypes);
45     $smarty->assign("SystemTypeKeys"  ,array_flip($this->SystemTypes)); 
47     $smarty->assign("ObjectGroup",$this->ObjectGroup);
48     $smarty->assign("SystemType",$this->SystemType);
50     $display.= $smarty->fetch(get_template_path('SelectDeviceType.tpl', TRUE,dirname(__FILE__)));
51     return($display);
52   }
54   /* Save data to object */
55   function save_object()
56   {
57     plugin::save_object();
58     foreach($this->attributes as $attr){
59       if(isset($_POST[$attr])){
60         $this->$attr = $_POST[$attr];
61       }
62     }
63   }
65   /* Check supplied data */
66   function check()
67   {
68     /* Call common method to give check the hook */
69     $message= plugin::check();
71     return ($message);
72   }
74   /* Save to LDAP */
75   function save()
76   {
77   }
78 }
80 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
81 ?>