19declare(strict_types=1);
49 $DIC->database()->setLimit(1);
53 if ($row =
$DIC->database()->fetchObject($rset)) {
54 return new self((
int) $row->instance_id, $row);
57 throw new LogicException(
'Could not determine any default configuration');
79 "SELECT* FROM chatroom_admconfig WHERE instance_id = %s",
84 $row =
$DIC->database()->fetchAssoc(
$res);
86 $DIC->database()->manipulateF(
87 "DELETE FROM chatroom_admconfig WHERE instance_id = %s",
95 if ($row[
'default_config'] !==
null) {
96 $def_conf = $row[
'default_config'];
99 if ($row[
'client_settings'] !==
null) {
100 $clnt_set = $row[
'client_settings'];
104 $DIC->database()->manipulateF(
106 INSERT INTO chatroom_admconfig
107 (instance_id, server_settings, default_config, client_settings)
108 VALUES (%s, %s, %s, %s)",
109 [
'integer',
'text',
'integer',
'text'],
110 [$this->config_id, json_encode(
$settings, JSON_THROW_ON_ERROR), $def_conf, $clnt_set]
123 "SELECT * FROM chatroom_admconfig WHERE instance_id = %s",
128 $row =
$DIC->database()->fetchAssoc(
$res);
130 $DIC->database()->manipulateF(
131 "DELETE FROM chatroom_admconfig WHERE instance_id = %s",
136 ($row[
'default_config'] ??
null) !==
null ? $def_conf = $row[
'default_config'] : $def_conf =
"{}";
137 ($row[
'server_settings'] ??
null) !==
null ? $srv_set = $row[
'server_settings'] : $srv_set =
"{}";
139 $DIC->database()->manipulateF(
141 INSERT INTO chatroom_admconfig
142 (instance_id, server_settings, default_config, client_settings)
143 VALUES (%s, %s, %s, %s)",
154 json_encode(
$settings, JSON_THROW_ON_ERROR)
163 $query =
'SELECT * FROM ' . self::$settingsTable .
164 ' WHERE instance_id = ' .
$DIC->database()->quote($this->config_id,
'integer');
166 if (($row =
$DIC->database()->fetchAssoc(
$DIC->database()->query(
$query))) && $row[
'server_settings']) {
167 $settings = json_decode($row[
'server_settings'],
true, 512, JSON_THROW_ON_ERROR);
187 $query =
'SELECT * FROM ' . self::$settingsTable .
188 ' WHERE instance_id = ' .
$DIC->database()->quote($this->config_id,
'integer');
189 if (($row =
$DIC->database()->fetchAssoc(
$DIC->database()->query(
$query))) && $row[
'client_settings']) {
190 $settings = json_decode($row[
'client_settings'],
true, 512, JSON_THROW_ON_ERROR);
202 if (isset(
$settings[
'conversation_idle_state_in_minutes']) && is_numeric(
$settings[
'conversation_idle_state_in_minutes'])) {
203 $settings[
'conversation_idle_state_in_minutes'] = max(1,
$settings[
'conversation_idle_state_in_minutes']);
205 $settings[
'conversation_idle_state_in_minutes'] = 1;
static getDefaultConfiguration()
Instantiates and returns ilChatroomAdmin object using instance_id and settings from settingsTable.
saveClientSettings(stdClass $settings)
Saves given client $settings into settingsTable.
static string $settingsTable
getServerSettings()
Instantiates ilChatroomServerSettings object, sets data using $this->settings->server_settings and re...
saveGeneralSettings(stdClass $settings)
Saves given $settings into settingsTable.
__construct(int $config_id, stdClass $settings=null)
Class ilChatroomServerSettings.