ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilChatroomAdminViewTask Class Reference

Class ilChatroomAdminViewTask. More...

+ Inheritance diagram for ilChatroomAdminViewTask:
+ Collaboration diagram for ilChatroomAdminViewTask:

Public Member Functions

 __construct (ilChatroomObjectGUI $gui)
 Constructor Sets $this->gui using given $gui. More...
 
 forcePublicRoom ()
 
- Public Member Functions inherited from ilChatroomTaskHandler
 __construct (ilChatroomObjectGUI $gui)
 
 executeDefault ($requestedMethod)
 

Protected Member Functions

 writeClientSettingsToFile (array $settings)
 Writes client settings to client.properties file. More...
 
 getClientFileContent (array $settings)
 Formats content for client settings file. More...
 
 writeDataToFile (array $settings)
 Writes server settings to server.properties file. More...
 
 getFileContent (array $settings)
 Builds and formats content tot write in server.properties file. More...
 
 checkDirectory ()
 Checks if external chatroom directory exists or can be created. More...
 
 checkPrivHosts ($ipnumbers)
 Checks if a valid IP number or a comma-separated string of valid IP numbers is given. More...
 

Private Member Functions

 defaultActions ()
 

Private Attributes

 $gui
 
 $commonSettings
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilChatroomAdminViewTask::__construct ( ilChatroomObjectGUI  $gui)

Constructor Sets $this->gui using given $gui.

Parameters
ilChatroomObjectGUI$gui

Reimplemented from ilChatroomTaskHandler.

Definition at line 29 of file class.ilChatroomAdminViewTask.php.

30 {
31 $this->gui = $gui;
32 $this->commonSettings = new ilSetting('common');
33 }
ILIAS Setting Class.

References $gui.

Member Function Documentation

◆ checkDirectory()

ilChatroomAdminViewTask::checkDirectory ( )
protected

Checks if external chatroom directory exists or can be created.

Returns
string
Exceptions
Exception

Definition at line 244 of file class.ilChatroomAdminViewTask.php.

245 {
246 $srv_prp_path = ilUtil::getDataDir() . '/chatroom/';
247
248 if(!file_exists($srv_prp_path))
249 {
250 if(!ilUtil::makeDir($srv_prp_path))
251 {
252 throw new Exception('Directory cannot be created');
253 }
254 }
255
256 return $srv_prp_path;
257 }
static getDataDir()
get data directory (outside webspace)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References ilUtil\getDataDir(), and ilUtil\makeDir().

Referenced by writeClientSettingsToFile(), and writeDataToFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkPrivHosts()

ilChatroomAdminViewTask::checkPrivHosts (   $ipnumbers)
protected

Checks if a valid IP number or a comma-separated string of valid IP numbers is given.

Parameters
string$ipnumbers
Returns
bool

Definition at line 266 of file class.ilChatroomAdminViewTask.php.

267 {
268 $ipnumbers = preg_replace("/[^0-9.,]+/", "", $ipnumbers);
269 $ips = explode(',', $ipnumbers);
270
271 foreach($ips as $ip)
272 {
273 $ip_parts = explode('.', $ip);
274
275 if(!($ip_parts[0] <= 255 && $ip_parts[1] <= 255 && $ip_parts[2] <= 255 && $ip_parts[3] <= 255 &&
276 preg_match("!^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$!", $ip))
277 )
278 {
279 return false;
280 }
281 }
282
283 return true;
284 }

◆ defaultActions()

ilChatroomAdminViewTask::defaultActions ( )
private

Definition at line 441 of file class.ilChatroomAdminViewTask.php.

442 {
443 $chatSettings = new ilSetting('chatroom');
444 if($chatSettings->get('chat_enabled', false))
445 {
446 $this->forcePublicRoom();
447 }
448 }

References forcePublicRoom().

+ Here is the call graph for this function:

◆ forcePublicRoom()

ilChatroomAdminViewTask::forcePublicRoom ( )

Definition at line 453 of file class.ilChatroomAdminViewTask.php.

454 {
456 if(!$ref_id)
457 {
458 $this->createPublicRoom();
459 return;
460 }
461
463 if(!$instance)
464 {
465 $this->createPublicRoom();
466 return;
467 }
468
470 if(!$obj_id)
471 {
472 $this->createPublicRoom();
473 return;
474 }
475
477 {
478 $this->createPublicRoom();
479 return;
480 }
481
482 require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
483 ilChatroomInstaller::ensureCorrectPublicChatroomTreeLocation($ref_id);
484 }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupObjId($a_id)
_hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
$ref_id
Definition: sahs_server.php:39

