[gosa.git] / gosa-plugins / goto / admin / systems / services / terminal / class_goTerminalServer.inc
1 <?php
3 class goTerminalServer extends goService{
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("goXdmcpIsEnabled","gotoSessionType");
12 var $StatusFlag = "goTerminalServerStatus";
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;
20 var $cn = "";
21 var $goTerminalServerStatus = "";
22 var $goXdmcpIsEnabled = false;
23 var $view_logged = FALSE;
25 var $gotoSessionType = array();
27 function goTerminalServer(&$config,$dn)
28 {
29 goService::goService($config,$dn);
30 $this->DisplayName = _("Terminal service");
32 $tmp = array();
33 if(isset($this->attrs['gotoSessionType'])){
34 for($i =0; $i < $this->attrs['gotoSessionType']['count'] ; $i++){
35 $tmp[] = $this->attrs['gotoSessionType'][$i];
36 }
37 }
38 $this->gotoSessionType = $tmp;
39 $this->gotoSessionTypes= array("LDM","XDCMP","RDP","CITRIX");
40 }
43 function execute()
44 {
45 $smarty = get_smarty();
47 if($this->is_account && !$this->view_logged){
48 $this->view_logged = TRUE;
49 new log("view","server/".get_class($this),$this->dn);
50 }
53 $tmp = $this->plinfo();
54 foreach($tmp['plProvidedAcls'] as $name => $translation){
55 $smarty->assign($name."ACL",$this->getacl($name));
56 }
58 foreach($this->attributes as $attr){
59 $smarty->assign($attr,$this->$attr);
60 }
62 $tmp = array();
63 foreach($this->gotoSessionTypes as $type){
64 if(in_array($type,$this->gotoSessionType)){
65 $tmp[$type] = TRUE;
66 }else{
67 $tmp[$type] = FALSE;
68 }
69 }
70 $smarty->assign("gotoSessionTypes",$tmp);
72 return($smarty->fetch(get_template_path("goTerminalServer.tpl",TRUE,dirname(__FILE__))));
73 }
76 function getListEntry()
77 {
78 $fields = goService::getListEntry();
79 $fields['Message'] = _("Terminal service");
80 #$fields['AllowEdit'] = true;
81 return($fields);
82 }
85 function save()
86 {
87 plugin::save();
89 if(!$this->goXdmcpIsEnabled){
90 $this->attrs['goXdmcpIsEnabled'] = "0";
91 }
93 $this->attrs['gotoSessionType'] = array_values($this->gotoSessionType);
95 /* Check if this is a new entry ... add/modify */
96 $ldap = $this->config->get_ldap_link();
97 $ldap->cat($this->dn,array("objectClass"));
98 if($ldap->count()){
99 $ldap->cd($this->dn);
100 $ldap->modify($this->attrs);
101 }else{
102 $ldap->cd($this->dn);
103 $ldap->add($this->attrs);
104 }
105 if (!$ldap->success()){
106 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
107 }
108 if($this->initially_was_account){
109 $this->handle_post_events("modify");
110 new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
111 }else{
112 $this->handle_post_events("add");
113 new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
114 }
115 }
118 function check()
119 {
120 $message = plugin::check();
121 return($message);
122 }
125 function save_object()
126 {
127 if(isset($_POST['goTerminalServerPosted'])){
128 plugin::save_object();
130 $this->gotoSessionType = array();
131 foreach($this->gotoSessionTypes as $attr){
132 if(isset($_POST['gotoSessionType_'.$attr])){
133 $this->gotoSessionType[] = $attr;
134 }
135 }
137 if($this->acl_is_writeable("goXdmcpIsEnabled")){
138 if(isset($_POST['goXdmcpIsEnabled'])){
139 $this->goXdmcpIsEnabled = true;
140 }else{
141 $this->goXdmcpIsEnabled = false;
142 }
143 }
144 }
145 }
148 function PrepareForCopyPaste($obj)
149 {
150 plugin::PrepareForCopyPaste($obj);
151 $tmp = array();
152 if(isset($obj['gotoSessionType'])){
153 for($i =0; $i < $obj['gotoSessionType']['count'] ; $i++){
154 $tmp[] = $obj['gotoSessionType'][$i];
155 }
156 }
157 $this->gotoSessionType = $tmp;
158 $this->gotoSessionTypes= array("LDM","XDCMP","RDP","CITRIX");
159 }
162 /* Return plugin informations for acl handling */
163 static function plInfo()
164 {
165 return (array(
166 "plShortName" => _("Terminal service"),
167 "plDescription" => _("Terminal service")." ("._("Services").")",
168 "plSelfModify" => FALSE,
169 "plDepends" => array(),
170 "plPriority" => 87,
171 "plSection" => array("administration"),
172 "plCategory" => array("server"),
174 "plProvidedAcls"=> array(
175 "goXdmcpIsEnabled" => _("Temporary disable login"))
176 ));
177 }
180 }
181 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
182 ?>