19declare(strict_types=1);
28 private \ilDBInterface
$db;
34 $this->uuid_factory =
new UUIDFactory();
41 if ($this->db->fetchObject(
43 "SELECT COUNT(*) cnt FROM settings WHERE module = 'common' AND keyword='{$keyword}'"
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)) {
79 $config_array[
'profile'] = array_map(
80 static function (
string $v) use ($old_value, $new_value):
string {
81 if ($v !==
"chk_{$old_value}") {
85 return "chk_{$new_value}";
87 $config_array[
'profile']
103 if (!$this->db->tableColumnExists(
'mail_template',
'att_rid')) {
104 $this->db->addTableColumn(
117 if ($this->db->tableExists(
'usr_data_multi')
118 && !$this->db->tableExists(
'usr_profile_data')) {
119 $this->db->renameTable(
124 if ($this->db->tableExists(
'usr_profile_data')) {
127 if ($this->db->sequenceExists(
'usr_profile_data')) {
128 $this->db->dropSequence(
'usr_profile_data');
130 if ($this->db->tableExists(
'usr_profile_data')
131 && $this->db->tableColumnExists(
'usr_profile_data',
'id')) {
132 $this->db->dropTableColumn(
'usr_profile_data',
'id');
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');
142 if ($this->db->tableExists(
'udf_data')) {
143 $this->db->dropTable(
'udf_data');
146 if ($this->db->sequenceExists(
'udf_definition')) {
151 $this->db->modifyTableColumn(
'ldap_attribute_mapping',
'keyword', [
'length' => 68]);
152 $this->db->modifyTableColumn(
'settings',
'keyword', [
'length' => 74]);
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}'"
164 $this->db->manipulate(
165 "UPDATE udf_clob SET field_id = '{$uuid}' WHERE field_id = '{$row->old_field_id}'"
167 $this->db->manipulate(
168 "UPDATE udf_text SET field_id = '{$uuid}' WHERE field_id = '{$row->old_field_id}'"
170 $this->db->manipulate(
171 "UPDATE ldap_attribute_mapping SET keyword = 'udf_{$uuid}' WHERE keyword = 'udf_{$row->old_field_id}'"
173 $this->db->manipulate(
174 "UPDATE settings SET keyword = 'pmap_udf_{$uuid}' WHERE keyword = 'pmap_udf_{$row->old_field_id}'"
176 $this->db->manipulate(
177 "UPDATE settings SET keyword = 'pumap_udf_{$uuid}' WHERE keyword = 'pumap_udf_{$row->old_field_id}'"
180 $this->migrateBadges(
"udf_{$row->old_field_id}", $uuid);
182 $this->db->dropTableColumn(
'udf_definition',
'old_field_id');
183 $this->db->addPrimaryKey(
'udf_definition', [
'field_id']);
184 $this->db->dropSequence(
'udf_definition');
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');
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');
203 if (!$this->db->tableExists(
'usr_field_config')) {
204 $this->db->createTable(
212 'visible_in_registration' => [
217 'visible_to_user' => [
222 'visible_in_lua' => [
227 'visible_in_crss' => [
232 'visible_in_grps' => [
237 'visible_in_prgs' => [
242 'changeable_by_user' => [
247 'changeable_in_lua' => [
267 'available_in_certs' => [
274 $this->db->addPrimaryKey(
'usr_field_config', [
'field_id']);
298 $this->db->modifyTableColumn(
355 if (!$this->db->tableColumnExists(
'udf_definition',
'section')) {
356 $this->db->addTableColumn(
371 if ($this->db->fetchObject(
373 'SELECT COUNT(*) cnt FROM settings WHERE module = "common"' . PHP_EOL
374 .
'AND keyword="usr_settings_changeable_by_user_new_mail_notification"'
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")'
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'
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}
")}"
401 while (($row = $this->db->fetchObject($settings_query)) !==
null) {
402 if ($row->keyword ===
'admin_country') {
410 str_replace(
"_{$old_id}",
"_{$new_id}", $row->keyword)
426 $user_query = $this->db->query(
427 "SELECT DISTINCT keyword FROM usr_pref WHERE {$this->db->like('keyword', \ilDBConstants::T_TEXT, "%_{$old_id}
")}"
429 while (($row = $this->db->fetchObject($user_query)) !==
null) {
435 str_replace(
"_{$old_id}",
"_{$new_id}", $row->keyword)
448 $this->migrateBadges(
'upload',
'avatar');
449 $this->migrateBadges(
'selcountry',
'country');
454 $query = $this->db->query(
455 "SELECT usr_id, keyword FROM usr_pref WHERE {$this->db->like('keyword', \ilDBConstants::T_TEXT, 'public_udf_&')}"
457 while (($row = $this->db->fetchObject($query)) !==
null) {
463 str_replace(
'public_udf_',
'public_', $row[
'keyword'])
482 if ($this->db->tableColumnExists(
'usr_data',
'time_limit_message')) {
483 $this->db->dropTableColumn(
'usr_data',
'time_limit_message');
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');
494 $this->db->modifyTableColumn(
'usr_pref',
'keyword', [
'length' => 74]);
499 if ($this->db->fetchObject(
501 'SELECT COUNT(*) cnt FROM settings WHERE module = "common"' . PHP_EOL
502 .
'AND keyword="usr_settings_changeable_by_user_starting_point"'
511 'usr_settings_changeable_by_user_starting_point'
521 'usr_starting_point_personal'
526 $this->db->manipulate(
527 'DELETE FROM settings WHERE module = "common" AND keyword= "usr_starting_point_personal"'
531 $this->insertSetting(
'usr_settings_changeable_lua_starting_point',
'1');
532 $this->insertSetting(
'usr_settings_export_starting_point',
'1');
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');
UUIDFactory $uuid_factory
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
migrateBadges(string $old_value, string $new_value)
insertSetting(string $keyword, string $value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
if(!file_exists('../ilias.ini.php'))