Code

Fixed spelling of terminal server services
[gosa.git] / gosa-plugins / goto / admin / systems / services / terminal / class_goTerminalServer.inc
1 <?php
3 class goTerminalServer extends goService{
4         
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     }
49   
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,$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",$tmp);
69     return($smarty->fetch(get_template_path("goTerminalServer.tpl",TRUE,dirname(__FILE__))));
70   }
73   function getListEntry()
74   {
75     $fields               = goService::getListEntry();
76     $fields['Message']    = _("Terminal service");
77     #$fields['AllowEdit']  = true;
78     return($fields);
79   }
82   function save()
83   {
84     plugin::save();
86     if(!$this->goXdmcpIsEnabled){
87       $this->attrs['goXdmcpIsEnabled'] = "0";
88     }
90     $this->attrs['gotoSessionType'] = array_values($this->gotoSessionType);
92     /* Check if this is a new entry ... add/modify */
93     $ldap = $this->config->get_ldap_link();
94     $ldap->cat($this->dn,array("objectClass"));
95     if($ldap->count()){
96       $ldap->cd($this->dn);
97       $ldap->modify($this->attrs);
98     }else{
99       $ldap->cd($this->dn);
100       $ldap->add($this->attrs);
101     }
102     if (!$ldap->success()){
103       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
104     }
105     if($this->initially_was_account){
106       $this->handle_post_events("modify");
107       new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
108     }else{
109       $this->handle_post_events("add");
110       new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
111     }
112   }
115   function check()
116   { 
117     $message = plugin::check();
118     return($message);
119   }
122   function save_object()
123   {
124     if(isset($_POST['goTerminalServerPosted'])){
125       plugin::save_object();
127       $this->gotoSessionType = array();
128       foreach($this->gotoSessionTypes as $attr){
129         if(isset($_POST['gotoSessionType_'.$attr])){
130           $this->gotoSessionType[] = $attr;
131         }
132       }
134       if($this->acl_is_writeable("goXdmcpIsEnabled")){
135         if(isset($_POST['goXdmcpIsEnabled'])){
136           $this->goXdmcpIsEnabled = true;
137         }else{
138           $this->goXdmcpIsEnabled = false;
139         }
140       }
141     }
142   } 
145   function PrepareForCopyPaste($obj)
146   {
147     plugin::PrepareForCopyPaste($obj);
148     $tmp = array();
149     if(isset($obj['gotoSessionType'])){
150       for($i =0; $i < $obj['gotoSessionType']['count'] ; $i++){
151         $tmp[] = $obj['gotoSessionType'][$i];
152       }
153     }
154     $this->gotoSessionType = $tmp;
155     #$this->gotoSessionTypes= array("LDM","XDMCP","RDP","CITRIX"); 
156     $this->gotoSessionTypes= array("LDM","XDMCP", "SHELL", "TELNET"); 
157   }
160   /* Return plugin informations for acl handling */
161   static function plInfo()
162   {
163     return (array(
164           "plShortName"   => _("Terminal service"),
165           "plDescription" => _("Terminal service")." ("._("Services").")",
166           "plSelfModify"  => FALSE,
167           "plDepends"     => array(),
168           "plPriority"    => 87,
169           "plSection"     => array("administration"),
170           "plCategory"    => array("server"),
172           "plProvidedAcls"=> array(
173             "goXdmcpIsEnabled"  => _("Temporary disable login"))
174           ));
175   }
179 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
180 ?>