ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
28 global $DIC;
29
30 $query = 'SELECT * FROM chatroom_admconfig';
31 $rset = $DIC->database()->query($query);
32 $row = $DIC->database()->fetchAssoc($rset);
33
34 $client_settings = json_decode($row['client_settings']);
35 $server_settings = json_decode($row['server_settings']);
36
37 $settings = new ilChatroomServerSettings();
38 $settings->setPort($server_settings->port);
39 $settings->setProtocol($server_settings->protocol);
40 $settings->setInstance($client_settings->name);
41 $settings->setDomain($server_settings->address);
42 $settings->setSmiliesEnabled($client_settings->enable_smilies);
43 $settings->setAuthKey($client_settings->auth->key);
44 $settings->setAuthSecret($client_settings->auth->secret);
45 $settings->setClientUrlEnabled($server_settings->client_proxy);
46 $settings->setIliasUrlEnabled($server_settings->ilias_proxy);
47 $settings->setClientUrl($server_settings->client_url);
48 $settings->setIliasUrl($server_settings->ilias_url);
49 $settings->setSubDirectory($server_settings->sub_directory);
50
51 return $settings;
52 }
53
61 public function getURL($action, $scope = null)
62 {
63 $url = $this->generateIliasUrl() . self::PREFIX . '/' . $action . '/' . $this->getInstance();
64
65 if ($scope !== null) {
66 $url .= '/' . $scope;
67 }
68
69 return $url;
70 }
71
75 public function generateIliasUrl()
76 {
77 if ($this->getIliasUrlEnabled()) {
78 $url = $this->getIliasUrl();
79
80 if (strpos($url, '://') === false) {
81 $url = $this->getProtocol() . $url;
82 }
83
84 return $url;
85 }
86 return $this->getBaseURL();
87 }
88
92 public function getIliasUrlEnabled()
93 {
95 }
96
101 {
102 $this->iliasUrlEnabled = $iliasUrlEnabled;
103 }
104
109 public function getProtocol()
110 {
111 return $this->protocol;
112 }
113
118 public function setProtocol($protocol)
119 {
120 if (strpos($protocol, '://') === false) {
121 $this->protocol = $protocol . '://';
122 }
123 }
124
128 public function getIliasUrl()
129 {
130 return $this->iliasUrl;
131 }
132
136 public function setIliasUrl($iliasUrl)
137 {
138 $this->iliasUrl = $iliasUrl;
139 }
140
147 public function getBaseURL()
148 {
149 return $this->getProtocol() . $this->getDomain() . ':' . $this->getPort();
150 }
151
156 public function getDomain()
157 {
158 return $this->domain;
159 }
160
165 public function setDomain($domain)
166 {
167 $this->domain = $domain;
168 }
169
174 public function getPort()
175 {
176 return $this->port;
177 }
178
183 public function setPort($port)
184 {
185 $this->port = $port;
186 }
187
192 public function getInstance()
193 {
194 return $this->instance;
195 }
196
201 public function setInstance($instance)
202 {
203 $this->instance = $instance;
204 }
205
209 public function generateClientUrl()
210 {
211 if ($this->getClientUrlEnabled()) {
212 $url = $this->getClientUrl();
213
214 if (strpos($url, '://') === false) {
215 $url = $this->getProtocol() . $url;
216 }
217
218 return $url;
219 }
220 return $this->getBaseURL();
221 }
222
226 public function getClientUrlEnabled()
227 {
229 }
230
235 {
236 $this->clientUrlEnabled = $clientUrlEnabled;
237 }
238
242 public function getClientUrl()
243 {
244 return $this->clientUrl;
245 }
246
250 public function setClientUrl($clientUrl)
251 {
252 $this->clientUrl = $clientUrl;
253 }
254
258 public function getSmiliesEnabled()
259 {
260 return (bool) $this->smilies_enabled;
261 }
262
266 public function setSmiliesEnabled($a_bool)
267 {
268 $this->smilies_enabled = $a_bool;
269 }
270
274 public function getAuthKey()
275 {
276 return $this->authKey;
277 }
278
282 public function setAuthKey($authKey)
283 {
284 $this->authKey = $authKey;
285 }
286
290 public function getAuthSecret()
291 {
292 return $this->authSecret;
293 }
294
298 public function setAuthSecret($authSecret)
299 {
300 $this->authSecret = $authSecret;
301 }
302
306 public function getSubDirectory()
307 {
308 return $this->subDirectory;
309 }
310
315 {
316 $this->subDirectory = $subDirectory;
317 }
318}
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.
$action
$query
$url
global $DIC
Definition: saml.php:7