Code

Fixed sorting
[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     $tmp= array();
25     while($attrs = $ldap->fetch()){
26       $tmp[$attrs['dn']]= $attrs['cn'][0];
27     }
28     asort($tmp, SORT_LOCALE_STRING);
29     $tmpa['none']=_("none");
30     $this->ObjectGroups= array_merge($tmpa, $tmp);
32     $this->SystemTypes =array("workstation"=>_("Workstation"), "terminal"=>_("Terminal"), "server"=>_("Server"));
33   }
35   function execute()
36   {
37     /* Call parent execute */
38     plugin::execute();
40     /* Fill templating stuff */
41     $smarty= get_smarty();
42     $display= "";
44     $smarty->assign("ObjectGroups"    ,$this->ObjectGroups);
45     $smarty->assign("ObjectGroupKeys" ,array_flip($this->ObjectGroups));
46     $smarty->assign("SystemTypes"     ,$this->SystemTypes);
47     $smarty->assign("SystemTypeKeys"  ,array_flip($this->SystemTypes)); 
49     $smarty->assign("ObjectGroup",$this->ObjectGroup);
50     $smarty->assign("SystemType",$this->SystemType);
52     $display.= $smarty->fetch(get_template_path('SelectDeviceType.tpl', TRUE,dirname(__FILE__)));
53     return($display);
54   }
56   /* Save data to object */
57   function save_object()
58   {
59     plugin::save_object();
60     foreach($this->attributes as $attr){
61       if(isset($_POST[$attr])){
62         $this->$attr = $_POST[$attr];
63       }
64     }
65   }
67   /* Check supplied data */
68   function check()
69   {
70     /* Call common method to give check the hook */
71     $message= plugin::check();
73     return ($message);
74   }
76   /* Save to LDAP */
77   function save()
78   {
79   }
80 }
82 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
83 ?>