1 <?php
3 require_once("class_goService.inc");
5 class goTerminalServer extends goService{
7 var $cli_summary = "This pluign is used within the ServerService Pluign \nand indicates that this server supports asterisk management.";
8 var $cli_description = "Some longer text\nfor help";
9 var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
11 /* This plugin only writes its objectClass */
12 var $objectclasses = array("goTerminalServer");
13 var $attributes = array("goXdmcpIsEnabled", "goFontPath");
14 var $StatusFlag = "goTerminalServerStatus";
16 /* This class can't be assigned twice so it conflicts with itsself */
17 var $conflicts = array("goTerminalServer");
19 var $DisplayName = "";
20 var $dn = NULL;
21 var $acl;
22 var $cn = "";
23 var $goTerminalServerStatus = "";
24 var $goXdmcpIsEnabled = false;
25 var $goFontPath = "";
26 var $view_logged =FALSE;
29 function goTerminalServer($config,$dn)
30 {
31 goService::goService($config,$dn);
32 $this->DisplayName = _("Terminal service");
33 }
36 function execute()
37 {
38 $smarty = get_smarty();
40 if($this->is_account && !$this->view_logged){
41 $this->view_logged = TRUE;
42 new log("view","server/".get_class($this),$this->dn);
43 }
46 $tmp = $this->plinfo();
47 foreach($tmp['plProvidedAcls'] as $name => $translation){
48 $smarty->assign($name."ACL",$this->getacl($name));
49 }
51 foreach($this->attributes as $attr){
52 $smarty->assign($attr,$this->$attr);
53 }
54 return($smarty->fetch(get_template_path("goTerminalServer.tpl",TRUE,dirname(__FILE__))));
55 }
58 function getListEntry()
59 {
60 $fields = goService::getListEntry();
61 $fields['Message'] = _("Terminal service");
62 $fields['AllowEdit'] = true;
63 return($fields);
64 }
67 function save()
68 {
69 plugin::save();
71 if(!$this->goXdmcpIsEnabled){
72 $this->attrs['goXdmcpIsEnabled'] = "0";
73 }
75 /* Check if this is a new entry ... add/modify */
76 $ldap = $this->config->get_ldap_link();
77 $ldap->cat($this->dn,array("objectClass"));
78 if($ldap->count()){
79 $ldap->cd($this->dn);
80 $ldap->modify($this->attrs);
81 }else{
82 $ldap->cd($this->dn);
83 $ldap->add($this->attrs);
84 }
85 show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/terminalServer with dn '%s' failed."),$this->dn));
86 if($this->initially_was_account){
87 $this->handle_post_events("modify");
88 new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
89 }else{
90 $this->handle_post_events("add");
91 new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
92 }
93 }
96 function check()
97 {
98 $message = plugin::check();
99 if(empty($this->goFontPath)){
100 $message[]=_("Terminal server, must have fontpath specified.");
101 }
103 return($message);
104 }
107 function save_object()
108 {
109 if(isset($_POST['goTerminalServerPosted'])){
110 plugin::save_object();
111 if($this->acl_is_writeable("goXdmcpIsEnabled")){
112 if(isset($_POST['goXdmcpIsEnabled'])){
113 $this->goXdmcpIsEnabled = true;
114 }else{
115 $this->goXdmcpIsEnabled = false;
116 }
117 }
118 }
119 }
122 /* Return plugin informations for acl handling */
123 function plInfo()
124 {
125 return (array(
126 "plShortName" => _("Terminal service"),
127 "plDescription" => _("Terminal service")." ("._("Services").")",
128 "plSelfModify" => FALSE,
129 "plDepends" => array(),
130 "plPriority" => 87,
131 "plSection" => array("administration"),
132 "plCategory" => array("server"),
134 "plProvidedAcls"=> array(
135 "goXdmcpIsEnabled" => _("Temporary disable login"),
136 "goFontPath" => _("Font path"))
137 ));
138 }
141 }
142 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
143 ?>