1.20.x user.install user_update_1003()

Moves account settings from variable to config.

Related topics

File

modules/user/user.install, line 251
Install, update and uninstall functions for the user module.

Code

function user_update_1003() {
  // Migrate variables to config.
  $config = config('system.core');
  $config->set('user_admin_role', update_variable_get('user_admin_role', ''));
  $config->set('anonymous', update_variable_get('anonymous', 'Anonymous'));
  $config->set('user_email_verification', update_variable_get('user_email_verification', 1));
  $config->set('user_mail_status_activated_notify', update_variable_get('user_mail_status_activated_notify', 1));
  $config->set('user_mail_status_blocked_notify', update_variable_get('user_mail_status_blocked_notify', 0));
  $config->set('user_mail_status_cancelled_notify', update_variable_get('user_mail_status_cancelled_notify', 0));
  $config->set('user_signatures', update_variable_get('user_signatures', 0));
  $config->set('user_password_reset_timeout', update_variable_get('user_password_reset_timeout', 86400));

  // Convert the user.settings:register numeric value to text value.
  $map = array(
    '0' => 'admin_only',
    '1' => 'visitors',
    '2' => 'visitors_admin_approval',
  );
  $user_register = update_variable_get('user_register', 2);
  if (isset($map[$user_register])) {
    $config->set('user_register', $map[$user_register])->save();
  }
  $config->save();

  // Delete variables.
  update_variable_del('anonymous');
  update_variable_del('user_admin_role');
  update_variable_del('user_register');
  update_variable_del('user_signatures');
  update_variable_del('user_mail_status_activated_notify');
  update_variable_del('user_mail_status_blocked_notify');
  update_variable_del('user_mail_status_cancelled_notify');
  update_variable_del('user_email_verification');
  update_variable_del('user_password_reset_timeout');
}