Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.41 diff -u -p -r1.41 install.php --- install.php 13 Apr 2007 08:56:57 -0000 1.41 +++ install.php 6 May 2007 04:12:40 -0000 @@ -33,7 +33,7 @@ function install_main() { require_once './includes/database.inc'; db_set_active(); // Check if Drupal is installed. - if (install_verify_drupal()) { + if (!isset($_GET['state']) && install_verify_drupal()) { install_already_done_error(); } } @@ -68,31 +68,33 @@ function install_main() { // Load the profile. require_once "./profiles/$profile/$profile.profile"; - // Check the installation requirements for Drupal and this profile. - install_check_requirements($profile); + if (!isset($_GET['state'])) { + // Check the installation requirements for Drupal and this profile. + install_check_requirements($profile); - // Change the settings.php information if verification failed earlier. - // Note: will trigger a redirect if database credentials change. - if (!$verify) { - install_change_settings($profile, $install_locale); - } + // Change the settings.php information if verification failed earlier. + // Note: will trigger a redirect if database credentials change. + if (!$verify) { + install_change_settings($profile, $install_locale); + } - // Verify existence of all required modules. - $modules = drupal_verify_profile($profile, $install_locale); - if (!$modules) { - install_missing_modules_error($profile); - } + // Verify existence of all required modules. + $modules = drupal_verify_profile($profile, $install_locale); + if (!$modules) { + install_missing_modules_error($profile); + } - // Perform actual installation defined in the profile. - drupal_install_profile($profile, $modules); + // Perform actual installation defined in the profile. + drupal_install_profile($profile, $modules); - // Warn about settings.php permissions risk - $settings_file = './'. conf_path() .'/settings.php'; - if (!drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE)) { - drupal_set_message(st('All necessary changes to %file have been made, so you should now remove write permissions to this file. Failure to remove write permissions to this file is a security risk.', array('%file' => $settings_file)), 'error'); - } - else { - drupal_set_message(st('All necessary changes to %file have been made. It has been set to read-only for security.', array('%file' => $settings_file))); + // Warn about settings.php permissions risk + $settings_file = './'. conf_path() .'/settings.php'; + if (!drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE)) { + drupal_set_message(st('All necessary changes to %file have been made, so you should now remove write permissions to this file. Failure to remove write permissions to this file is a security risk.', array('%file' => $settings_file)), 'error'); + } + else { + drupal_set_message(st('All necessary changes to %file have been made. It has been set to read-only for security.', array('%file' => $settings_file))); + } } // Show end page. @@ -114,7 +116,7 @@ function install_verify_settings() { global $db_prefix, $db_type, $db_url; // Verify existing settings (if any). - if ($_SERVER['REQUEST_METHOD'] == 'GET' && $db_url != 'mysql://username:password@localhost/databasename') { + if (($_SERVER['REQUEST_METHOD'] == 'GET' || isset($_GET['state']))&& $db_url != 'mysql://username:password@localhost/databasename') { // We need this because we want to run form_get_errors. include_once './includes/form.inc'; @@ -550,7 +552,9 @@ function install_complete($profile) { global $base_url; $output = ''; // Store install profile for later use. - variable_set('install_profile', $profile); + if (!isset($_GET['state'])) { + variable_set('install_profile', $profile); + } // Bootstrap newly installed Drupal, while preserving existing messages. $messages = $_SESSION['messages']; @@ -559,7 +563,9 @@ function install_complete($profile) { // Build final page. drupal_maintenance_theme(); - install_task_list(); + $function = $profile .'_profile_final_task'; + $task = function_exists($function) ? $function() : NULL; + install_task_list($task); drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_name()))); $output .= '

'. st('Congratulations, @drupal has been successfully installed.', array('@drupal' => drupal_install_profile_name())) .'

'; @@ -620,8 +626,9 @@ function install_task_list($active = NUL 'install' => st('Installation'), ); + $profiles = install_find_profiles(); // Remove profiles if only one profile exists. - if (count(install_find_profiles()) == 1) { + if (count($profiles) == 1) { unset($tasks['profile']); } @@ -630,6 +637,15 @@ function install_task_list($active = NUL unset($tasks['locale']); } + if (isset($_GET['profile']) && isset($profiles[$_GET['profile']])) { + $function = $_GET['profile'] . '_profile_tasks'; + if (function_exists($function)) { + $result = $function(); + if (is_array($result)) { + $tasks += $result; + } + } + } drupal_set_content('left', theme_task_list($tasks, $active)); } Index: modules/system/system.css =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.css,v retrieving revision 1.25 diff -u -p -r1.25 system.css --- modules/system/system.css 1 May 2007 06:53:03 -0000 1.25 +++ modules/system/system.css 6 May 2007 04:12:40 -0000 @@ -431,3 +431,10 @@ tr.selected td { thead div.sticky-header { background: #fff; } + +/* +** Installation clean URLs +*/ +#clean-url.install { + display: none; +} Index: modules/system/system.js =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.js,v retrieving revision 1.3 diff -u -p -r1.3 system.js --- modules/system/system.js 29 Apr 2007 16:06:04 -0000 1.3 +++ modules/system/system.js 6 May 2007 04:12:40 -0000 @@ -8,7 +8,8 @@ * are currently enabled. */ Drupal.cleanURLsSettingsCheck = function() { - var url = location.pathname +"admin/settings/clean-urls"; + var pathname = location.pathname +""; + var url = pathname.replace(/\/[^\/]*?$/, '/') +"node"; $("#clean-url .description span").html('
'+ Drupal.settings.cleanURL.testing +"
"); $("#clean-url p").hide(); $.ajax({url: location.protocol +"//"+ location.host + url, type: "GET", data: " ", complete: function(response) { @@ -24,3 +25,35 @@ Drupal.cleanURLsSettingsCheck = function } }}); } + +/** + * Internal function to check using Ajax if clean URLs can be enabled on the + * install page. + * + * This function is not used to verify whether or not clean URLs + * are currently enabled. + */ +Drupal.cleanURLsInstallCheck = function() { + var pathname = location.pathname +""; + var url = pathname.replace(/\/[^\/]*?$/, '/') +"node"; + $("#clean-url .description").append('
'+ Drupal.settings.cleanURL.testing +"
"); + $("#clean-url.install").css("display", "block"); + $.ajax({url: location.protocol +"//"+ location.host + url, type: "GET", data: " ", complete: function(response) { + $("#testing").toggle(); + if (response.status == 200) { + // Check was successful. + $("#clean-url input.form-radio").attr("disabled", ""); + $("#clean-url .description span").append('
'+ Drupal.settings.cleanURL.success +"
"); + $("#clean-url input.form-radio").attr("checked", 1); + } + else { + // Check failed. + $("#clean-url .description span").append('
'+ Drupal.settings.cleanURL.failure +"
"); + } + }}); +} + +Drupal.installDefaultTimezone = function() { + var offset = new Date().getTimezoneOffset() * -60; + $("#edit-date-default-timezone").val(offset); +} Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.777 diff -u -p -r1.777 user.module --- modules/user/user.module 30 Apr 2007 17:03:29 -0000 1.777 +++ modules/user/user.module 6 May 2007 04:12:40 -0000 @@ -1375,7 +1375,10 @@ function user_register_submit($form_id, // The first user may login immediately, and receives a customized welcome e-mail. if ($account->uid == 1) { drupal_mail('user-register-admin', $mail, t('Drupal user account details for !s', array('!s' => $name)), strtr(t("!username,\n\nYou may now login to !uri using the following username and password:\n\n username: !username\n password: !password\n\n!edit_uri\n\n--drupal"), $variables), $from); - drupal_set_message(t('

Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via e-mail, so please make sure your website e-mail address is set properly under the general settings on the site information settings page.

Your password is %pass. You may change your password below.

', array('%pass' => $pass, '@settings' => url('admin/settings/site-information')))); + drupal_set_message(t('

Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via e-mail, so please make sure your website e-mail address is set properly under the general settings on the site information settings page.')); + if (variable_get('user_email_verification', TRUE)) { + drupal_set_message(t('

Your password is %pass. You may change your password below.

', array('%pass' => $pass, '@settings' => url('admin/settings/site-information')))); + } user_authenticate($account->name, trim($pass)); return 'user/1/edit'; Index: profiles/default/default.profile =================================================================== RCS file: /cvs/drupal/drupal/profiles/default/default.profile,v retrieving revision 1.9 diff -u -p -r1.9 default.profile --- profiles/default/default.profile 10 Apr 2007 10:10:27 -0000 1.9 +++ profiles/default/default.profile 6 May 2007 04:12:40 -0000 @@ -25,6 +25,26 @@ function default_profile_details() { } /** + * Return a list of tasks that this profile supports. + * + * @return + * A keyed array of tasks the profile will perform during the _final stage. + */ +function default_profile_tasks() { + return array('profile_info' => st('Enter site details')); +} + +/** + * Return the current task during the final stage + * + * @return + * A key to the tasks array, as defined in *_profile_tasks() + */ +function default_profile_final_task() { + return 'profile_info'; +} + +/** * Perform any final installation tasks for this profile. * * @return @@ -32,6 +52,105 @@ function default_profile_details() { * screen. */ function default_profile_final() { + $account = user_load(1); + if ($account) { + drupal_goto(); + } + return drupal_get_form('default_profile_final_form'); +} + +function default_profile_final_form() { + // This is necessary to add the state to the $_GET args so the install + // system will know that it is done and we've taken over. + + $form['#action'] = 'install.php?profile=default&state=profile_info'; + $form['intro'] = array( + '#value' => t('Now, please provide some basic information for your site, so that we may finalize this information.'), + ); + $form['site_name'] = array( + '#type' => 'textfield', + '#title' => t('Name'), + '#default_value' => variable_get('site_name', 'Drupal'), + '#description' => t('The name of this website.'), + '#required' => TRUE + ); + $form['site_mail'] = array( + '#type' => 'textfield', + '#title' => t('E-mail address'), + '#default_value' => variable_get('site_mail', ini_get('sendmail_from')), + '#description' => t('A valid e-mail address to be used as the "From" address by the auto-mailer during registration, new password requests, notifications, etc. To lessen the likelihood of e-mail being marked as spam, this e-mail address should use the same domain as the website.'), + '#required' => TRUE, + ); + $form['account']['#tree'] = TRUE; + $form['account']['name'] = array('#type' => 'textfield', + '#title' => t('Admin username'), + '#maxlength' => USERNAME_MAX_LENGTH, + '#description' => t('Your preferred administrator username; punctuation is not allowed except for periods, hyphens, and underscores.'), + '#required' => TRUE, + ); + + $form['account']['mail'] = array('#type' => 'textfield', + '#title' => t('Admin E-mail address'), + '#maxlength' => EMAIL_MAX_LENGTH, + '#description' => t('A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'), + '#required' => TRUE, + ); + $form['account']['pass'] = array( + '#type' => 'password_confirm', + '#description' => t('Provide a password for the admin account in both fields.'), + '#required' => TRUE, + '#size' => 25, + ); + + $zones = _system_zonelist(); + + $form['date_default_timezone'] = array( + '#type' => 'select', + '#title' => t('Default time zone'), + '#default_value' => variable_get('date_default_timezone', 0), + '#options' => $zones, + '#description' => t('Select the default site time zone.') + ); + + drupal_add_js(drupal_get_path('module', 'system') .'/system.js', 'module'); + drupal_add_js(array('cleanURL' => array('success' => t('Your server has been successfully tested to support this feature.'), 'failure' => t('Your system configuration does not currently support this feature. The handbook page on Clean URLs has additional troubleshooting information.'), 'testing' => t('Testing clean URLs...'))), 'setting'); + drupal_add_js(' +// Global Killswitch +if (Drupal.jsEnabled) { + $(document).ready(function() { + Drupal.cleanURLsInstallCheck(); + Drupal.installDefaultTimezone(); + }); +}', 'inline'); + + $form['clean_url'] = array( + '#type' => 'radios', + '#title' => t('Clean URLs'), + '#default_value' => variable_get('clean_url', 0), + '#options' => array(t('Disabled'), t('Enabled')), + '#description' => t('This option makes Drupal emit "clean" URLs (i.e. without ?q= in the URL).'), + '#disabled' => TRUE, + '#prefix' => '
', + '#suffix' => '
', + ); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit'), + ); + return $form; +} + +function default_profile_final_form_submit($form_id, $form_values) { + variable_set('site_name', $form_values['site_name']); + variable_set('site_mail', $form_values['site_mail']); + variable_set('date_default_timezone', $form_values['date_default_timezone']); + // Turn this off temporarily so that we can pass a password through. + variable_set('user_email_verification', FALSE); + user_register_submit('user_register', $form_values['account']); + variable_set('user_email_verification', TRUE); + drupal_set_message(t('Site installation completed! Welcome to your new site!')); + // Insert default user-defined node types into the database. For a complete // list of available node type attributes, refer to the node type API // documentation at: http://api.drupal.org/api/HEAD/function/hook_node_info.