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.

References $a_type, array, ilDBConstants\TYPE_INNODB, ilDBConstants\TYPE_MYSQL, ilDBConstants\TYPE_PDO_MYSQL_INNODB, ilDBConstants\TYPE_PDO_MYSQL_MYISAM, and writeDataToFile().

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

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

Referenced by writeDataToFile().

90  {
91  $path = ilUtil::getDataDir() . self::CHATROOM_DATA_DIR;
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 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:

◆ 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.

References getServerFileContent(), and writeDataToFile().

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.
writeDataToFile($content, $filename)
Writes $content to file named by $filename.
+ 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.

Referenced by createServerConfigFile().

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  }
+ 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.

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

Referenced by createClientConfigFile(), and createServerConfigFile().

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  }
$path
Definition: aliased.php:25
createDataDirIfNotExists()
Creates a data directory for configuration files, if the directory does not already exists...
+ 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.

◆ 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: