Binary files install_profile_pre/.DS_Store and install_profile/.DS_Store differ diff -urNp install_profile_pre/install.php install_profile/install.php --- install_profile_pre/install.php 2007-05-06 04:56:41.000000000 -0700 +++ install_profile/install.php 2007-05-07 14:37:25.000000000 -0700 @@ -27,16 +27,20 @@ function install_main() { // Check existing settings.php. $verify = install_verify_settings(); - // Drupal may already be installed. - if ($verify) { + global $db_url; + if ($db_url != 'mysql://username:password@localhost/databasename') { // Establish a connection to the database. require_once './includes/database.inc'; db_set_active(); // Check if Drupal is installed. - if (install_verify_drupal()) { + $state = install_verify_drupal(); + if ($state == 'complete') { install_already_done_error(); } } + else { + $state = NULL; + } // Load module basics (needed for hook invokes). include_once './includes/module.inc'; @@ -68,43 +72,48 @@ 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 (!$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. - install_complete($profile); + install_finalize($profile, $state); } /** * Verify if Drupal is installed. */ function install_verify_drupal() { - $result = @db_query("SELECT name FROM {system} WHERE name = 'system'"); - return $result && db_result($result) == 'system'; + // read the variable manually using the @ so we don't trigger an error if it fails + $result = @db_query("SELECT value FROM {variable} WHERE name = 'install_state'"); + if ($result) { + return unserialize(db_result($result)); + } } /** @@ -546,11 +555,9 @@ function install_missing_modules_error($ /** * Page displayed when the installation is complete. Called from install.php. */ -function install_complete($profile) { +function install_finalize($profile, $state) { global $base_url; $output = ''; - // Store install profile for later use. - variable_set('install_profile', $profile); // Bootstrap newly installed Drupal, while preserving existing messages. $messages = $_SESSION['messages']; @@ -559,25 +566,70 @@ function install_complete($profile) { // Build final page. drupal_maintenance_theme(); - install_task_list(); - 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())) .'

'; - - // Show profile finalization info. - $function = $profile .'_profile_final'; - if (function_exists($function)) { - // More steps required - $profile_message = $function(); + if (empty($state)) { + variable_set('install_state', 'finalize'); + $state = 'finalize'; + } + + if ($state == 'finalize') { + drupal_set_title(st('Enter site details')); + menu_rebuild(); + + // We break the form up so we can tell when it's been successfully + // submitted. + $form = drupal_retrieve_form('install_finalize_form'); + + // In order to find out if the form was successfully submitted or not, + // we do a little song and dance to set the form to 'programmed' and check + // to make sure this is really the form being submitted. It'd better be. + if ($_POST && $_POST['form_id'] == 'install_finalize_form') { + $form['#programmed'] = TRUE; + $form['#post'] = $_POST; + } + + if (!drupal_process_form('install_finalize_form', $form)) { + $output = drupal_render_form('install_finalize_form', $form); + install_task_list('finalize'); + } } - menu_rebuild(); - // If the profile returned a welcome message, use that instead of default. - if (isset($profile_message)) { - $output .= $profile_message; - } - else { - // No more steps - $output .= '

'. (drupal_set_message() ? st('Please review the messages above before continuing on to your new site.', array('@url' => url(''))) : st('You may now visit your new site.', array('@url' => url('')))) .'

'; + // If we have no output, then install.php is done and now we turn to + // our profile to finalize things. + if (empty($output)) { + // Show profile finalization info. + $function = $profile .'_profile_final'; + if (function_exists($function)) { + // More steps required + $output = $function($state); + } + + // This comes after the above so it can make decisions based upon + // form results. + + $function = $profile .'_profile_final_task'; + if (function_exists($function) && $task = $function($state)) { + $state = $task; + } + else { + $state = 'complete'; + } + + install_task_list($state); + variable_set('install_state', $state); + + // Store install profile for later use. + if ($state == 'complete') { + drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_name()))); + + variable_set('install_profile', $profile); + + $output = '

'. (drupal_set_message() ? st('Please review the messages above before continuing on to your new site.', array('@url' => url(''))) : st('You may now visit your new site.', array('@url' => url('')))) .'

'; + + $function = $profile .'_profile_final_message'; + if (function_exists($function)) { + $output .= $function(); + } + } } // Output page. print theme('maintenance_page', $output); @@ -618,10 +670,12 @@ function install_task_list($active = NUL 'requirements' => st('Verify requirements'), 'database' => st('Database setup'), 'install' => st('Installation'), + 'finalize' => st('Enter site details'), ); + $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,7 +684,130 @@ 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; + } + } + } + + // Let the theming function know that 'complete' includes everything, + // even though it's not in the list. + if ($active == 'complete') { + $active = NULL; + } drupal_set_content('left', theme_task_list($tasks, $active)); } +function install_finalize_default_form() { + $form['intro'] = array( + '#value' => t('To finalize installation, please configure the following 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('Site 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('Administrator 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('Administrator 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 administrator 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. By default, dates in this site will be displayed in the chosen 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 install_finalize_default_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); + if (isset($form_values['clean_url'])) { + variable_set('clean_url', $form_values['clean_url']); + } + return 'completed'; +} +function install_finalize_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. + + $function = $_GET['profile'] .'_install_finalize_form'; + if(function_exists($function)) { + $form = $function(); + if(!isset($form['#submit'])) { + $form['#submit'] = array($function .'_submit' => array()); + } + } + else { + $form = install_finalize_default_form(); + $form['#submit'] = array('install_finalize_default_form_submit' => array()); + } + return $form; +} + install_main(); diff -urNp install_profile_pre/modules/system/system.css install_profile/modules/system/system.css --- install_profile_pre/modules/system/system.css 2007-04-30 23:53:03.000000000 -0700 +++ install_profile/modules/system/system.css 2007-05-07 14:07:12.000000000 -0700 @@ -431,3 +431,10 @@ tr.selected td { thead div.sticky-header { background: #fff; } + +/* +** Installation clean URLs +*/ +#clean-url.install { + display: none; +} diff -urNp install_profile_pre/modules/system/system.js install_profile/modules/system/system.js --- install_profile_pre/modules/system/system.js 2007-04-29 09:06:04.000000000 -0700 +++ install_profile/modules/system/system.js 2007-05-07 14:07:12.000000000 -0700 @@ -24,3 +24,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); +} diff -urNp install_profile_pre/modules/user/user.module install_profile/modules/user/user.module --- install_profile_pre/modules/user/user.module 2007-04-30 10:03:29.000000000 -0700 +++ install_profile/modules/user/user.module 2007-05-07 14:07:12.000000000 -0700 @@ -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.', array('@settings' => url('admin/settings/site-information')))); + if (variable_get('user_email_verification', TRUE)) { + drupal_set_message(t('

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

', array('%pass' => $pass))); + } user_authenticate($account->name, trim($pass)); return 'user/1/edit'; diff -urNp install_profile_pre/profiles/default/default.profile install_profile/profiles/default/default.profile --- install_profile_pre/profiles/default/default.profile 2007-04-10 03:10:27.000000000 -0700 +++ install_profile/profiles/default/default.profile 2007-05-07 14:07:12.000000000 -0700 @@ -25,13 +25,50 @@ 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 the current task during the final stage + * + * @param + * The current state of the install system. + * + * @return + * A key to the tasks array, as defined in *_profile_tasks(), or NULL + * to indicate that everything is complete. + */ +function default_profile_final_task($state) { +} + +/** + * Display a final message to the user after all install steps are complete. + * + * @return + * A string containing the message. + */ +function default_profile_final_message() { +} + +/** * Perform any final installation tasks for this profile. * + * @param $key + * The $key returned by default_profile_final_task (if any) or the + * $state if that was not set. + * * @return * An optional HTML string to display to the user on the final installation * screen. */ -function default_profile_final() { +function default_profile_final($key) { + // Should a profile want to display a form here, it can; it should set the + // 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. @@ -74,3 +111,4 @@ function default_profile_final() { $theme_settings['toggle_node_info_page'] = FALSE; variable_set('theme_settings', $theme_settings); } + diff -urNp install_profile_pre/sites/default/settings.php install_profile/sites/default/settings.php --- install_profile_pre/sites/default/settings.php 2007-05-04 01:32:00.000000000 -0700 +++ install_profile/sites/default/settings.php 2007-05-07 14:16:33.000000000 -0700 @@ -90,7 +90,7 @@ * $db_url = 'mysqli://username:password@localhost/databasename'; * $db_url = 'pgsql://username:password@localhost/databasename'; */ -$db_url = 'mysql://username:password@localhost/databasename'; +$db_url = 'mysql://root:root@localhost/install_profile_02'; $db_prefix = ''; /**