ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 

Data Fields

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

Protected Member Functions

 writeDataToFile ($content, $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...
 

Detailed Description

Definition at line 11 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 22 of file class.ilChatroomConfigFileHandler.php.

23 {
24 $content = $this->getClientFileContent($settings);
25 $this->writeDataToFile($content, self::CHATROOM_CLIENT_CONFIG_FILENAME);
26 }
writeDataToFile($content, $filename)
Writes $content to file named by $filename.

References writeDataToFile().

+ 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
ExceptionThrows Exception if data dir creation failed

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

90 {
92
93 if(!file_exists($path))
94 {
96 {
97 throw new Exception('Directory cannot be created');
98 }
99 }
100
101 return $path;
102 }
$path
Definition: aliased.php:25
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 $path, CHATROOM_DATA_DIR, ilUtil\getDataDir(), and ilUtil\makeDir().

Referenced by writeDataToFile().

+ 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 109 of file class.ilChatroomConfigFileHandler.php.

110 {
111 $content = $this->getServerFileContent($settings);
112 $this->writeDataToFile($content, self::CHATROOM_SERVER_CONFIG_FILENAME);
113 }
getServerFileContent(array $settings)
Get the server config file contetn as json encoded string.

References getServerFileContent(), and writeDataToFile().

+ Here is the call 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 120 of file class.ilChatroomConfigFileHandler.php.

121 {
122 unset($settings['ilias_proxy']);
123 unset($settings['client_proxy']);
124 unset($settings['ilias_url']);
125 unset($settings['client_url']);
126
127 return json_encode($settings, JSON_PRETTY_PRINT);
128 }

Referenced by createServerConfigFile().

+ Here is the caller graph for this function:

◆ writeDataToFile()

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

Writes $content to file named by $filename.

Parameters
string$content
string$filename
Exceptions
Exception

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

72 {
74 $handle = fopen($path . $filename, 'w');
75
76 if(!fwrite($handle, $content))
77 {
78 throw new Exception('Cannot write to file');
79 }
80
81 fclose($handle);
82 }
createDataDirIfNotExists()
Creates a data directory for configuration files, if the directory does not already exists.

References $filename, $path, and createDataDirIfNotExists().

Referenced by createClientConfigFile(), and createServerConfigFile().

+ 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'

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

◆ CHATROOM_DATA_DIR

const ilChatroomConfigFileHandler::CHATROOM_DATA_DIR = '/chatroom/'

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

Referenced by createDataDirIfNotExists().

◆ CHATROOM_SERVER_CONFIG_FILENAME

const ilChatroomConfigFileHandler::CHATROOM_SERVER_CONFIG_FILENAME = 'server.cfg'

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


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