ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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...
 

Data Fields

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

Protected Member Functions

 getClientFileContent (array $settings)
 Get the client config file content as json encoded string. More...
 
 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 getClientFileContent(), 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.
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
ExceptionThrows Exception if data dir creation failed

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

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

Referenced by writeDataToFile().

87  {
88  $path = ilUtil::getDataDir() . self::CHATROOM_DATA_DIR;
89 
90  if (!file_exists($path)) {
91  if (!ilUtil::makeDir($path)) {
92  throw new Exception('Directory cannot be created');
93  }
94  }
95 
96  return $path;
97  }
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 104 of file class.ilChatroomConfigFileHandler.php.

References getServerFileContent(), and writeDataToFile().

105  {
106  $content = $this->getServerFileContent($settings);
107  $this->writeDataToFile($content, self::CHATROOM_SERVER_CONFIG_FILENAME);
108  }
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:

◆ getClientFileContent()

ilChatroomConfigFileHandler::getClientFileContent ( array  $settings)
protected

Get the client config file content as json encoded string.

Parameters
array$settings
Returns
string

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

References $a_type, $DIC, $type, ilDBConstants\TYPE_INNODB, ilDBConstants\TYPE_MYSQL, ilDBConstants\TYPE_PDO_MYSQL_INNODB, and ilDBConstants\TYPE_PDO_MYSQL_MYISAM.

Referenced by createClientConfigFile().

34  {
35  global $DIC;
36 
37  // Dirty configuration swap: Ilias differentiates between InnoDB and MyISAM.
38  // MyISAM is configured as mysql, InnoDB as innodb.
39  // The client config file only needs information about driver not engine
40  $type = $a_type = $DIC['ilClientIniFile']->readVariable('db', 'type');
41  if (in_array($type, array(
46  ''
47  ))) {
48  $type = 'mysql';
49  }
50 
51  $settings['database'] = array(
52  'type' => $type,
53  'host' => $DIC['ilClientIniFile']->readVariable('db', 'host'),
54  'port' => (int) $DIC['ilClientIniFile']->readVariable('db', 'port'),
55  'name' => $DIC['ilClientIniFile']->readVariable('db', 'name'),
56  'user' => $DIC['ilClientIniFile']->readVariable('db', 'user'),
57  'pass' => $DIC['ilClientIniFile']->readVariable('db', 'pass')
58  );
59 
60  return json_encode($settings, JSON_PRETTY_PRINT);
61  }
$type
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46
+ 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 115 of file class.ilChatroomConfigFileHandler.php.

Referenced by createServerConfigFile().

116  {
117  unset($settings['ilias_proxy']);
118  unset($settings['client_proxy']);
119  unset($settings['ilias_url']);
120  unset($settings['client_url']);
121 
122  return json_encode($settings, JSON_PRETTY_PRINT);
123  }
+ 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 69 of file class.ilChatroomConfigFileHandler.php.

References $filename, and createDataDirIfNotExists().

Referenced by createClientConfigFile(), and createServerConfigFile().

70  {
71  $path = $this->createDataDirIfNotExists();
72  $handle = fopen($path . $filename, 'w');
73 
74  if (!fwrite($handle, $content)) {
75  throw new Exception('Cannot write to file');
76  }
77 
78  fclose($handle);
79  }
createDataDirIfNotExists()
Creates a data directory for configuration files, if the directory does not already exists...
$filename
Definition: buildRTE.php:89
+ 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: