ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilChatroomConfigFileHandler Class Reference
+ Collaboration diagram for ilChatroomConfigFileHandler:

Public Member Functions

 createClientConfigFile (array $settings)
 Creates a client config file and saves it to the chatroom data directory. More...
 
 createServerConfigFile (array $settings)
 Creates a server config file and saves it to the chatroom data directory. More...
 

Protected Member Functions

 getClientFileContent (array $settings)
 Get the client config file content as json encoded string. More...
 
 writeDataToFile (string $content, string $filename)
 Writes $content to file named by $filename. More...
 
 createDataDirIfNotExists ()
 Creates a data directory for configuration files, if the directory does not already exists. More...
 
 getServerFileContent (array $settings)
 Get the server config file contetn as json encoded string. More...
 

Private Attributes

const CHATROOM_DATA_DIR = '/chatroom/'
 
const CHATROOM_CLIENT_CONFIG_FILENAME = 'client.cfg'
 
const CHATROOM_SERVER_CONFIG_FILENAME = 'server.cfg'
 

Detailed Description

Definition at line 28 of file class.ilChatroomConfigFileHandler.php.

Member Function Documentation

◆ createClientConfigFile()

ilChatroomConfigFileHandler::createClientConfigFile ( array  $settings)

Creates a client config file and saves it to the chatroom data directory.

Parameters
array$settings
Exceptions
Exception

Definition at line 39 of file class.ilChatroomConfigFileHandler.php.

References getClientFileContent(), and writeDataToFile().

39  : void
40  {
41  $content = $this->getClientFileContent($settings);
42  $this->writeDataToFile($content, self::CHATROOM_CLIENT_CONFIG_FILENAME);
43  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
writeDataToFile(string $content, string $filename)
Writes $content to file named by $filename.
getClientFileContent(array $settings)
Get the client config file content as json encoded string.
+ Here is the call graph for this function:

◆ createDataDirIfNotExists()

ilChatroomConfigFileHandler::createDataDirIfNotExists ( )
protected

Creates a data directory for configuration files, if the directory does not already exists.

Returns
string
Exceptions
RuntimeExceptionThrows Exception if data dir creation failed

Definition at line 101 of file class.ilChatroomConfigFileHandler.php.

References $path, ilFileUtils\getDataDir(), and ilFileUtils\makeDir().

Referenced by writeDataToFile().

101  : string
102  {
103  $path = ilFileUtils::getDataDir() . self::CHATROOM_DATA_DIR;
104 
105  if (!is_dir($path) && !ilFileUtils::makeDir($path)) {
106  throw new RuntimeException('Directory cannot be created');
107  }
108 
109  return $path;
110  }
$path
Definition: ltiservices.php:32
static getDataDir()
get data directory (outside webspace)
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createServerConfigFile()

ilChatroomConfigFileHandler::createServerConfigFile ( array  $settings)

Creates a server config file and saves it to the chatroom data directory.

Parameters
array$settings
Exceptions
Exception

Definition at line 117 of file class.ilChatroomConfigFileHandler.php.

References getServerFileContent(), and writeDataToFile().

117  : void
118  {
119  $content = $this->getServerFileContent($settings);
120  $this->writeDataToFile($content, self::CHATROOM_SERVER_CONFIG_FILENAME);
121  }
getServerFileContent(array $settings)
Get the server config file contetn as json encoded string.
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
writeDataToFile(string $content, string $filename)
Writes $content to file named by $filename.
+ Here is the call graph for this function:

◆ getClientFileContent()

ilChatroomConfigFileHandler::getClientFileContent ( array  $settings)
protected

Get the client config file content as json encoded string.

Parameters
array$settings
Returns
string

Definition at line 50 of file class.ilChatroomConfigFileHandler.php.

References $DIC, $type, ILIAS\Repository\int(), ilDBConstants\TYPE_INNODB, and ilDBConstants\TYPE_MYSQL.

Referenced by createClientConfigFile().

50  : string
51  {
52  global $DIC;
53 
54  // Dirty configuration swap: Ilias differentiates between InnoDB and MyISAM.
55  // MyISAM is configured as mysql, InnoDB as innodb.
56  // The client config file only needs information about driver not engine
57  $type = $DIC['ilClientIniFile']->readVariable('db', 'type');
58  if (in_array($type, [
61  ''
62  ], true)) {
63  $type = 'mysql';
64  }
65 
66  $settings['database'] = [
67  'type' => $type,
68  'host' => $DIC['ilClientIniFile']->readVariable('db', 'host'),
69  'port' => (int) $DIC['ilClientIniFile']->readVariable('db', 'port'),
70  'name' => $DIC['ilClientIniFile']->readVariable('db', 'name'),
71  'user' => $DIC['ilClientIniFile']->readVariable('db', 'user'),
72  'pass' => $DIC['ilClientIniFile']->readVariable('db', 'pass')
73  ];
74 
75  return json_encode($settings, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
76  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
$type
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getServerFileContent()

ilChatroomConfigFileHandler::getServerFileContent ( array  $settings)
protected

Get the server config file contetn as json encoded string.

Parameters
array$settings
Returns
string

Definition at line 128 of file class.ilChatroomConfigFileHandler.php.

Referenced by createServerConfigFile().

128  : string
129  {
130  unset($settings['ilias_proxy'], $settings['client_proxy'], $settings['ilias_url'], $settings['client_url']);
131 
132  return json_encode($settings, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
133  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
+ Here is the caller graph for this function:

◆ writeDataToFile()

ilChatroomConfigFileHandler::writeDataToFile ( string  $content,
string  $filename 
)
protected

Writes $content to file named by $filename.

Parameters
string$content
string$filename
Exceptions
RuntimeException

Definition at line 84 of file class.ilChatroomConfigFileHandler.php.

References $path, and createDataDirIfNotExists().

Referenced by createClientConfigFile(), and createServerConfigFile().

84  : void
85  {
87  $handle = fopen($path . $filename, 'wb');
88 
89  if (!fwrite($handle, $content)) {
90  throw new RuntimeException('Cannot write to file');
91  }
92 
93  fclose($handle);
94  }
$path
Definition: ltiservices.php:32
createDataDirIfNotExists()
Creates a data directory for configuration files, if the directory does not already exists...
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ CHATROOM_CLIENT_CONFIG_FILENAME

const ilChatroomConfigFileHandler::CHATROOM_CLIENT_CONFIG_FILENAME = 'client.cfg'
private

Definition at line 31 of file class.ilChatroomConfigFileHandler.php.

◆ CHATROOM_DATA_DIR

const ilChatroomConfigFileHandler::CHATROOM_DATA_DIR = '/chatroom/'
private

Definition at line 30 of file class.ilChatroomConfigFileHandler.php.

◆ CHATROOM_SERVER_CONFIG_FILENAME

const ilChatroomConfigFileHandler::CHATROOM_SERVER_CONFIG_FILENAME = 'server.cfg'
private

Definition at line 32 of file class.ilChatroomConfigFileHandler.php.


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