ILIAS  release_8 Revision v8.24
ilChatroomAdmin Class Reference

Class ilChatroomAdmin. More...

+ Collaboration diagram for ilChatroomAdmin:

Public Member Functions

 __construct (int $config_id, 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...
 

Private Attributes

int $config_id
 
stdClass $settings
 

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 ( int  $config_id,
stdClass  $settings = null 
)

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

35 {
36 $this->config_id = $config_id;
37 $this->settings = $settings;
38 }

References $config_id, $settings, and ILIAS\Repository\settings().

+ Here is the call graph for this function:

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 45 of file class.ilChatroomAdmin.php.

45 : self
46 {
47 global $DIC;
48
49 $DIC->database()->setLimit(1);
50 $query = 'SELECT * FROM ' . self::$settingsTable;
51
52 $rset = $DIC->database()->query($query);
53 if ($row = $DIC->database()->fetchObject($rset)) {
54 return new self((int) $row->instance_id, $row);
55 }
56
57 throw new LogicException('Could not determine any default configuration');
58 }
static string $settingsTable
global $DIC
Definition: feed.php:28
$query

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

Referenced by ilChatroomServerConnector\checkServerConnection(), ilObjChatroom\cloneObject(), ilObjChatroomGUI\getConnector(), and ilOnScreenChatAppEventListener\handleEvent().

+ 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 65 of file class.ilChatroomAdmin.php.

References ilChatroomServerSettings\loadDefault().

+ Here is the call graph for this function:

◆ loadClientSettings()

ilChatroomAdmin::loadClientSettings ( )

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

183 : array
184 {
185 global $DIC;
186
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);
191
192 if (!isset($settings['client']) || !is_string($settings['client']) || $settings['client'] === '') {
193 $settings['client'] = CLIENT_ID;
194 }
195
196 if (isset($settings['name']) && is_string($settings['name']) && !$settings['name'] === '') {
197 $settings['client_name'] = (string) $settings['name'];
198 } else {
199 $settings['client_name'] = CLIENT_ID;
200 }
201
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']);
204 } else {
205 $settings['conversation_idle_state_in_minutes'] = 1;
206 }
207
208 if (!isset($settings['auth']) || !is_array($settings['auth'])) {
209 $settings['auth'] = [];
210 }
211 if (!isset($settings['auth']['key']) || !is_string($settings['auth']['key'])) {
212 $settings['auth']['key'] = '';
213 }
214 if (!isset($settings['auth']['secret']) || !is_string($settings['auth']['secret'])) {
215 $settings['auth']['secret'] = '';
216 }
217
218 return $settings;
219 }
220
221 return [];
222 }
const CLIENT_ID
Definition: constants.php:41

References $DIC, $query, $settings, and CLIENT_ID.

◆ loadGeneralSettings()

ilChatroomAdmin::loadGeneralSettings ( )

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

159 : array
160 {
161 global $DIC;
162
163 $query = 'SELECT * FROM ' . self::$settingsTable .
164 ' WHERE instance_id = ' . $DIC->database()->quote($this->config_id, 'integer');
165
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);
168
169 if (!isset($settings['protocol'])) {
170 $settings['protocol'] = 'http';
171 }
172
173 if (!isset($settings['log_level'])) {
174 $settings['log_level'] = 'info';
175 }
176
177 return $settings;
178 }
179
180 return [];
181 }

References $DIC, $query, and $settings.

◆ saveClientSettings()

ilChatroomAdmin::saveClientSettings ( stdClass  $settings)

Saves given client $settings into settingsTable.

Parameters
stdClass$settings

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

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

References $DIC, $res, and $settings.

◆ saveGeneralSettings()

ilChatroomAdmin::saveGeneralSettings ( stdClass  $settings)

Saves given $settings into settingsTable.

Parameters
stdClass$settings

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

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

References $DIC, $res, and $settings.

Field Documentation

◆ $config_id

int ilChatroomAdmin::$config_id
private

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

Referenced by __construct().

◆ $settings

stdClass ilChatroomAdmin::$settings
private

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