ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilChatroomAdmin Class Reference

Class ilChatroomAdmin. More...

+ Collaboration diagram for ilChatroomAdmin:

Public Member Functions

 __construct (private readonly int $config_id, private readonly ?stdClass $settings=null)
 
 getServerSettings ()
 Instantiates ilChatroomServerSettings object, sets data using $this->settings->server_settings and returns object. More...
 
 saveGeneralSettings (stdClass $settings)
 Saves given $settings into settingsTable. More...
 
 saveClientSettings (stdClass $settings)
 Saves given client $settings into settingsTable. More...
 
 loadGeneralSettings ()
 
 loadClientSettings ()
 

Static Public Member Functions

static getDefaultConfiguration ()
 Instantiates and returns ilChatroomAdmin object using instance_id and settings from settingsTable. More...
 

Static Private Attributes

static string $settingsTable = 'chatroom_admconfig'
 

Detailed Description

Class ilChatroomAdmin.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$ \

Definition at line 27 of file class.ilChatroomAdmin.php.

Constructor & Destructor Documentation

◆ __construct()

ilChatroomAdmin::__construct ( private readonly int  $config_id,
private readonly ?stdClass  $settings = null 
)

Definition at line 31 of file class.ilChatroomAdmin.php.

32 {
33 }

Member Function Documentation

◆ getDefaultConfiguration()

static ilChatroomAdmin::getDefaultConfiguration ( )
static

Instantiates and returns ilChatroomAdmin object using instance_id and settings from settingsTable.

Returns
self

Definition at line 40 of file class.ilChatroomAdmin.php.

40 : self
41 {
42 global $DIC;
43
44 $DIC->database()->setLimit(1);
45 $query = 'SELECT * FROM ' . self::$settingsTable;
46
47 $rset = $DIC->database()->query($query);
48 if ($row = $DIC->database()->fetchObject($rset)) {
49 return new self((int) $row->instance_id, $row);
50 }
51
52 throw new LogicException('Could not determine any default configuration');
53 }
static string $settingsTable
global $DIC
Definition: shib_login.php:26

References $DIC, $settingsTable, and ILIAS\Repository\int().

Referenced by ilChatroomServerConnector\checkServerConnection(), ilObjChatroom\cloneObject(), ilObjChatroomGUI\getConnector(), and ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations\updateChatServer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getServerSettings()

ilChatroomAdmin::getServerSettings ( )

Instantiates ilChatroomServerSettings object, sets data using $this->settings->server_settings and returns object.

Returns
ilChatroomServerSettings

Definition at line 60 of file class.ilChatroomAdmin.php.

References ilChatroomServerSettings\loadDefault().

+ Here is the call graph for this function:

◆ loadClientSettings()

ilChatroomAdmin::loadClientSettings ( )

Definition at line 177 of file class.ilChatroomAdmin.php.

177 : array
178 {
179 global $DIC;
180
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);
185
186 if (!isset($settings['client']) || !is_string($settings['client']) || $settings['client'] === '') {
187 $settings['client'] = CLIENT_ID;
188 }
189
190 if (is_string($settings['name'] ?? null) && $settings['name']) {
191 $settings['client_name'] = $settings['name'];
192 } else {
193 $settings['client_name'] = CLIENT_ID;
194 }
195
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']);
198 } else {
199 $settings['conversation_idle_state_in_minutes'] = 1;
200 }
201
202 if (!isset($settings['auth']) || !is_array($settings['auth'])) {
203 $settings['auth'] = [];
204 }
205 if (!isset($settings['auth']['key']) || !is_string($settings['auth']['key'])) {
206 $settings['auth']['key'] = '';
207 }
208 if (!isset($settings['auth']['secret']) || !is_string($settings['auth']['secret'])) {
209 $settings['auth']['secret'] = '';
210 }
211
212 return $settings;
213 }
214
215 return [];
216 }
const CLIENT_ID
Definition: constants.php:41

References $DIC, and CLIENT_ID.

◆ loadGeneralSettings()

ilChatroomAdmin::loadGeneralSettings ( )

Definition at line 153 of file class.ilChatroomAdmin.php.

153 : array
154 {
155 global $DIC;
156
157 $query = 'SELECT * FROM ' . self::$settingsTable .
158 ' WHERE instance_id = ' . $DIC->database()->quote($this->config_id, 'integer');
159
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);
162
163 if (!isset($settings['protocol'])) {
164 $settings['protocol'] = 'http';
165 }
166
167 if (!isset($settings['log_level'])) {
168 $settings['log_level'] = 'info';
169 }
170
171 return $settings;
172 }
173
174 return [];
175 }

References $DIC.

◆ saveClientSettings()

ilChatroomAdmin::saveClientSettings ( stdClass  $settings)

Saves given client $settings into settingsTable.

Definition at line 112 of file class.ilChatroomAdmin.php.

112 : void
113 {
114 global $DIC;
115
116 $res = $DIC->database()->queryF(
117 "SELECT * FROM chatroom_admconfig WHERE instance_id = %s",
118 ['integer'],
119 [$this->config_id]
120 );
121
122 $row = $DIC->database()->fetchAssoc($res);
123
124 $DIC->database()->manipulateF(
125 "DELETE FROM chatroom_admconfig WHERE instance_id = %s",
126 ['integer'],
127 [$this->config_id]
128 );
129
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 = "{}";
132
133 $DIC->database()->manipulateF(
134 "
135 INSERT INTO chatroom_admconfig
136 (instance_id, server_settings, default_config, client_settings)
137 VALUES (%s, %s, %s, %s)",
138 [
139 'integer',
140 'text',
141 'integer',
142 'text'
143 ],
144 [
145 $this->config_id,
146 $srv_set,
147 $def_conf,
148 json_encode($settings, JSON_THROW_ON_ERROR)
149 ]
150 );
151 }
$res
Definition: ltiservices.php:69

References $DIC, and $res.

◆ saveGeneralSettings()

ilChatroomAdmin::saveGeneralSettings ( stdClass  $settings)

Saves given $settings into settingsTable.

Parameters
stdClass$settings

Definition at line 69 of file class.ilChatroomAdmin.php.

69 : void
70 {
71 global $DIC;
72
73 $res = $DIC->database()->queryF(
74 "SELECT* FROM chatroom_admconfig WHERE instance_id = %s",
75 ['integer'],
76 [$this->config_id]
77 );
78
79 $row = $DIC->database()->fetchAssoc($res);
80
81 $DIC->database()->manipulateF(
82 "DELETE FROM chatroom_admconfig WHERE instance_id = %s",
83 ['integer'],
84 [$this->config_id]
85 );
86
87 $def_conf = '{}';
88 $clnt_set = '{}';
89 if (is_array($row)) {
90 if ($row['default_config'] !== null) {
91 $def_conf = $row['default_config'];
92 }
93
94 if ($row['client_settings'] !== null) {
95 $clnt_set = $row['client_settings'];
96 }
97 }
98
99 $DIC->database()->manipulateF(
100 "
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]
106 );
107 }

References $DIC, and $res.

Field Documentation

◆ $settingsTable

string ilChatroomAdmin::$settingsTable = 'chatroom_admconfig'
staticprivate

Definition at line 29 of file class.ilChatroomAdmin.php.

Referenced by getDefaultConfiguration().


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