[gosa.git] / gosa-plugins / goto / admin / systems / services / terminal / class_goTerminalServer.inc
1 <?php
3 class goTerminalServer extends goService{
5 /* This plugin only writes its objectClass */
6 var $objectclasses = array("goTerminalServer");
7 var $attributes = array("goXdmcpIsEnabled","gotoSessionType");
8 var $StatusFlag = "goTerminalServerStatus";
10 /* This class can't be assigned twice so it conflicts with itsself */
11 var $conflicts = array("goTerminalServer");
13 var $DisplayName = "";
14 var $dn = NULL;
15 var $acl;
16 var $cn = "";
17 var $goTerminalServerStatus = "";
18 var $goXdmcpIsEnabled = false;
19 var $view_logged = FALSE;
21 var $gotoSessionType = array();
23 function goTerminalServer(&$config,$dn)
24 {
25 goService::goService($config,$dn);
26 $this->DisplayName = _("Terminal service");
28 $tmp = array();
29 if(isset($this->attrs['gotoSessionType'])){
30 for($i =0; $i < $this->attrs['gotoSessionType']['count'] ; $i++){
31 $tmp[] = $this->attrs['gotoSessionType'][$i];
32 }
33 }
34 $this->gotoSessionType = $tmp;
35 #$this->gotoSessionTypes= array("LDM","XDMCP","RDP","CITRIX");
36 $this->gotoSessionTypes= array("LDM","XDMCP", "SHELL", "RDP", "TELNET");
37 }
40 function execute()
41 {
42 $smarty = get_smarty();
44 if($this->is_account && !$this->view_logged){
45 $this->view_logged = TRUE;
46 new log("view","server/".get_class($this),$this->dn);
47 }
50 $tmp = $this->plinfo();
51 foreach($tmp['plProvidedAcls'] as $name => $translation){
52 $smarty->assign($name."ACL",$this->getacl($name));
53 }
55 foreach($this->attributes as $attr){
56 $smarty->assign($attr, set_post($this->$attr));
57 }
59 $tmp = array();
60 foreach($this->gotoSessionTypes as $type){
61 if(in_array($type,$this->gotoSessionType)){
62 $tmp[$type] = TRUE;
63 }else{
64 $tmp[$type] = FALSE;
65 }
66 }
67 $smarty->assign("gotoSessionTypes", set_post($tmp));
68 return($smarty->fetch(get_template_path("goTerminalServer.tpl",TRUE,dirname(__FILE__))));
69 }
72 function getListEntry()
73 {
74 $fields = goService::getListEntry();
75 $fields['Message'] = _("Terminal service");
76 #$fields['AllowEdit'] = true;
77 return($fields);
78 }
81 function save()
82 {
83 plugin::save();
85 if(!$this->goXdmcpIsEnabled){
86 $this->attrs['goXdmcpIsEnabled'] = "0";
87 }
89 $this->attrs['gotoSessionType'] = array_values($this->gotoSessionType);
91 /* Check if this is a new entry ... add/modify */
92 $ldap = $this->config->get_ldap_link();
93 $ldap->cat($this->dn,array("objectClass"));
94 if($ldap->count()){
95 $ldap->cd($this->dn);
96 $ldap->modify($this->attrs);
97 }else{
98 $ldap->cd($this->dn);
99 $ldap->add($this->attrs);
100 }
101 if (!$ldap->success()){
102 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
103 }
104 if($this->initially_was_account){
105 $this->handle_post_events("modify");
106 new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
107 }else{
108 $this->handle_post_events("add");
109 new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
110 }
111 }
114 function check()
115 {
116 $message = plugin::check();
117 return($message);
118 }
121 function save_object()
122 {
123 if(isset($_POST['goTerminalServerPosted'])){
124 plugin::save_object();
126 $this->gotoSessionType = array();
127 foreach($this->gotoSessionTypes as $attr){
128 if(isset($_POST['gotoSessionType_'.$attr])){
129 $this->gotoSessionType[] = $attr;
130 }
131 }
133 if($this->acl_is_writeable("goXdmcpIsEnabled")){
134 if(isset($_POST['goXdmcpIsEnabled'])){
135 $this->goXdmcpIsEnabled = true;
136 }else{
137 $this->goXdmcpIsEnabled = false;
138 }
139 }
140 }
141 }
144 function PrepareForCopyPaste($obj)
145 {
146 plugin::PrepareForCopyPaste($obj);
147 $tmp = array();
148 if(isset($obj['gotoSessionType'])){
149 for($i =0; $i < $obj['gotoSessionType']['count'] ; $i++){
150 $tmp[] = $obj['gotoSessionType'][$i];
151 }
152 }
153 $this->gotoSessionType = $tmp;
154 #$this->gotoSessionTypes= array("LDM","XDMCP","RDP","CITRIX");
155 $this->gotoSessionTypes= array("LDM","XDMCP", "SHELL", "TELNET");
156 }
159 /* Return plugin informations for acl handling */
160 static function plInfo()
161 {
162 return (array(
163 "plShortName" => _("Terminal service"),
164 "plDescription" => _("Terminal service")." ("._("Services").")",
165 "plSelfModify" => FALSE,
166 "plDepends" => array(),
167 "plPriority" => 87,
168 "plSection" => array("administration"),
169 "plRequirements"=> array(
170 'ldapSchema' => array('goTerminalServer' => '>=2.7'),
171 'onFailureDisablePlugin' => array(get_class())
172 ),
173 "plCategory" => array("server"),
176 "plProvidedAcls"=> array(
177 "start" => _("Start"),
178 "stop" => _("Stop"),
179 "restart" => _("Restart"),
180 "goXdmcpIsEnabled" => _("Temporary disable login"))
181 ));
182 }
185 }
186 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
187 ?>