Code

Updated display image, moved into goto images.
[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   }
42   function execute()
43   {
44     /* Call parent execute */
45     plugin::execute();
47     /* Fill templating stuff */
48     $smarty= get_smarty();
49     $display= "";
51     $smarty->assign("dns_cnt" , count($this->dns));
53     /* Add none to the list of object groups, if there is only one 
54         object that currently edited. This will allow to modify attributes manually and 
55         skip object group inherit.
56      */
57     $ogs = $this->ObjectGroups;
58     if(count($this->dns) == 1){
59       $tmpa['none']=_("none");
60       $ogs = array_merge($tmpa,$ogs);
61     }
63     $smarty->assign("ObjectGroups"    ,$ogs);
64     $smarty->assign("ObjectGroupKeys" ,array_flip($ogs));
65     $smarty->assign("SystemTypes"     ,$this->SystemTypes);
66     $smarty->assign("SystemTypeKeys"  ,array_flip($this->SystemTypes)); 
68     $smarty->assign("ObjectGroup",$this->ObjectGroup);
69     $smarty->assign("SystemType",$this->SystemType);
71     $display.= $smarty->fetch(get_template_path('SelectDeviceType.tpl', TRUE,dirname(__FILE__)));
72     return($display);
73   }
75   /* Save data to object */
76   function save_object()
77   {
78     plugin::save_object();
79     foreach($this->attributes as $attr){
80       if(isset($_POST[$attr])){
81         $this->$attr = $_POST[$attr];
82       }
83     }
84   }
86   /* Check supplied data */
87   function check()
88   {
89     /* Call common method to give check the hook */
90     $message= plugin::check();
92     return ($message);
93   }
95   /* Save to LDAP */
96   function save()
97   {
98   }
99 }
101 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
102 ?>