Code

added missing template
[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    = "none";
14     var $SystemType        = "gotoWorkstation";
16     var $dn;
18     function SelectDeviceType  (&$config, $dn= NULL)
19     {
20         if(!is_array($dn)){
21             $this->dns = array($dn);
22         }else{
23             $this->dns = $dn;
24         }
25         plugin::plugin ($config, NULL);
27         /* Get object groups */
28         $ldap = $this->config->get_ldap_link();
29         $ldap->cd ($this->config->current['BASE']);
30         $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn"));
31         $tmp= array();
32         while($attrs = $ldap->fetch()){
33             $tmp[$attrs['dn']]= $attrs['cn'][0];
34         }
35         asort($tmp, SORT_LOCALE_STRING);
36         $this->ObjectGroups= $tmp;
38         $this->SystemTypes =array("gotoWorkstation"=>_("Workstation"), "gotoTerminal"=>_("Terminal"), "goServer"=>_("Server"));
39         if(class_available("opsi")){
40             $this->SystemTypes["FAKE_OC_OpsiHost"]= _("Windows workstation");
41         }
42     }
44     function execute()
45     {
46         /* Call parent execute */
47         plugin::execute();
50         /* Get object groups */
51         $ldap = $this->config->get_ldap_link();
52         $ldap->cd ($this->config->current['BASE']);
53         $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("gosaGroupObjects","cn"));
54         $tmp= array("W" => array(),"T" => array(), "S" => array(),"O" => array());
55         while($attrs = $ldap->fetch()){
56             $tmp[preg_replace("/[\[\] ]/","",$attrs['gosaGroupObjects'][0])][$attrs['dn']] = $attrs['cn'][0];
57         }
59         /* Fill templating stuff */
60         $smarty= get_smarty();
61         $display= "";
63         $map = array("gotoWorkstation" => "W","gotoTerminal" => "T","goServer" => "S", "FAKE_OC_OpsiHost" => "O");
64         $smarty->assign("dns_cnt" ,        set_post(count($this->dns)));
65         $smarty->assign("ogroups",         set_post($tmp[$map[$this->SystemType]]));
66         $smarty->assign("SystemTypes"     ,set_post($this->SystemTypes));
67         $smarty->assign("SystemTypeKeys"  ,set_post(array_flip($this->SystemTypes))); 
68         $smarty->assign("ObjectGroup",     set_post($this->ObjectGroup));
69         $smarty->assign("SystemType",      set_post($this->SystemType));
70         $display.= $smarty->fetch(get_template_path('SelectDeviceType.tpl', TRUE,dirname(__FILE__)));
71         return($display);
72     }
74     /* Save data to object */
75     function save_object()
76     {
77         plugin::save_object();
78         foreach($this->attributes as $attr){
79             if(isset($_POST[$attr])){
80                 $this->$attr = get_post($attr);
81             }
82         }
83     }
85     /* Check supplied data */
86     function check()
87     {
88         /* Call common method to give check the hook */
89         $message= plugin::check();
91         return ($message);
92     }
94     /* Save to LDAP */
95     function save()
96     {
97     }
99     function acl_is_writeable($attribute,$skip_write = FALSE)
100     {
101         if($this->read_only) return(FALSE);
102         $ui= get_userinfo();
103         return preg_match('/w/', $ui->get_permissions($this->acl_base, $this->acl_category."systemManagement", "", $skip_write));
104     }
108 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
109 ?>