Code

Only add opsi if the plugin is installed
[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   var $dn;
18   function SelectDeviceType  (&$config, $dn= NULL)
19   {
20     if(!is_array($dn)){
21       $this->dns = array($dn);
22       plugin::plugin ($config, NULL);
23     }else{
24       $this->dns = $dn;
25       plugin::plugin ($config, $dn);
26     }
28     /* Get object groups */
29     $ldap = $this->config->get_ldap_link();
30     $ldap->cd ($this->config->current['BASE']);
31     $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn"));
32     $tmp= array();
33     while($attrs = $ldap->fetch()){
34       $tmp[$attrs['dn']]= $attrs['cn'][0];
35     }
36     asort($tmp, SORT_LOCALE_STRING);
37     $this->ObjectGroups= $tmp;
39     $this->SystemTypes =array("workstation"=>_("Workstation"), "terminal"=>_("Terminal"), "server"=>_("Server"));
40     if(class_available("opsi")){
41     $this->SystemTypes["opsi_client"]= _("Windows workstation");
42     }
43   }
45   function execute()
46   {
47     /* Call parent execute */
48     plugin::execute();
50     /* Fill templating stuff */
51     $smarty= get_smarty();
52     $display= "";
54     $smarty->assign("dns_cnt" , count($this->dns));
56     /* Add none to the list of object groups, if there is only one 
57         object that currently edited. This will allow to modify attributes manually and 
58         skip object group inherit.
59      */
60     $ogs = $this->ObjectGroups;
61     if(count($this->dns) == 1){
62       $tmpa['none']=_("none");
63       $ogs = array_merge($tmpa,$ogs);
64     }
66     $smarty->assign("ObjectGroups"    ,$ogs);
67     $smarty->assign("ObjectGroupKeys" ,array_flip($ogs));
68     $smarty->assign("SystemTypes"     ,$this->SystemTypes);
69     $smarty->assign("SystemTypeKeys"  ,array_flip($this->SystemTypes)); 
71     $smarty->assign("ObjectGroup",$this->ObjectGroup);
72     $smarty->assign("SystemType",$this->SystemType);
74     $display.= $smarty->fetch(get_template_path('SelectDeviceType.tpl', TRUE,dirname(__FILE__)));
75     return($display);
76   }
78   /* Save data to object */
79   function save_object()
80   {
81     plugin::save_object();
82     foreach($this->attributes as $attr){
83       if(isset($_POST[$attr])){
84         $this->$attr = $_POST[$attr];
85       }
86     }
87   }
89   /* Check supplied data */
90   function check()
91   {
92     /* Call common method to give check the hook */
93     $message= plugin::check();
95     return ($message);
96   }
98   /* Save to LDAP */
99   function save()
100   {
101   }
104 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
105 ?>