31 private \ilDBInterface
$db;
37 return 'Clean-Up and Consolidate User Profile Fields';
48 new \ilDatabaseInitializedObjective(),
49 new \ilSettingsFactoryExistsObjective(),
50 new \ilDatabaseUpdatedObjective()
65 $this->
settings->set(self::MIGRATION_COMPLETED,
'1');
70 return $this->
settings->get(self::MIGRATION_COMPLETED) ===
'1' ? 0 : 1;
75 if (!$this->db->tableColumnExists(
'udf_definition',
'prg_export')) {
79 $custom_fields_query = $this->db->query(
'SELECT * FROM udf_definition');
81 while (($row = $this->db->fetchObject($custom_fields_query))) {
84 $row->registration_visible,
98 $this->db->dropTableColumn(
102 $this->db->dropTableColumn(
106 $this->db->dropTableColumn(
110 $this->db->dropTableColumn(
114 $this->db->dropTableColumn(
118 $this->db->dropTableColumn(
122 $this->db->dropTableColumn(
124 'registration_visible'
126 $this->db->dropTableColumn(
130 $this->db->dropTableColumn(
134 $this->db->dropTableColumn(
138 $this->db->dropTableColumn(
142 $this->db->dropTableColumn(
160 'interests_general' ,
161 'interests_help_offered',
162 'interests_help_looking',
179 'allow_contact_request',
186 $property_attributes = [
187 'usr_settings_visib_reg',
189 'usr_settings_visib_lua',
190 'usr_settings_course_export',
191 'usr_settings_group_export',
192 'usr_settings_prg_export',
193 'usr_settings_disable',
194 'usr_settings_changeable_lua',
196 'usr_settings_export',
202 foreach ($field_ids as $field_id) {
208 foreach ($property_attributes as $attribute) {
209 $this->
settings->delete(
"{$attribute}_{$field_id}");
216 $message =
'ILIAS up to now knows two types of country information: One selectable by a dropdown '
217 .
'the other one as a text field. The latter one will be removed. Would you like us to move '
218 .
'the current information in the text field to a custom field with the name "Country"? If you '
219 .
'choose to not move the information it will simply be deleted.';
221 if ($this->admin_interaction->confirmOrDeny(
$message)) {
222 $uuid = (
new UUIDFactory())->uuid4AsString();
240 AvailableSections::ContactData->value
248 $query = $this->db->query(
249 'SELECT usr_id, old_country FROM usr_data WHERE old_country IS NOT NULL AND NOT old_country = ""'
253 while (($row = $this->db->fetchObject($query))) {
254 $insert[] =
"('{$row->usr_id}', '{$uuid}', {$this->db->quote($row->old_country, \ilDBConstants::T_TEXT)})";
257 if ($insert === []) {
261 $this->db->manipulate(
262 'INSERT INTO usr_profile_data (usr_id, field_id, value) VALUES ' . implode(
',', $insert)
266 foreach ($property_attributes as $attribute) {
267 $this->
settings->delete(
"{$attribute}_old_country");
269 $this->db->dropTableColumn(
'usr_data',
'old_country');
277 function (string $v) use ($field_id): bool {
278 if ($field_id ===
'username' && $v ===
'usr_settings_disable') {
279 return $this->
settings->get(
'allow_change_loginname',
'0') ===
'1';
282 if (in_array($v, [
'usr_settings_hide',
'usr_settings_disable'])) {
293 return $this->
settings->get(
"{$attribute}_{$field_id}",
'0') ===
'1';
298 int $visible_in_registration,
299 int $visible_to_user,
301 int $visible_in_crss,
302 int $visible_in_grps,
303 int $visible_in_prgs,
304 int $changeable_by_user,
305 int $changeable_in_lua,
309 int $available_in_certs
311 if ($this->db->fetchAll(
313 "SELECT count(field_id) as cnt FROM usr_field_config WHERE field_id='{$field_id}'"
326 'visible_in_registration' => [
328 $visible_in_registration
330 'visible_to_user' => [
334 'visible_in_lua' => [
338 'visible_in_crss' => [
342 'visible_in_grps' => [
346 'visible_in_prgs' => [
350 'changeable_by_user' => [
354 'changeable_in_lua' => [
370 'available_in_certs' => [
getPreconditions(Environment $environment)
Objectives the migration depend on.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
updateCountryField(array $property_attributes)
migrateCustomFieldAccess()
retrievePropertyAttributeValue(string $field_id, string $attribute)
step(Environment $environment)
Run one step of the migration.
prepare(Environment $environment)
Prepare the migration by means of some environment.
insertConfig(string $field_id, int $visible_in_registration, int $visible_to_user, int $visible_in_lua, int $visible_in_crss, int $visible_in_grps, int $visible_in_prgs, int $changeable_by_user, int $changeable_in_lua, int $required, int $export, int $searchable, int $available_in_certs)
AdminInteraction $admin_interaction
migrateStandardFieldConfig()
fetchConfigValuesFromSettings(string $field_id, array $attributes)
const string MIGRATION_COMPLETED
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This defines ways in which objectives may interact with admins during the setup.
An environment holds resources to be used in the setup process.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
const RESOURCE_ADMIN_INTERACTION
const RESOURCE_SETTINGS_FACTORY
A migration is a potentially long lasting operation that can be broken into discrete steps.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))