19 declare(strict_types=1);
44 $DIC->database()->setLimit(1);
45 $query =
'SELECT * FROM ' . self::$settingsTable;
47 $rset = $DIC->database()->query($query);
48 if ($row = $DIC->database()->fetchObject($rset)) {
49 return new self((
int) $row->instance_id, $row);
52 throw new LogicException(
'Could not determine any default configuration');
73 $res = $DIC->database()->queryF(
74 "SELECT* FROM chatroom_admconfig WHERE instance_id = %s",
79 $row = $DIC->database()->fetchAssoc(
$res);
81 $DIC->database()->manipulateF(
82 "DELETE FROM chatroom_admconfig WHERE instance_id = %s",
90 if ($row[
'default_config'] !==
null) {
91 $def_conf = $row[
'default_config'];
94 if ($row[
'client_settings'] !==
null) {
95 $clnt_set = $row[
'client_settings'];
99 $DIC->database()->manipulateF(
101 INSERT INTO chatroom_admconfig 102 (instance_id, server_settings, default_config, client_settings) 103 VALUES (%s, %s, %s, %s)",
104 [
'integer',
'text',
'integer',
'text'],
105 [$this->config_id, json_encode($settings, JSON_THROW_ON_ERROR), $def_conf, $clnt_set]
116 $res = $DIC->database()->queryF(
117 "SELECT * FROM chatroom_admconfig WHERE instance_id = %s",
122 $row = $DIC->database()->fetchAssoc(
$res);
124 $DIC->database()->manipulateF(
125 "DELETE FROM chatroom_admconfig WHERE instance_id = %s",
130 ($row[
'default_config'] ??
null) !==
null ? $def_conf = $row[
'default_config'] : $def_conf =
"{}";
131 ($row[
'server_settings'] ??
null) !==
null ? $srv_set = $row[
'server_settings'] : $srv_set =
"{}";
133 $DIC->database()->manipulateF(
135 INSERT INTO chatroom_admconfig 136 (instance_id, server_settings, default_config, client_settings) 137 VALUES (%s, %s, %s, %s)",
148 json_encode($settings, JSON_THROW_ON_ERROR)
157 $query =
'SELECT * FROM ' . self::$settingsTable .
158 ' WHERE instance_id = ' . $DIC->database()->quote($this->config_id,
'integer');
160 if (($row = $DIC->database()->fetchAssoc($DIC->database()->query($query))) && $row[
'server_settings']) {
161 $settings = json_decode($row[
'server_settings'],
true, 512, JSON_THROW_ON_ERROR);
163 if (!isset($settings[
'protocol'])) {
164 $settings[
'protocol'] =
'http';
167 if (!isset($settings[
'log_level'])) {
168 $settings[
'log_level'] =
'info';
181 $query =
'SELECT * FROM ' . self::$settingsTable .
182 ' WHERE instance_id = ' . $DIC->database()->quote($this->config_id,
'integer');
183 if (($row = $DIC->database()->fetchAssoc($DIC->database()->query($query))) && $row[
'client_settings']) {
184 $settings = json_decode($row[
'client_settings'],
true, 512, JSON_THROW_ON_ERROR);
186 if (!isset($settings[
'client']) || !is_string($settings[
'client']) || $settings[
'client'] ===
'') {
190 if (is_string($settings[
'name'] ??
null) && $settings[
'name']) {
191 $settings[
'client_name'] = $settings[
'name'];
196 if (isset($settings[
'conversation_idle_state_in_minutes']) && is_numeric($settings[
'conversation_idle_state_in_minutes'])) {
197 $settings[
'conversation_idle_state_in_minutes'] = max(1, $settings[
'conversation_idle_state_in_minutes']);
199 $settings[
'conversation_idle_state_in_minutes'] = 1;
202 if (!isset($settings[
'auth']) || !is_array($settings[
'auth'])) {
203 $settings[
'auth'] = [];
205 if (!isset($settings[
'auth'][
'key']) || !is_string($settings[
'auth'][
'key'])) {
206 $settings[
'auth'][
'key'] =
'';
208 if (!isset($settings[
'auth'][
'secret']) || !is_string($settings[
'auth'][
'secret'])) {
209 $settings[
'auth'][
'secret'] =
'';
saveGeneralSettings(stdClass $settings)
Saves given $settings into settingsTable.
static getDefaultConfiguration()
Instantiates and returns ilChatroomAdmin object using instance_id and settings from settingsTable...
static string $settingsTable
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(private readonly int $config_id, private readonly ?stdClass $settings=null)
saveClientSettings(stdClass $settings)
Saves given client $settings into settingsTable.
getServerSettings()
Instantiates ilChatroomServerSettings object, sets data using $this->settings->server_settings and re...