ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\User\Setup\DBUpdateSteps11 Class Reference
+ Inheritance diagram for ILIAS\User\Setup\DBUpdateSteps11:
+ Collaboration diagram for ILIAS\User\Setup\DBUpdateSteps11:

Public Member Functions

 prepare (\ilDBInterface $db)
 Prepare the execution of the steps. More...
 
 step_1 ()
 
 step_2 ()
 
 step_3 ()
 
 step_4 ()
 
 step_5 ()
 
 step_6 ()
 
 step_7 ()
 
 step_8 ()
 
 step_9 ()
 
 step_10 ()
 
 step_11 ()
 
 step_12 ()
 
 step_13 ()
 
 prepare (\ilDBInterface $db)
 Prepare the execution of the steps. More...
 

Private Member Functions

 insertSetting (string $keyword, string $value)
 
 migrateBadges (string $old_value, string $new_value)
 

Private Attributes

ilDBInterface $db
 
UUIDFactory $uuid_factory
 

Detailed Description

Definition at line 26 of file DBUpdateSteps11.php.

Member Function Documentation

◆ insertSetting()

ILIAS\User\Setup\DBUpdateSteps11::insertSetting ( string  $keyword,
string  $value 
)
private

Definition at line 37 of file DBUpdateSteps11.php.

40 : void {
41 if ($this->db->fetchObject(
42 $this->db->query(
43 "SELECT COUNT(*) cnt FROM settings WHERE module = 'common' AND keyword='{$keyword}'"
44 )
45 )?->cnt > 0
46 ) {
47 return;
48 }
49
50 $this->db->insert(
51 'settings',
52 [
53 'module' => [
55 'common'
56 ],
57 'keyword' => [
59 $keyword
60 ],
61 'value' => [
63 $value
64 ],
65 ]
66 );
67 }

◆ migrateBadges()

ILIAS\User\Setup\DBUpdateSteps11::migrateBadges ( string  $old_value,
string  $new_value 
)
private

Definition at line 69 of file DBUpdateSteps11.php.

72 : void {
73 $query = $this->db->query("SELECT id, conf FROM badge_badge WHERE type_id='user/profile' AND conf LIKE '%$old_value%'");
74 while (($badge = $this->db->fetchObject($query)) !== null) {
75 $config_array = unserialize($badge->conf, ['allowed_classes' => false]);
76 if (!array_key_exists('profile', $config_array)) {
77 continue;
78 }
79 $config_array['profile'] = array_map(
80 static function (string $v) use ($old_value, $new_value): string {
81 if ($v !== "chk_{$old_value}") {
82 return $v;
83 }
84
85 return "chk_{$new_value}";
86 },
87 $config_array['profile']
88 );
89 $this->db->update(
90 'badge_badge',
91 [
92 'conf' => [\ilDBConstants::T_TEXT, serialize($config_array)]
93 ],
94 [
95 'id' => [\ilDBConstants::T_INTEGER, $badge->id]
96 ]
97 );
98 }
99 }

References ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

◆ prepare()

ILIAS\User\Setup\DBUpdateSteps11::prepare ( \ilDBInterface  $db)

Prepare the execution of the steps.

Do not use anything from the globals or the DIC inside your steps, only use the instance of the database provided here.

Implements ilDatabaseUpdateSteps.

Definition at line 31 of file DBUpdateSteps11.php.

31 : void
32 {
33 $this->db = $db;
34 $this->uuid_factory = new UUIDFactory();
35 }

References ILIAS\User\Setup\DBUpdateSteps11\$db.

◆ step_1()

ILIAS\User\Setup\DBUpdateSteps11::step_1 ( )

Definition at line 101 of file DBUpdateSteps11.php.

101 : void
102 {
103 if (!$this->db->tableColumnExists('mail_template', 'att_rid')) {
104 $this->db->addTableColumn(
105 'mail_template',
106 'att_rid',
107 [
108 'type' => \ilDBConstants::T_TEXT,
109 'length' => 64
110 ]
111 );
112 }
113 }

References ilDBConstants\T_TEXT.

◆ step_10()

ILIAS\User\Setup\DBUpdateSteps11::step_10 ( )

Definition at line 480 of file DBUpdateSteps11.php.

