ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilChatroomViewTask Class Reference

Class ilChatroomViewTask. More...

+ Inheritance diagram for ilChatroomViewTask:
+ Collaboration diagram for ilChatroomViewTask:

Public Member Functions

 __construct (ilChatroomObjectGUI $gui)
 Constructor Sets $this->gui using given $gui. More...
 
 forcePublicRoom ()
 
 __construct (ilChatroomObjectGUI $gui)
 
 renderFileUploadForm (ilTemplate $roomTpl)
 Prepares Fileupload form and displays it. More...
 
- 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 ()
 
 cancelJoin ($message)
 Calls ilUtil::sendFailure method using given $message as parameter. More...
 

Private Attributes

 $gui
 
 $commonSettings
 

Detailed Description

Class ilChatroomViewTask.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilChatroomViewTask.php.

Constructor & Destructor Documentation

◆ __construct() [1/2]

ilChatroomViewTask::__construct ( ilChatroomObjectGUI  $gui)

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

Parameters
ilChatroomObjectGUI$gui

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

References $gui, $ilCtrl, $lng, checkPrivHosts(), ilUtil\sendFailure(), ilUtil\sendInfo(), ilUtil\sendSuccess(), writeClientSettingsToFile(), and writeDataToFile().

30  {
31  $this->gui = $gui;
32  $this->commonSettings = new ilSetting('common');
33  }
ILIAS Setting Class.
+ Here is the call graph for this function:

◆ __construct() [2/2]

ilChatroomViewTask::__construct ( ilChatroomObjectGUI  $gui)
Parameters
ilChatroomObjectGUI$gui

Definition at line 23 of file class.ilChatroomViewTask.php.

References $gui.

24  {
25  $this->gui = $gui;
26  }

Member Function Documentation

◆ cancelJoin()

◆ checkDirectory()

ilChatroomViewTask::checkDirectory ( )
protected

Checks if external chatroom directory exists or can be created.

Returns
string
Exceptions
Exception

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

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

Referenced by writeClientSettingsToFile(), and writeDataToFile().

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 makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkPrivHosts()

ilChatroomViewTask::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.ilChatroomViewTask.php.

References $data, $ilCtrl, $lng, $serverSettings, $tpl, ilUtil\_getHttpPath(), ilChatroomServerConnector\checkServerConnection(), ilChatroom\checkUserPermissions(), defaultActions(), ilChatroomTaskHandler\executeDefault(), and ilUtil\sendInfo().

Referenced by __construct().

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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ defaultActions()

ilChatroomViewTask::defaultActions ( )
private

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

References forcePublicRoom().

Referenced by checkPrivHosts().

442  {
443  $chatSettings = new ilSetting('chatroom');
444  if($chatSettings->get('chat_enabled', false))
445  {
446  $this->forcePublicRoom();
447  }
448  }
ILIAS Setting Class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ forcePublicRoom()

ilChatroomViewTask::forcePublicRoom ( )

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

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

Referenced by defaultActions().

454  {
456  if(!$ref_id)
457  {
458  $this->createPublicRoom();
459  return;
460  }
461 
462  $instance = ilObjectFactory::getInstanceByRefId($ref_id, false);
463  if(!$instance)
464  {
465  $this->createPublicRoom();
466  return;
467  }
468 
469  $obj_id = ilObject::_lookupObjId($ref_id);
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClientFileContent()

ilChatroomViewTask::getClientFileContent ( array  $settings)
protected

Formats content for client settings file.

Parameters
array$settings
Returns
string

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

Referenced by writeClientSettingsToFile().

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  }
+ Here is the caller graph for this function:

◆ getFileContent()

ilChatroomViewTask::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.ilChatroomViewTask.php.

References $https.

Referenced by writeDataToFile().

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
+ Here is the caller graph for this function:

◆ renderFileUploadForm()

ilChatroomViewTask::renderFileUploadForm ( ilTemplate  $roomTpl)

Prepares Fileupload form and displays it.

Parameters
ilTemplate$roomTpl

Definition at line 637 of file class.ilChatroomViewTask.php.

References $ilCtrl, $lng, ilUtil\sendFailure(), and HTML_Template_IT\setVariable().

Referenced by cancelJoin().

638  {
639  // @todo: Not implemented yet
640  return;
641 
642  require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
643  $formFactory = new ilChatroomFormFactory();
644  $file_upload = $formFactory->getFileUploadForm();
645  //$file_upload->setFormAction( $ilCtrl->getFormAction($this->gui, 'UploadFile-uploadFile') );
646  $roomTpl->setVariable('FILE_UPLOAD', $file_upload->getHTML());
647  }
Class ilChatroomFormFactory.
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:626
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeClientSettingsToFile()

ilChatroomViewTask::writeClientSettingsToFile ( array  $settings)
protected

Writes client settings to client.properties file.

Parameters
array$settings
Exceptions
Exception

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

References checkDirectory(), and getClientFileContent().

Referenced by __construct().

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  }
checkDirectory()
Checks if external chatroom directory exists or can be created.
getClientFileContent(array $settings)
Formats content for client settings file.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeDataToFile()

ilChatroomViewTask::writeDataToFile ( array  $settings)
protected

Writes server settings to server.properties file.

Parameters
array$settings

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

References checkDirectory(), and getFileContent().

Referenced by __construct().

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  }
checkDirectory()
Checks if external chatroom directory exists or can be created.
getFileContent(array $settings)
Builds and formats content tot write in server.properties file.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $commonSettings

ilChatroomViewTask::$commonSettings
private

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

◆ $gui

ilChatroomViewTask::$gui
private

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

Referenced by __construct().


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