Index: hosting/site/hosting_site.drush.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/hosting/site/hosting_site.drush.inc,v retrieving revision 1.8 diff -u -p -r1.8 hosting_site.drush.inc --- hosting/site/hosting_site.drush.inc 23 Oct 2009 00:02:31 -0000 1.8 +++ hosting/site/hosting_site.drush.inc 29 Jan 2010 18:17:27 -0000 @@ -11,6 +11,7 @@ function drush_hosting_site_pre_hosting_ if ($task->ref->type == 'site') { $task->args[0] = $task->ref->title; $task->options['site_id'] = $task->ref->nid; + $task->options['admin_user'] = $task->ref->admin_user; if ($task->task_type != 'import') { $task->options['language'] = $task->ref->site_language; } Index: hosting/site/hosting_site.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/hosting/site/hosting_site.install,v retrieving revision 1.15 diff -u -p -r1.15 hosting_site.install --- hosting/site/hosting_site.install 29 Oct 2009 17:10:30 -0000 1.15 +++ hosting/site/hosting_site.install 29 Jan 2010 18:17:27 -0000 @@ -74,6 +74,11 @@ function hosting_site_schema() { 'type' => 'int', 'not null' => TRUE, ), + 'admin_user' => array( + 'type' => 'varchar', + 'length' => 60, + 'not null' => TRUE, + ), ), 'primary key' => array('vid'), ); @@ -243,3 +248,8 @@ function hosting_site_update_6004() { return array(); } +function hosting_site_update_6005() { + $ret = array(); + db_add_field($ret, 'hosting_site', 'admin_user', array('type' => 'varchar', 'not null' => TRUE, 'length' => 60)); + return $ret; +} Index: hosting/site/hosting_site.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/hosting/site/hosting_site.module,v retrieving revision 1.142 diff -u -p -r1.142 hosting_site.module --- hosting/site/hosting_site.module 23 Oct 2009 00:02:31 -0000 1.142 +++ hosting/site/hosting_site.module 29 Jan 2010 18:17:28 -0000 @@ -4,6 +4,7 @@ define('HOSTING_SITE_DELETED', -2); define('HOSTING_SITE_DISABLED', -1); define('HOSTING_SITE_QUEUED', 0); define('HOSTING_SITE_ENABLED', 1); +define('HOSTING_DEFAULT_ADMIN_USER_SITE', 'admin'); /** * Implementation of hook_node_info @@ -380,6 +381,17 @@ function hosting_site_form($node) { $form["$extra_attribute"] = array('#type' => 'value', '#value' => $node->$extra_attribute); } + if (!$node->nid) { + $form['admin_user'] = array( + '#type' => 'textfield', + '#title' => t('Admin username'), + '#required' => TRUE, + '#maxlength' => USERNAME_MAX_LENGTH, + '#description' => t('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'), + '#default_value' => variable_get('default_admin_user_site', HOSTING_DEFAULT_ADMIN_USER_SITE), + ); + } + return $form; } @@ -421,6 +433,10 @@ function hosting_site_validate($node, &$ if (!array_key_exists($node->site_language, hosting_get_profile_languages($node->profile, $node->platform))) { form_set_error('site_language', t('Please fill in a valid language')); } + + if ($error = user_validate_name($node->admin_user)) { + form_set_error('admin_user', $error); + } } @@ -443,8 +459,8 @@ function hosting_site_insert(&$node) { $node->client = $client->nid; $node->site_language = ($node->site_language) ? $node->site_language : 'en'; - db_query("INSERT INTO {hosting_site} (vid, nid, client, db_server, platform, profile, language, last_cron, status, verified, port, `ssl`, ssl_redirect) VALUES (%d, %d, %d, %d, %d, %d, '%s', %d, %d, %d, %d, %d, %d)", - $node->vid, $node->nid, $node->client, $node->db_server, $node->platform, $node->profile, $node->site_language, $node->last_cron, $node->site_status, $node->verified, $node->port, $node->ssl, $node->ssl_redirect); + db_query("INSERT INTO {hosting_site} (vid, nid, client, db_server, platform, profile, language, last_cron, status, verified, port, `ssl`, ssl_redirect, admin_user) VALUES (%d, %d, %d, %d, %d, %d, '%s', %d, %d, %d, %d, %d, %d, '%s')", + $node->vid, $node->nid, $node->client, $node->db_server, $node->platform, $node->profile, $node->site_language, $node->last_cron, $node->site_status, $node->verified, $node->port, $node->ssl, $node->ssl_redirect, $node->admin_user); if ((!$node->old_vid)) { if ($node->import) { hosting_add_task($node->nid, 'import'); @@ -482,8 +498,8 @@ function hosting_site_update(&$node) { else { $client = hosting_get_client($node->client); $node->client = $client->nid; - db_query("UPDATE {hosting_site} SET client = %d, db_server = %d, platform = %d, last_cron = %d, status = %d, profile = %d, language = '%s', verified = %d, port = %d, `ssl` = %d, ssl_redirect = %d WHERE vid=%d", - $node->client, $node->db_server, $node->platform, $node->last_cron, $node->site_status, $node->profile, $node->site_language, $node->verified, $node->port, $node->ssl, $node->ssl_redirect, $node->vid); + db_query("UPDATE {hosting_site} SET client = %d, db_server = %d, platform = %d, last_cron = %d, status = %d, profile = %d, language = '%s', verified = %d, port = %d, `ssl` = %d, ssl_redirect = %d, admin_user = '%s' WHERE vid=%d", + $node->client, $node->db_server, $node->platform, $node->last_cron, $node->site_status, $node->profile, $node->site_language, $node->verified, $node->port, $node->ssl, $node->ssl_redirect, $node->admin_user, $node->vid); } if (!$node->no_verify) { hosting_add_task($node->nid, 'verify'); @@ -494,7 +510,7 @@ function hosting_site_update(&$node) { * Implementation of hook_load(). */ function hosting_site_load($node) { - $additions = db_fetch_object(db_query('SELECT client, db_server, platform, profile, language as site_language, last_cron, status AS site_status, verified, port, `ssl`, ssl_redirect FROM {hosting_site} WHERE vid = %d', $node->vid)); + $additions = db_fetch_object(db_query('SELECT client, db_server, platform, profile, language as site_language, last_cron, status AS site_status, verified, port, `ssl`, ssl_redirect, admin_user FROM {hosting_site} WHERE vid = %d', $node->vid)); return $additions; } @@ -678,6 +694,23 @@ function hosting_site_form_alter(&$form, $form['buttons']['delete']['#type'] = 'hidden'; } } + if ($form_id == 'node_type_form' && $form['#node_type']->type == 'site') { + $form['default_admin_user'] = array( + '#type' => 'textfield', + '#title' => t('Default admin username'), + '#required' => TRUE, + '#maxlength' => USERNAME_MAX_LENGTH, + '#description' => t('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'), + '#default_value' => variable_get('default_admin_user_site', HOSTING_DEFAULT_ADMIN_USER_SITE), + ); + $form['#validate'][] = 'hosting_site_node_type_form_validate_admin_user'; + } +} + +function hosting_site_node_type_form_validate_admin_user($form, &$form_state) { + if ($error = user_validate_name($form_state['values']['default_admin_user'])) { + form_set_error('default_admin_user', $error); + } } /**