480 : void
481 {
482 if ($this->db->tableColumnExists('usr_data', 'time_limit_message')) {
483 $this->db->dropTableColumn('usr_data', 'time_limit_message');
484 }
485
486 if ($this->db->tableColumnExists('usr_data', 'sel_country')) {
487 $this->db->renameTableColumn('usr_data', 'country', 'old_country');
488 $this->db->renameTableColumn('usr_data', 'sel_country', 'country');
489 }
490 }

◆ step_11()

ILIAS\User\Setup\DBUpdateSteps11::step_11 ( )

Definition at line 492 of file DBUpdateSteps11.php.

492 : void
493 {
494 $this->db->modifyTableColumn('usr_pref', 'keyword', ['length' => 74]);
495 }

◆ step_12()

ILIAS\User\Setup\DBUpdateSteps11::step_12 ( )

Definition at line 497 of file DBUpdateSteps11.php.

497 : void
498 {
499 if ($this->db->fetchObject(
500 $this->db->query(
501 'SELECT COUNT(*) cnt FROM settings WHERE module = "common"' . PHP_EOL
502 . 'AND keyword="usr_settings_changeable_by_user_starting_point"'
503 )
504 )?->cnt <= 0
505 ) {
506 $this->db->update(
507 'settings',
508 [
509 'keyword' => [
511 'usr_settings_changeable_by_user_starting_point'
512 ]
513 ],
514 [
515 'module' => [
517 'common'
518 ],
519 'keyword' => [
521 'usr_starting_point_personal'
522 ]
523 ]
524 );
525 } else {
526 $this->db->manipulate(
527 'DELETE FROM settings WHERE module = "common" AND keyword= "usr_starting_point_personal"'
528 );
529 }
530
531 $this->insertSetting('usr_settings_changeable_lua_starting_point', '1');
532 $this->insertSetting('usr_settings_export_starting_point', '1');
533
534 foreach ([
535 'last_visited',
536 'timezone',
537 'date_format',
538 'time_format'
539 ] as $setting) {
540 $this->insertSetting("usr_settings_changeable_by_user_{$setting}", '1');
541 $this->insertSetting("usr_settings_changeable_lua_{$setting}", '1');
542 $this->insertSetting("usr_settings_export_{$setting}", '1');
543 }
544 }
insertSetting(string $keyword, string $value)
ilSetting $setting
Definition: class.ilias.php:68

References ilDBConstants\T_TEXT.

◆ step_13()

ILIAS\User\Setup\DBUpdateSteps11::step_13 ( )

Definition at line 546 of file DBUpdateSteps11.php.

546 : void
547 {
548 $this->db->update(
549 'usr_pref',
550 ['keyword' => [\ilDBConstants::T_TEXT, 'public_avatar']],
551 ['keyword' => [\ilDBConstants::T_TEXT, 'public_upload']]
552 );
553 }

References ilDBConstants\T_TEXT.

◆ step_2()

ILIAS\User\Setup\DBUpdateSteps11::step_2 ( )

Definition at line 115 of file DBUpdateSteps11.php.

115 : void
116 {
117 if ($this->db->tableExists('usr_data_multi')
118 && !$this->db->tableExists('usr_profile_data')) {
119 $this->db->renameTable(
120 'usr_data_multi',
121 'usr_profile_data'
122 );
123 }
124 if ($this->db->tableExists('usr_profile_data')) {
125 $this->db->modifyTableColumn('usr_profile_data', 'value', ['type' => \ilDBConstants::T_CLOB]);
126 }
127 if ($this->db->sequenceExists('usr_profile_data')) {
128 $this->db->dropSequence('usr_profile_data');
129 }
130 if ($this->db->tableExists('usr_profile_data')
131 && $this->db->tableColumnExists('usr_profile_data', 'id')) {
132 $this->db->dropTableColumn('usr_profile_data', 'id');
133 }
134 if ($this->db->tableExists('usr_profile_data')
135 && !$this->db->indexExistsByFields('usr_profile_data', ['usr_id', 'field_id'])) {
136 $this->db->addIndex('usr_profile_data', ['usr_id', 'field_id'], 'uf');
137 }
138 }

References ilDBConstants\T_CLOB.

◆ step_3()

ILIAS\User\Setup\DBUpdateSteps11::step_3 ( )

Definition at line 140 of file DBUpdateSteps11.php.