References $ref_id, ilObjChatroom\_getPublicRefId(), ilObject\_hasUntrashedReference(), ilObject\_lookupObjId(), and ilObjectFactory\getInstanceByRefId().

Referenced by defaultActions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClientFileContent()

ilChatroomAdminViewTask::getClientFileContent ( array  $settings)
protected

Formats content for client settings file.

Parameters
array$settings
Returns
string

Definition at line 182 of file class.ilChatroomAdminViewTask.php.

183 {
184 $linebreak = "\n";
185
186 $content = 'hash = ' . $settings['hash'] . $linebreak;
187 $content .= 'name = ' . $settings['name'] . $linebreak;
188 $content .= 'url = ' . $settings['url'] . $linebreak;
189 $content .= 'user = ' . $settings['user'] . $linebreak;
190 $content .= 'password = ' . $settings['password'] . $linebreak;
191 $content .= 'client = ' . $settings['client'];
192
193 return $content;
194 }

Referenced by writeClientSettingsToFile().

+ Here is the caller graph for this function:

◆ getFileContent()

ilChatroomAdminViewTask::getFileContent ( array  $settings)
protected

Builds and formats content tot write in server.properties file.

Parameters
array$settings
Returns
string

Definition at line 221 of file class.ilChatroomAdminViewTask.php.

222 {
223 $linebreak = "\n";
224
225 $content = 'host = ' . $settings['address'] . $linebreak;
226 $content .= 'port = ' . $settings['port'] . $linebreak;
227 $content .= 'privileged_hosts = ' . $settings['priv_hosts'] . $linebreak;
228
229 $settings['protocol'] == 'https' ? $https = 1 : $https = 0;
230
231 $content .= 'https = ' . $https . $linebreak;
232 $content .= 'keystore = ' . $settings['keystore'] . $linebreak;
233 $content .= 'keypass = ' . $settings['keypass'] . $linebreak;
234 $content .= 'storepass = ' . $settings['storepass'];
235
236 return $content;
237 }
global $https
Definition: imgupload.php:15

References $https.

Referenced by writeDataToFile().

+ Here is the caller graph for this function:

◆ writeClientSettingsToFile()

ilChatroomAdminViewTask::writeClientSettingsToFile ( array  $settings)
protected

Writes client settings to client.properties file.

Parameters
array$settings
Exceptions
Exception

Definition at line 162 of file class.ilChatroomAdminViewTask.php.

163 {
164 if($srv_prp_path = $this->checkDirectory())
165 {
166 $handle = fopen($srv_prp_path . 'client.properties', 'w');
167
168 if(!fwrite($handle, $this->getClientFileContent($settings)))
169 {
170 throw new Exception('Cannot write to file');
171 }
172
173 fclose($handle);
174 }
175 }
getClientFileContent(array $settings)
Formats content for client settings file.
checkDirectory()
Checks if external chatroom directory exists or can be created.

References checkDirectory(), and getClientFileContent().

+ Here is the call graph for this function:

◆ writeDataToFile()

ilChatroomAdminViewTask::writeDataToFile ( array  $settings)
protected

Writes server settings to server.properties file.

Parameters
array$settings

Definition at line 201 of file class.ilChatroomAdminViewTask.php.

202 {
203 if($srv_prp_path = $this->checkDirectory())
204 {
205 $handle = fopen($srv_prp_path . 'server.properties', 'w');
206
207 if(!fwrite($handle, $this->getFileContent($settings)))
208 {
209 throw new Exception('Cannot write to file');
210 }
211
212 fclose($handle);
213 }
214 }
getFileContent(array $settings)
Builds and formats content tot write in server.properties file.

References checkDirectory(), and getFileContent().

+ Here is the call graph for this function:

Field Documentation

◆ $commonSettings

ilChatroomAdminViewTask::$commonSettings
private

Definition at line 22 of file class.ilChatroomAdminViewTask.php.

◆ $gui

ilChatroomAdminViewTask::$gui
private

Definition at line 17 of file class.ilChatroomAdminViewTask.php.

Referenced by __construct().


The documentation for this class was generated from the following file: