ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilChatroomServerSettings.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
12 const PREFIX = '/backend';
13 private $port = '8585';
14 private $protocol = 'http://';
15 private $domain = '192.168.1.94';
16 private $instance = '123456';
17 private $smilies_enabled = false;
18 private $authKey;
19 private $authSecret;
21 private $clientUrl;
23 private $iliasUrl;
25
26 public static function loadDefault()
27 {
31 global $ilDB;
32
33 $query = 'SELECT * FROM chatroom_admconfig';
34 $rset = $ilDB->query($query);
35 $row = $ilDB->fetchAssoc($rset);
36
37 $client_settings = json_decode($row['client_settings']);
38 $server_settings = json_decode($row['server_settings']);
39
40 $settings = new ilChatroomServerSettings();
41 $settings->setPort($server_settings->port);
42 $settings->setProtocol($server_settings->protocol);
43 $settings->setInstance($client_settings->name);
44 $settings->setDomain($server_settings->address);
45 $settings->setSmiliesEnabled($client_settings->enable_smilies);
46 $settings->setAuthKey($client_settings->auth->key);
47 $settings->setAuthSecret($client_settings->auth->secret);
48 $settings->setClientUrlEnabled($server_settings->client_proxy);
49 $settings->setIliasUrlEnabled($server_settings->ilias_proxy);
50 $settings->setClientUrl($server_settings->client_url);
51 $settings->setIliasUrl($server_settings->ilias_url);
52 $settings->setSubDirectory($server_settings->sub_directory);
53
54 return $settings;
55 }
56
64 public function getURL($action, $scope = null)
65 {
66 $url = $this->generateIliasUrl() . self::PREFIX . '/' . $action . '/' . $this->getInstance();
67
68 if($scope !== null)
69 {
70 $url .= '/' . $scope;
71 }
72
73 return $url;
74 }
75
79 public function generateIliasUrl()
80 {
81 if($this->getIliasUrlEnabled())
82 {
83 $url = $this->getIliasUrl();
84
85 if(strpos($url, '://') === false)
86 {
87 $url = $this->getProtocol() . $url;
88 }
89
90 return $url;
91 }
92 return $this->getBaseURL();
93 }
94
98 public function getIliasUrlEnabled()
99 {
101 }
102
107 {
108 $this->iliasUrlEnabled = $iliasUrlEnabled;
109 }
110
115 public function getProtocol()
116 {
117 return $this->protocol;
118 }
119
124 public function setProtocol($protocol)
125 {
126 if(strpos($protocol, '://') === false)
127 {
128 $this->protocol = $protocol . '://';
129 }
130 }
131
135 public function getIliasUrl()
136 {
137 return $this->iliasUrl;
138 }
139
143 public function setIliasUrl($iliasUrl)
144 {
145 $this->iliasUrl = $iliasUrl;
146 }
147
154 public function getBaseURL()
155 {
156 return $this->getProtocol() . $this->getDomain() . ':' . $this->getPort();
157 }
158
163 public function getDomain()
164 {
165 return $this->domain;
166 }
167
172 public function setDomain($domain)
173 {
174 $this->domain = $domain;
175 }
176
181 public function getPort()
182 {
183 return $this->port;
184 }
185
190 public function setPort($port)
191 {
192 $this->port = $port;
193 }
194
199 public function getInstance()
200 {
201 return $this->instance;
202 }
203
208 public function setInstance($instance)
209 {
210 $this->instance = $instance;
211 }
212
216 public function generateClientUrl()
217 {
218 if($this->getClientUrlEnabled())
219 {
220 $url = $this->getClientUrl();
221
222 if(strpos($url, '://') === false)
223 {
224 $url = $this->getProtocol() . $url;
225 }
226
227 return $url;
228 }
229 return $this->getBaseURL();
230 }
231
235 public function getClientUrlEnabled()
236 {
238 }
239
244 {
245 $this->clientUrlEnabled = $clientUrlEnabled;
246 }
247
251 public function getClientUrl()
252 {
253 return $this->clientUrl;
254 }
255
259 public function setClientUrl($clientUrl)
260 {
261 $this->clientUrl = $clientUrl;
262 }
263
267 public function getSmiliesEnabled()
268 {
269 return (bool)$this->smilies_enabled;
270 }
271
275 public function setSmiliesEnabled($a_bool)
276 {
277 $this->smilies_enabled = $a_bool;
278 }
279
283 public function getAuthKey()
284 {
285 return $this->authKey;
286 }
287
291 public function setAuthKey($authKey)
292 {
293 $this->authKey = $authKey;
294 }
295
299 public function getAuthSecret()
300 {
301 return $this->authSecret;
302 }
303
307 public function setAuthSecret($authSecret)
308 {
309 $this->authSecret = $authSecret;
310 }
311
315 public function getSubDirectory()
316 {
317 return $this->subDirectory;
318 }
319
324 {
325 $this->subDirectory = $subDirectory;
326 }
327}
An exception for terminatinating execution or to throw for unit testing.
Class ilChatroomServerSettings.
setPort($port)
Sets $this->port using given $port.
setInstance($instance)
Sets $this->instance using given $instance.
getURL($action, $scope=null)
Creates URL by calling $this->getBaseURL and using given $action and $scope and returns it.
setProtocol($protocol)
Sets $this->protocol using given $protocol.
getBaseURL()
Returns base URL Creates base URL by calling $this->getProtocol(), $this->getDomain() and $this->getP...
setDomain($domain)
Sets $this->domain using given $domain.
$url
Definition: shib_logout.php:72
global $ilDB