140 : void
141 {
142 if ($this->db->tableExists('udf_data')) {
143 $this->db->dropTable('udf_data');
144 }
145
146 if ($this->db->sequenceExists('udf_definition')) {
147 /*
148 * 2025-07-17, sk: This needs to be done here, as we absolutely need
149 * the change to be ready for the next steps
150 */
151 $this->db->modifyTableColumn('ldap_attribute_mapping', 'keyword', ['length' => 68]);
152 $this->db->modifyTableColumn('settings', 'keyword', ['length' => 74]);
153
154 $this->db->renameTableColumn('udf_definition', 'field_id', 'old_field_id');
155 $this->db->manipulate('ALTER TABLE udf_definition ADD COLUMN field_id VARCHAR(64) NOT NULL FIRST');
156 $this->db->modifyTableColumn('udf_clob', 'field_id', ['type' => 'text', 'length' => 64]);
157 $this->db->modifyTableColumn('udf_text', 'field_id', ['type' => 'text', 'length' => 64]);
158 $fields_query = $this->db->query('SELECT old_field_id FROM udf_definition');
159 while (($row = $this->db->fetchObject($fields_query))) {
160 $uuid = $this->uuid_factory->uuid4AsString();
161 $this->db->manipulate(
162 "UPDATE udf_definition SET field_id = '{$uuid}' WHERE old_field_id = '{$row->old_field_id}'"
163 );
164 $this->db->manipulate(
165 "UPDATE udf_clob SET field_id = '{$uuid}' WHERE field_id = '{$row->old_field_id}'"
166 );
167 $this->db->manipulate(
168 "UPDATE udf_text SET field_id = '{$uuid}' WHERE field_id = '{$row->old_field_id}'"
169 );
170 $this->db->manipulate(
171 "UPDATE ldap_attribute_mapping SET keyword = 'udf_{$uuid}' WHERE keyword = 'udf_{$row->old_field_id}'"
172 );
173 $this->db->manipulate(
174 "UPDATE settings SET keyword = 'pmap_udf_{$uuid}' WHERE keyword = 'pmap_udf_{$row->old_field_id}'"
175 );
176 $this->db->manipulate(
177 "UPDATE settings SET keyword = 'pumap_udf_{$uuid}' WHERE keyword = 'pumap_udf_{$row->old_field_id}'"
178 );
179
180 $this->migrateBadges("udf_{$row->old_field_id}", $uuid);
181 }
182 $this->db->dropTableColumn('udf_definition', 'old_field_id');
183 $this->db->addPrimaryKey('udf_definition', ['field_id']);
184 $this->db->dropSequence('udf_definition');
185 }
186 }
migrateBadges(string $old_value, string $new_value)

◆ step_4()

ILIAS\User\Setup\DBUpdateSteps11::step_4 ( )

Definition at line 188 of file DBUpdateSteps11.php.

188 : void
189 {
190 if ($this->db->tableExists('udf_text')) {
191 $this->db->manipulate('INSERT INTO usr_profile_data SELECT * FROM udf_text');
192 $this->db->dropTable('udf_text');
193 }
194
195 if ($this->db->tableExists('udf_clob')) {
196 $this->db->manipulate('INSERT INTO usr_profile_data SELECT * FROM udf_clob');
197 $this->db->dropTable('udf_clob');
198 }
199 }

◆ step_5()

ILIAS\User\Setup\DBUpdateSteps11::step_5 ( )

Definition at line 201 of file DBUpdateSteps11.php.

201 : void
202 {
203 if (!$this->db->tableExists('usr_field_config')) {
204 $this->db->createTable(
205 'usr_field_config',
206 [
207 'field_id' => [
208 'type' => \ilDBConstants::T_TEXT,
209 'length' => 64,
210 'notnull' => true
211 ],
212 'visible_in_registration' => [
213 'type' => \ilDBConstants::T_INTEGER,
214 'length' => 1,
215 'notnull' => true
216 ],
217 'visible_to_user' => [
218 'type' => \ilDBConstants::T_INTEGER,
219 'length' => 1,
220 'notnull' => true
221 ],
222 'visible_in_lua' => [
223 'type' => \ilDBConstants::T_INTEGER,
224 'length' => 1,
225 'notnull' => true
226 ],
227 'visible_in_crss' => [
228 'type' => \ilDBConstants::T_INTEGER,
229 'length' => 1,
230 'notnull' => true
231 ],
232 'visible_in_grps' => [
233 'type' => \ilDBConstants::T_INTEGER,
234 'length' => 1,
235 'notnull' => true
236 ],
237 'visible_in_prgs' => [
238 'type' => \ilDBConstants::T_INTEGER,
239 'length' => 1,
240 'notnull' => true
241 ],
242 'changeable_by_user' => [
243 'type' => \ilDBConstants::T_INTEGER,
244 'length' => 1,
245 'notnull' => true
246 ],
247 'changeable_in_lua' => [
248 'type' => \ilDBConstants::T_INTEGER,
249 'length' => 1,
250 'notnull' => true
251 ],
252 'required' => [
253 'type' => \ilDBConstants::T_INTEGER,
254 'length' => 1,
255 'notnull' => true
256 ],
257 'export' => [
258 'type' => \ilDBConstants::T_INTEGER,
259 'length' => 1,
260 'notnull' => true
261 ],
262 'searchable' => [
263 'type' => \ilDBConstants::T_INTEGER,
264 'length' => 1,
265 'notnull' => true
266 ],
267 'available_in_certs' => [
268 'type' => \ilDBConstants::T_INTEGER,
269 'length' => 1,
270 'notnull' => true
271 ],
272 ]
273 );
274 $this->db->addPrimaryKey('usr_field_config', ['field_id']);
275 $this->db->insert(
276 'usr_field_config',
277 [
278 'field_id' => [\ilDBConstants::T_TEXT, 'location'],
279 'visible_in_registration' => [\ilDBConstants::T_INTEGER, 0],
280 'visible_to_user' => [\ilDBConstants::T_INTEGER, 1],
281 'visible_in_lua' => [\ilDBConstants::T_INTEGER, 0],
282 'visible_in_crss' => [\ilDBConstants::T_INTEGER, 0],
283 'visible_in_grps' => [\ilDBConstants::T_INTEGER, 0],
284 'visible_in_prgs' => [\ilDBConstants::T_INTEGER, 0],
285 'changeable_by_user' => [\ilDBConstants::T_INTEGER, 1],
286 'changeable_in_lua' => [\ilDBConstants::T_INTEGER, 0],
287 'required' => [\ilDBConstants::T_INTEGER, 0],
288 'export' => [\ilDBConstants::T_INTEGER, 0],
289 'searchable' => [\ilDBConstants::T_INTEGER, 0],
290 'available_in_certs' => [\ilDBConstants::T_INTEGER, 0]
291 ]
292 );
293 }
294 }

References ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

◆ step_6()

ILIAS\User\Setup\DBUpdateSteps11::step_6 ( )

Definition at line 296 of file DBUpdateSteps11.php.

