Commit d0623c30 authored by ergonlogic's avatar ergonlogic

Issue #1201174: Make UID1 username configurable.

parent 0b6bb1b3
<?php
/**
* @file
* Installation settings common across different versions of Drupal.
*/
define('PROVISION_DEFAULT_ADMIN_USER', 'admin');
......@@ -9,8 +9,10 @@ $GLOBALS['profile'] = d()->profile;
$GLOBALS['install_locale'] = d()->language;
$GLOBALS['base_url'] = provision_get_base_url();
// @TODO Document how/why this works.
require_once 'includes/install.inc'; // From the Drupal platform.
require_once 'install.inc'; // From Provision.
require_once 'includes/install.inc';
define('MAINTENANCE_MODE', 'install');
/**
......@@ -46,12 +48,17 @@ function install_verify_settings() {
}
function install_create_admin_user($client_email = NULL) {
$name = drush_get_option('admin_user', PROVISION_DEFAULT_ADMIN_USER);
if ($error = user_validate_name($name)) {
$name = PROVISION_DEFAULT_ADMIN_USER;
drush_log(dt('Error setting UID username to `!user`: ', array('!user' => $name)) . $error . dt(' Using default (!default) instead.', array('!default' => $name)), 'warning');
}
if (!$client_email) {
$client_email = 'webmaster@localhost';
}
// create the admin account
$account = user_load(1);
$edit['name'] = 'admin';
$edit['name'] = $name;
$edit['pass'] = user_password();
$edit['mail'] = $client_email;
$edit['status'] = 1;
......
......@@ -9,6 +9,7 @@ $GLOBALS['profile'] = d()->profile;
$GLOBALS['install_locale'] = d()->language;
$GLOBALS['base_url'] = provision_get_base_url();
require_once 'install.inc'; // From Provision, not the Drupal platform.
define('MAINTENANCE_MODE', 'install');
function install_send_welcome_mail($url, $account, $language, $client_email, $onetime) {
......@@ -76,6 +77,8 @@ function install_main() {
$client_email = drush_get_option('client_email');
require_once DRUPAL_ROOT . '/includes/install.core.inc';
require_once DRUPAL_ROOT . '/includes/entity.inc';
require_once DRUPAL_ROOT . '/modules/user/user.module';
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);
......@@ -106,6 +109,11 @@ function install_main() {
unset($GLOBALS['db_url']);
$account_pass = provision_password();
$name = drush_get_option('admin_user', PROVISION_DEFAULT_ADMIN_USER);
if ($error = user_validate_name($name)) {
$name = PROVISION_DEFAULT_ADMIN_USER;
drush_log(dt('Error setting UID username to `!user`: ', array('!user' => $name)) . $error . dt(' Using default (!default) instead.', array('!default' => $name)) , 'warning');
}
$settings = array(
'parameters' => array(
'profile' => $profile,
......@@ -118,7 +126,7 @@ function install_main() {
'site_name' => $url,
'site_mail' => $client_email ? $client_email : 'admin@example.com',
'account' => array(
'name' => 'admin',
'name' => $name,
'mail' => $client_email ? $client_email : 'admin@example.com',
'pass' => array(
'pass1' => $account_pass,
......@@ -144,7 +152,7 @@ function install_main() {
// create the admin account
$account = user_load(1);
$edit['name'] = 'admin';
$edit['name'] = $name;
$edit['pass'] = $account_pass;
$edit['mail'] = $client_email;
$edit['status'] = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment