Code

9c8a2af2e59ba07e17127fb3e5ab6bca6a0c3ffc
[gosa.git] / plugins / admin / systems / class_goTerminalServer.inc
1 <?php
3 class goTerminalServer extends plugin{
4         
5   var $cli_summary      = "This pluign is used within the ServerService Pluign \nand indicates that this server supports asterisk management.";
6   var $cli_description  = "Some longer text\nfor help";
7   var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
9   /* This plugin only writes its objectClass */
10   var $objectclasses    = array("goTerminalServer");
11   var $attributes       = array("goTerminalServerStatus","goXdmcpIsEnabled", "goFontPath");
12   var $StatusFlag       = "goTerminalServerStatus";
13  
14   /* This class can't be assigned twice so it conflicts with itsself */
15   var $conflicts        = array("goTerminalServer");
17   var $DisplayName      = "";
18   var $dn               = NULL;
19   var $acl;
21   var $goTerminalServerStatus  = "";
22   var $goXdmcpIsEnabled        = false;  
23   var $goFontPath              = "";
24  
25  
26   function goTerminalServer($config,$dn)
27   {
28     plugin::plugin($config,$dn);
29     $this->DisplayName = _("Terminal service");
30   }
33   function execute()
34   { 
35     $smarty = get_smarty(); 
36     foreach($this->attributes as $attr){
37       $smarty->assign($attr,$this->$attr);
38       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
39     }
40     return($smarty->fetch(get_template_path("goTerminalServer.tpl",TRUE,dirname(__FILE__))));
41   }
44   function getListEntry()
45   {
46     $flag = $this->StatusFlag;
47     $fields['Status']     = $this->$flag;
48     $fields['Message']    = _("Terminal service");
49     $fields['AllowStart'] = true;
50     $fields['AllowStop']  = true;
51     $fields['AllowReset'] = true;
52     $fields['AllowRemove']= true;
53     $fields['AllowEdit']  = true;
54     return($fields);
55   }
58   function remove_from_parent()
59   {
60     plugin::remove_from_parent();
61     /* Check if this is a new entry ... add/modify */
62     $ldap = $this->config->get_ldap_link();
63     $ldap->cat($this->dn,array("objectClass"));
64     if($ldap->count()){
65       $ldap->cd($this->dn);
66       $ldap->modify($this->attrs);
67     }else{
68       $ldap->cd($this->dn);
69       $ldap->add($this->attrs);
70     }
71     show_ldap_error($ldap->get_error());
72   }
75   function save()
76   {
77     plugin::save();
78     /* Check if this is a new entry ... add/modify */
79     $ldap = $this->config->get_ldap_link();
80     $ldap->cat($this->dn,array("objectClass"));
81     if($ldap->count()){
82       $ldap->cd($this->dn);
83       $ldap->modify($this->attrs);
84     }else{
85       $ldap->cd($this->dn);
86       $ldap->add($this->attrs);
87     }
88     show_ldap_error($ldap->get_error());
89   }
92   /* Directly save new status flag */
93   function setStatus($value)
94   {
95     if($value == "none") return;
96     $ldap = $this->config->get_ldap_link();
97     $ldap->cd($this->dn);
98     $ldap->cat($this->dn,array("objectClass","goXdmcpIsEnabled", "goFontPath"));
99       
100     if($ldap->count()){
101       $attrs =array();
102       foreach(array("goXdmcpIsEnabled", "goFontPath") as $req) {
103         if(!isset($attrs[$req])){
104           if(empty($this->$req)){
105             print_red(sprintf(_("The required attribute '%s' is not set."),$req));
106           }else{
107             $attrs[$req] = $this->$req;
108           }
109         }else{
110           $attrs[$req] = $attrs[$req][0];
111         }
112       }
114       $tmp = $ldap->fetch();
115       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
116         $attrs['objectClass'][] = $tmp['objectClass'][$i];
117       }    
118       if(!in_array("goTerminalServer",$attrs['objectClass'])){
119         $attrs['objectClass'][] = "goTerminalServer";
120       }
122       $flag = $this->StatusFlag;
123       $attrs[$flag] = $value;
124       $this->$flag = $value;
125       $ldap->modify($attrs);
126       show_ldap_error($ldap->get_error());
127     }    
128   }
130   
131   function check()
132   { 
133     $message = plugin::check();
134     if(empty($this->goFontPath)){
135       $message[]=_("Terminal server, must have fontpath specified.");
136     }
138     return($message);
139   }
140   
142   function save_object()
143   {
144     if(isset($_POST['goTerminalServerPosted'])){
145       plugin::save_object();
146       if(isset($_POST['goXdmcpIsEnabled'])){
147         $this->goXdmcpIsEnabled = true;
148       }else{
149         $this->goXdmcpIsEnabled = false;
150       }
151     }
152   }  
154 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
155 ?>