296 : void
297 {
298 $this->db->modifyTableColumn(
299 'udf_definition',
300 'field_type',
301 [
302 'type' => \ilDBConstants::T_TEXT,
303 'length' => 4000
304 ]
305 );
306 $this->db->update(
307 'udf_definition',
308 [
309 'field_type' => [
311 \ILIAS\User\Profile\Fields\Custom\Text::class
312 ]
313 ],
314 [
315 'field_type' => [
317 '1'
318 ]
319 ]
320 );
321 $this->db->update(
322 'udf_definition',
323 [
324 'field_type' => [
326 \ILIAS\User\Profile\Fields\Custom\Select::class
327 ]
328 ],
329 [
330 'field_type' => [
332 '2'
333 ]
334 ]
335 );
336 $this->db->update(
337 'udf_definition',
338 [
339 'field_type' => [
341 \ILIAS\User\Profile\Fields\Custom\TextArea::class
342 ]
343 ],
344 [
345 'field_type' => [
347 '3'
348 ]
349 ]
350 );
351 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References ilDBConstants\T_TEXT.

◆ step_7()

ILIAS\User\Setup\DBUpdateSteps11::step_7 ( )

Definition at line 353 of file DBUpdateSteps11.php.

353 : void
354 {
355 if (!$this->db->tableColumnExists('udf_definition', 'section')) {
356 $this->db->addTableColumn(
357 'udf_definition',
358 'section',
359 [
360 'type' => \ilDBConstants::T_TEXT,
361 'length' => 64,
362 'notnull' => true,
363 'default' => AvailableSections::Other->value
364 ]
365 );
366 }
367 }

References ILIAS\User\Profile\Fields\Other, and ilDBConstants\T_TEXT.

◆ step_8()

ILIAS\User\Setup\DBUpdateSteps11::step_8 ( )

Definition at line 369 of file DBUpdateSteps11.php.

369 : void
370 {
371 if ($this->db->fetchObject(
372 $this->db->query(
373 'SELECT COUNT(*) cnt FROM settings WHERE module = "common"' . PHP_EOL
374 . 'AND keyword="usr_settings_changeable_by_user_new_mail_notification"'
375 )
376 )?->cnt <= 0
377 ) {
378 $this->db->manipulate(
379 'INSERT INTO settings (module, keyword, value) VALUES '
380 . '("common", "usr_settings_changeable_by_user_new_mail_notification", "1"), '
381 . '("common", "usr_settings_changeable_lua_new_mail_notification", "1"), '
382 . '("common", "usr_settings_export_new_mail_notification", "1")'
383 );
384 }
385
386 $renamed_fields = [
387 'hide_own_online_status' => 'awrn_user_show',
388 'bs_allow_to_contact_me' => 'allow_contact_request',
389 'mail_incoming_mail' => 'incoming_mail',
390 'skin_style' => 'style',
391 'upload' => 'avatar',
392 'sel_country' => 'selcountry',
393 'country' => 'old_country',
394 'selcountry' => 'country'
395 ];
396
397 foreach ($renamed_fields as $old_id => $new_id) {
398 $settings_query = $this->db->query(
399 "SELECT keyword FROM settings WHERE {$this->db->like('keyword', \ilDBConstants::T_TEXT, "%_{$old_id}")}"
400 );
401 while (($row = $this->db->fetchObject($settings_query)) !== null) {
402 if ($row->keyword === 'admin_country') {
403 continue;
404 }
405 $this->db->update(
406 'settings',
407 [
408 'keyword' => [
410 str_replace("_{$old_id}", "_{$new_id}", $row->keyword)
411 ]
412 ],
413 [
414 'module' => [
416 'common'
417 ],
418 'keyword' => [
420 $row->keyword
421 ]
422 ]
423 );
424 }
425
426 $user_query = $this->db->query(
427 "SELECT DISTINCT keyword FROM usr_pref WHERE {$this->db->like('keyword', \ilDBConstants::T_TEXT, "%_{$old_id}")}"
428 );
429 while (($row = $this->db->fetchObject($user_query)) !== null) {
430 $this->db->update(
431 'usr_pref',
432 [
433 'keyword' => [
435 str_replace("_{$old_id}", "_{$new_id}", $row->keyword)
436 ]
437 ],
438 [
439 'keyword' => [
441 $row->keyword
442 ]
443 ]
444 );
445 }
446 }
447
448 $this->migrateBadges('upload', 'avatar');
449 $this->migrateBadges('selcountry', 'country');
450 }

References ilDBConstants\T_TEXT.

◆ step_9()

ILIAS\User\Setup\DBUpdateSteps11::step_9 ( )

Definition at line 452 of file DBUpdateSteps11.php.

452 : void
453 {
454 $query = $this->db->query(
455 "SELECT usr_id, keyword FROM usr_pref WHERE {$this->db->like('keyword', \ilDBConstants::T_TEXT, 'public_udf_&')}"
456 );
457 while (($row = $this->db->fetchObject($query)) !== null) {
458 $this->db->update(
459 'usr_pref',
460 [
461 keyword => [
463 str_replace('public_udf_', 'public_', $row['keyword'])
464 ]
465 ],
466 [
467 'usr_id' => [
469 $row['usr_id']
470 ],
471 'keyword' => [
473 $row['keyword']
474 ]
475 ]
476 );
477 }
478 }

References ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

Field Documentation

◆ $db

ilDBInterface ILIAS\User\Setup\DBUpdateSteps11::$db
private

Definition at line 28 of file DBUpdateSteps11.php.

Referenced by ILIAS\User\Setup\DBUpdateSteps11\prepare().

◆ $uuid_factory

UUIDFactory ILIAS\User\Setup\DBUpdateSteps11::$uuid_factory
private

Definition at line 29 of file DBUpdateSteps11.php.


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