| webmaster@1 | 1 <?php | 
| webmaster@1 | 2 // $Id: install.php,v 1.113.2.2 2008/02/08 22:00:45 goba Exp $ | 
| webmaster@1 | 3 | 
| webmaster@1 | 4 require_once './includes/install.inc'; | 
| webmaster@1 | 5 | 
| webmaster@1 | 6 define('MAINTENANCE_MODE', 'install'); | 
| webmaster@1 | 7 | 
| webmaster@1 | 8 /** | 
| webmaster@1 | 9  * The Drupal installation happens in a series of steps. We begin by verifying | 
| webmaster@1 | 10  * that the current environment meets our minimum requirements. We then go | 
| webmaster@1 | 11  * on to verify that settings.php is properly configured. From there we | 
| webmaster@1 | 12  * connect to the configured database and verify that it meets our minimum | 
| webmaster@1 | 13  * requirements. Finally we can allow the user to select an installation | 
| webmaster@1 | 14  * profile and complete the installation process. | 
| webmaster@1 | 15  * | 
| webmaster@1 | 16  * @param $phase | 
| webmaster@1 | 17  *   The installation phase we should proceed to. | 
| webmaster@1 | 18  */ | 
| webmaster@1 | 19 function install_main() { | 
| webmaster@1 | 20   require_once './includes/bootstrap.inc'; | 
| webmaster@1 | 21   drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); | 
| webmaster@1 | 22 | 
| webmaster@1 | 23   // This must go after drupal_bootstrap(), which unsets globals! | 
| webmaster@1 | 24   global $profile, $install_locale, $conf; | 
| webmaster@1 | 25 | 
| webmaster@1 | 26   require_once './modules/system/system.install'; | 
| webmaster@1 | 27   require_once './includes/file.inc'; | 
| webmaster@1 | 28 | 
| webmaster@1 | 29   // Ensure correct page headers are sent (e.g. caching) | 
| webmaster@1 | 30   drupal_page_header(); | 
| webmaster@1 | 31 | 
| webmaster@1 | 32   // Set up $language, so t() caller functions will still work. | 
| webmaster@1 | 33   drupal_init_language(); | 
| webmaster@1 | 34 | 
| webmaster@1 | 35   // Load module basics (needed for hook invokes). | 
| webmaster@1 | 36   include_once './includes/module.inc'; | 
| webmaster@1 | 37   $module_list['system']['filename'] = 'modules/system/system.module'; | 
| webmaster@1 | 38   $module_list['filter']['filename'] = 'modules/filter/filter.module'; | 
| webmaster@1 | 39   module_list(TRUE, FALSE, FALSE, $module_list); | 
| webmaster@1 | 40   drupal_load('module', 'system'); | 
| webmaster@1 | 41   drupal_load('module', 'filter'); | 
| webmaster@1 | 42 | 
| webmaster@1 | 43   // Set up theme system for the maintenance page. | 
| webmaster@1 | 44   drupal_maintenance_theme(); | 
| webmaster@1 | 45 | 
| webmaster@1 | 46   // Check existing settings.php. | 
| webmaster@1 | 47   $verify = install_verify_settings(); | 
| webmaster@1 | 48 | 
| webmaster@1 | 49   if ($verify) { | 
| webmaster@1 | 50     // Since we have a database connection, we use the normal cache system. | 
| webmaster@1 | 51     // This is important, as the installer calls into the Drupal system for | 
| webmaster@1 | 52     // the clean URL checks, so we should maintain the cache properly. | 
| webmaster@1 | 53     require_once './includes/cache.inc'; | 
| webmaster@1 | 54     $conf['cache_inc'] = './includes/cache.inc'; | 
| webmaster@1 | 55 | 
| webmaster@1 | 56     // Establish a connection to the database. | 
| webmaster@1 | 57     require_once './includes/database.inc'; | 
| webmaster@1 | 58     db_set_active(); | 
| webmaster@1 | 59 | 
| webmaster@1 | 60     // Check if Drupal is installed. | 
| webmaster@1 | 61     $task = install_verify_drupal(); | 
| webmaster@1 | 62     if ($task == 'done') { | 
| webmaster@1 | 63       install_already_done_error(); | 
| webmaster@1 | 64     } | 
| webmaster@1 | 65   } | 
| webmaster@1 | 66   else { | 
| webmaster@1 | 67     // Since no persistent storage is available yet, and functions that check | 
| webmaster@1 | 68     // for cached data will fail, we temporarily replace the normal cache | 
| webmaster@1 | 69     // system with a stubbed-out version that short-circuits the actual | 
| webmaster@1 | 70     // caching process and avoids any errors. | 
| webmaster@1 | 71     require_once './includes/cache-install.inc'; | 
| webmaster@1 | 72     $conf['cache_inc'] = './includes/cache-install.inc'; | 
| webmaster@1 | 73 | 
| webmaster@1 | 74     $task = NULL; | 
| webmaster@1 | 75   } | 
| webmaster@1 | 76 | 
| webmaster@1 | 77   // Decide which profile to use. | 
| webmaster@1 | 78   if (!empty($_GET['profile'])) { | 
| webmaster@1 | 79     $profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']); | 
| webmaster@1 | 80   } | 
| webmaster@1 | 81   elseif ($profile = install_select_profile()) { | 
| webmaster@1 | 82     install_goto("install.php?profile=$profile"); | 
| webmaster@1 | 83   } | 
| webmaster@1 | 84   else { | 
| webmaster@1 | 85     install_no_profile_error(); | 
| webmaster@1 | 86   } | 
| webmaster@1 | 87 | 
| webmaster@1 | 88   // Load the profile. | 
| webmaster@1 | 89   require_once "./profiles/$profile/$profile.profile"; | 
| webmaster@1 | 90 | 
| webmaster@1 | 91   // Locale selection | 
| webmaster@1 | 92   if (!empty($_GET['locale'])) { | 
| webmaster@1 | 93     $install_locale = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['locale']); | 
| webmaster@1 | 94   } | 
| webmaster@1 | 95   elseif (($install_locale = install_select_locale($profile)) !== FALSE) { | 
| webmaster@1 | 96     install_goto("install.php?profile=$profile&locale=$install_locale"); | 
| webmaster@1 | 97   } | 
| webmaster@1 | 98 | 
| webmaster@1 | 99   // Tasks come after the database is set up | 
| webmaster@1 | 100   if (!$task) { | 
| webmaster@1 | 101     // Check the installation requirements for Drupal and this profile. | 
| webmaster@1 | 102     install_check_requirements($profile, $verify); | 
| webmaster@1 | 103 | 
| webmaster@1 | 104     // Verify existence of all required modules. | 
| webmaster@1 | 105     $modules = drupal_verify_profile($profile, $install_locale); | 
| webmaster@1 | 106 | 
| webmaster@1 | 107     // If any error messages are set now, it means a requirement problem. | 
| webmaster@1 | 108     $messages = drupal_set_message(); | 
| webmaster@1 | 109     if (!empty($messages['error'])) { | 
| webmaster@1 | 110       install_task_list('requirements'); | 
| webmaster@1 | 111       drupal_set_title(st('Requirements problem')); | 
| webmaster@1 | 112       print theme('install_page', ''); | 
| webmaster@1 | 113       exit; | 
| webmaster@1 | 114     } | 
| webmaster@1 | 115 | 
| webmaster@1 | 116     // Change the settings.php information if verification failed earlier. | 
| webmaster@1 | 117     // Note: will trigger a redirect if database credentials change. | 
| webmaster@1 | 118     if (!$verify) { | 
| webmaster@1 | 119       install_change_settings($profile, $install_locale); | 
| webmaster@1 | 120     } | 
| webmaster@1 | 121 | 
| webmaster@1 | 122     // Install system.module. | 
| webmaster@1 | 123     drupal_install_system(); | 
| webmaster@1 | 124     // Save the list of other modules to install for the 'profile-install' | 
| webmaster@1 | 125     // task. variable_set() can be used now that system.module is installed | 
| webmaster@1 | 126     // and drupal is bootstrapped. | 
| webmaster@1 | 127     variable_set('install_profile_modules', array_diff($modules, array('system'))); | 
| webmaster@1 | 128   } | 
| webmaster@1 | 129 | 
| webmaster@1 | 130   // The database is set up, turn to further tasks. | 
| webmaster@1 | 131   install_tasks($profile, $task); | 
| webmaster@1 | 132 } | 
| webmaster@1 | 133 | 
| webmaster@1 | 134 /** | 
| webmaster@1 | 135  * Verify if Drupal is installed. | 
| webmaster@1 | 136  */ | 
| webmaster@1 | 137 function install_verify_drupal() { | 
| webmaster@1 | 138   // Read the variable manually using the @ so we don't trigger an error if it fails. | 
| webmaster@1 | 139   $result = @db_query("SELECT value FROM {variable} WHERE name = '%s'", 'install_task'); | 
| webmaster@1 | 140   if ($result) { | 
| webmaster@1 | 141     return unserialize(db_result($result)); | 
| webmaster@1 | 142   } | 
| webmaster@1 | 143 } | 
| webmaster@1 | 144 | 
| webmaster@1 | 145 /** | 
| webmaster@1 | 146  * Verify existing settings.php | 
| webmaster@1 | 147  */ | 
| webmaster@1 | 148 function install_verify_settings() { | 
| webmaster@1 | 149   global $db_prefix, $db_type, $db_url; | 
| webmaster@1 | 150 | 
| webmaster@1 | 151   // Verify existing settings (if any). | 
| webmaster@1 | 152   if (!empty($db_url)) { | 
| webmaster@1 | 153     // We need this because we want to run form_get_errors. | 
| webmaster@1 | 154     include_once './includes/form.inc'; | 
| webmaster@1 | 155 | 
| webmaster@1 | 156     $url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url); | 
| webmaster@1 | 157     $db_user = urldecode($url['user']); | 
| webmaster@1 | 158     $db_pass = isset($url['pass']) ? urldecode($url['pass']) : NULL; | 
| webmaster@1 | 159     $db_host = urldecode($url['host']); | 
| webmaster@1 | 160     $db_port = isset($url['port']) ? urldecode($url['port']) : ''; | 
| webmaster@1 | 161     $db_path = ltrim(urldecode($url['path']), '/'); | 
| webmaster@1 | 162     $settings_file = './'. conf_path(FALSE, TRUE) .'/settings.php'; | 
| webmaster@1 | 163 | 
| webmaster@1 | 164     $form_state = array(); | 
| webmaster@1 | 165     _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file, $form_state); | 
| webmaster@1 | 166     if (!form_get_errors()) { | 
| webmaster@1 | 167       return TRUE; | 
| webmaster@1 | 168     } | 
| webmaster@1 | 169   } | 
| webmaster@1 | 170   return FALSE; | 
| webmaster@1 | 171 } | 
| webmaster@1 | 172 | 
| webmaster@1 | 173 /** | 
| webmaster@1 | 174  * Configure and rewrite settings.php. | 
| webmaster@1 | 175  */ | 
| webmaster@1 | 176 function install_change_settings($profile = 'default', $install_locale = '') { | 
| webmaster@1 | 177   global $db_url, $db_type, $db_prefix; | 
| webmaster@1 | 178 | 
| webmaster@1 | 179   $url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url); | 
| webmaster@1 | 180   $db_user = isset($url['user']) ? urldecode($url['user']) : ''; | 
| webmaster@1 | 181   $db_pass = isset($url['pass']) ? urldecode($url['pass']) : ''; | 
| webmaster@1 | 182   $db_host = isset($url['host']) ? urldecode($url['host']) : ''; | 
| webmaster@1 | 183   $db_port = isset($url['port']) ? urldecode($url['port']) : ''; | 
| webmaster@1 | 184   $db_path = ltrim(urldecode($url['path']), '/'); | 
| webmaster@1 | 185   $conf_path = './'. conf_path(FALSE, TRUE); | 
| webmaster@1 | 186   $settings_file = $conf_path .'/settings.php'; | 
| webmaster@1 | 187 | 
| webmaster@1 | 188   // We always need this because we want to run form_get_errors. | 
| webmaster@1 | 189   include_once './includes/form.inc'; | 
| webmaster@1 | 190   install_task_list('database'); | 
| webmaster@1 | 191 | 
| webmaster@1 | 192   if ($db_url == 'mysql://username:password@localhost/databasename') { | 
| webmaster@1 | 193     $db_user = $db_pass = $db_path = ''; | 
| webmaster@1 | 194   } | 
| webmaster@1 | 195   elseif (!empty($db_url)) { | 
| webmaster@1 | 196     // Do not install over a configured settings.php. | 
| webmaster@1 | 197     install_already_done_error(); | 
| webmaster@1 | 198   } | 
| webmaster@1 | 199 | 
| webmaster@1 | 200   $output = drupal_get_form('install_settings_form', $profile, $install_locale, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host, $db_port, $db_path); | 
| webmaster@1 | 201   drupal_set_title(st('Database configuration')); | 
| webmaster@1 | 202   print theme('install_page', $output); | 
| webmaster@1 | 203   exit; | 
| webmaster@1 | 204 } | 
| webmaster@1 | 205 | 
| webmaster@1 | 206 | 
| webmaster@1 | 207 /** | 
| webmaster@1 | 208  * Form API array definition for install_settings. | 
| webmaster@1 | 209  */ | 
| webmaster@1 | 210 function install_settings_form(&$form_state, $profile, $install_locale, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host, $db_port, $db_path) { | 
| webmaster@1 | 211   if (empty($db_host)) { | 
| webmaster@1 | 212     $db_host = 'localhost'; | 
| webmaster@1 | 213   } | 
| webmaster@1 | 214   $db_types = drupal_detect_database_types(); | 
| webmaster@1 | 215 | 
| webmaster@1 | 216   // If both 'mysql' and 'mysqli' are available, we disable 'mysql': | 
| webmaster@1 | 217   if (isset($db_types['mysqli'])) { | 
| webmaster@1 | 218     unset($db_types['mysql']); | 
| webmaster@1 | 219   } | 
| webmaster@1 | 220 | 
| webmaster@1 | 221   if (count($db_types) == 0) { | 
| webmaster@1 | 222     $form['no_db_types'] = array( | 
| webmaster@1 | 223       '#value' => st('Your web server does not appear to support any common database types. Check with your hosting provider to see if they offer any databases that <a href="@drupal-databases">Drupal supports</a>.', array('@drupal-databases' => 'http://drupal.org/node/270#database')), | 
| webmaster@1 | 224     ); | 
| webmaster@1 | 225   } | 
| webmaster@1 | 226   else { | 
| webmaster@1 | 227     $form['basic_options'] = array( | 
| webmaster@1 | 228       '#type' => 'fieldset', | 
| webmaster@1 | 229       '#title' => st('Basic options'), | 
| webmaster@1 | 230       '#description' => '<p>'. st('To set up your @drupal database, enter the following information.', array('@drupal' => drupal_install_profile_name())) .'</p>', | 
| webmaster@1 | 231     ); | 
| webmaster@1 | 232 | 
| webmaster@1 | 233     if (count($db_types) > 1) { | 
| webmaster@1 | 234       $form['basic_options']['db_type'] = array( | 
| webmaster@1 | 235         '#type' => 'radios', | 
| webmaster@1 | 236         '#title' => st('Database type'), | 
| webmaster@1 | 237         '#required' => TRUE, | 
| webmaster@1 | 238         '#options' => $db_types, | 
| webmaster@1 | 239         '#default_value' => ($db_type ? $db_type : current($db_types)), | 
| webmaster@1 | 240         '#description' => st('The type of database your @drupal data will be stored in.', array('@drupal' => drupal_install_profile_name())), | 
| webmaster@1 | 241       ); | 
| webmaster@1 | 242       $db_path_description = st('The name of the database your @drupal data will be stored in. It must exist on your server before @drupal can be installed.', array('@drupal' => drupal_install_profile_name())); | 
| webmaster@1 | 243     } | 
| webmaster@1 | 244     else { | 
| webmaster@1 | 245       if (count($db_types) == 1) { | 
| webmaster@1 | 246         $db_types = array_values($db_types); | 
| webmaster@1 | 247         $form['basic_options']['db_type'] = array( | 
| webmaster@1 | 248           '#type' => 'hidden', | 
| webmaster@1 | 249           '#value' => $db_types[0], | 
| webmaster@1 | 250         ); | 
| webmaster@1 | 251         $db_path_description = st('The name of the %db_type database your @drupal data will be stored in. It must exist on your server before @drupal can be installed.', array('%db_type' => $db_types[0], '@drupal' => drupal_install_profile_name())); | 
| webmaster@1 | 252       } | 
| webmaster@1 | 253     } | 
| webmaster@1 | 254 | 
| webmaster@1 | 255     // Database name | 
| webmaster@1 | 256     $form['basic_options']['db_path'] = array( | 
| webmaster@1 | 257       '#type' => 'textfield', | 
| webmaster@1 | 258       '#title' => st('Database name'), | 
| webmaster@1 | 259       '#default_value' => $db_path, | 
| webmaster@1 | 260       '#size' => 45, | 
| webmaster@1 | 261       '#maxlength' => 45, | 
| webmaster@1 | 262       '#required' => TRUE, | 
| webmaster@1 | 263       '#description' => $db_path_description | 
| webmaster@1 | 264     ); | 
| webmaster@1 | 265 | 
| webmaster@1 | 266     // Database username | 
| webmaster@1 | 267     $form['basic_options']['db_user'] = array( | 
| webmaster@1 | 268       '#type' => 'textfield', | 
| webmaster@1 | 269       '#title' => st('Database username'), | 
| webmaster@1 | 270       '#default_value' => $db_user, | 
| webmaster@1 | 271       '#size' => 45, | 
| webmaster@1 | 272       '#maxlength' => 45, | 
| webmaster@1 | 273       '#required' => TRUE, | 
| webmaster@1 | 274     ); | 
| webmaster@1 | 275 | 
| webmaster@1 | 276     // Database username | 
| webmaster@1 | 277     $form['basic_options']['db_pass'] = array( | 
| webmaster@1 | 278       '#type' => 'password', | 
| webmaster@1 | 279       '#title' => st('Database password'), | 
| webmaster@1 | 280       '#default_value' => $db_pass, | 
| webmaster@1 | 281       '#size' => 45, | 
| webmaster@1 | 282       '#maxlength' => 45, | 
| webmaster@1 | 283     ); | 
| webmaster@1 | 284 | 
| webmaster@1 | 285     $form['advanced_options'] = array( | 
| webmaster@1 | 286       '#type' => 'fieldset', | 
| webmaster@1 | 287       '#title' => st('Advanced options'), | 
| webmaster@1 | 288       '#collapsible' => TRUE, | 
| webmaster@1 | 289       '#collapsed' => TRUE, | 
| webmaster@1 | 290       '#description' => st("These options are only necessary for some sites. If you're not sure what you should enter here, leave the default settings or check with your hosting provider.") | 
| webmaster@1 | 291     ); | 
| webmaster@1 | 292 | 
| webmaster@1 | 293     // Database host | 
| webmaster@1 | 294     $form['advanced_options']['db_host'] = array( | 
| webmaster@1 | 295       '#type' => 'textfield', | 
| webmaster@1 | 296       '#title' => st('Database host'), | 
| webmaster@1 | 297       '#default_value' => $db_host, | 
| webmaster@1 | 298       '#size' => 45, | 
| webmaster@1 | 299       '#maxlength' => 45, | 
| webmaster@1 | 300       '#required' => TRUE, | 
| webmaster@1 | 301       '#description' => st('If your database is located on a different server, change this.'), | 
| webmaster@1 | 302     ); | 
| webmaster@1 | 303 | 
| webmaster@1 | 304     // Database port | 
| webmaster@1 | 305     $form['advanced_options']['db_port'] = array( | 
| webmaster@1 | 306       '#type' => 'textfield', | 
| webmaster@1 | 307       '#title' => st('Database port'), | 
| webmaster@1 | 308       '#default_value' => $db_port, | 
| webmaster@1 | 309       '#size' => 45, | 
| webmaster@1 | 310       '#maxlength' => 45, | 
| webmaster@1 | 311       '#description' => st('If your database server is listening to a non-standard port, enter its number.'), | 
| webmaster@1 | 312     ); | 
| webmaster@1 | 313 | 
| webmaster@1 | 314     // Table prefix | 
| webmaster@1 | 315     $prefix = ($profile == 'default') ? 'drupal_' : $profile .'_'; | 
| webmaster@1 | 316     $form['advanced_options']['db_prefix'] = array( | 
| webmaster@1 | 317       '#type' => 'textfield', | 
| webmaster@1 | 318       '#title' => st('Table prefix'), | 
| webmaster@1 | 319       '#default_value' => $db_prefix, | 
| webmaster@1 | 320       '#size' => 45, | 
| webmaster@1 | 321       '#maxlength' => 45, | 
| webmaster@1 | 322       '#description' => st('If more than one application will be sharing this database, enter a table prefix such as %prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_name(), '%prefix' => $prefix)), | 
| webmaster@1 | 323     ); | 
| webmaster@1 | 324 | 
| webmaster@1 | 325     $form['save'] = array( | 
| webmaster@1 | 326       '#type' => 'submit', | 
| webmaster@1 | 327       '#value' => st('Save and continue'), | 
| webmaster@1 | 328     ); | 
| webmaster@1 | 329 | 
| webmaster@1 | 330     $form['errors'] = array(); | 
| webmaster@1 | 331     $form['settings_file'] = array('#type' => 'value', '#value' => $settings_file); | 
| webmaster@1 | 332     $form['_db_url'] = array('#type' => 'value'); | 
| webmaster@1 | 333     $form['#action'] = "install.php?profile=$profile". ($install_locale ? "&locale=$install_locale" : ''); | 
| webmaster@1 | 334     $form['#redirect'] = FALSE; | 
| webmaster@1 | 335   } | 
| webmaster@1 | 336   return $form; | 
| webmaster@1 | 337 } | 
| webmaster@1 | 338 | 
| webmaster@1 | 339 /** | 
| webmaster@1 | 340  * Form API validate for install_settings form. | 
| webmaster@1 | 341  */ | 
| webmaster@1 | 342 function install_settings_form_validate($form, &$form_state) { | 
| webmaster@1 | 343   global $db_url; | 
| webmaster@1 | 344   _install_settings_form_validate($form_state['values']['db_prefix'], $form_state['values']['db_type'], $form_state['values']['db_user'], $form_state['values']['db_pass'], $form_state['values']['db_host'], $form_state['values']['db_port'], $form_state['values']['db_path'], $form_state['values']['settings_file'], $form_state, $form); | 
| webmaster@1 | 345 } | 
| webmaster@1 | 346 | 
| webmaster@1 | 347 /** | 
| webmaster@1 | 348  * Helper function for install_settings_validate. | 
| webmaster@1 | 349  */ | 
| webmaster@1 | 350 function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file, &$form_state, $form = NULL) { | 
| webmaster@1 | 351   global $db_url; | 
| webmaster@1 | 352 | 
| webmaster@1 | 353   // Verify the table prefix | 
| webmaster@1 | 354   if (!empty($db_prefix) && is_string($db_prefix) && !preg_match('/^[A-Za-z0-9_.]+$/', $db_prefix)) { | 
| webmaster@1 | 355     form_set_error('db_prefix', st('The database table prefix you have entered, %db_prefix, is invalid. The table prefix can only contain alphanumeric characters, periods, or underscores.', array('%db_prefix' => $db_prefix)), 'error'); | 
| webmaster@1 | 356   } | 
| webmaster@1 | 357 | 
| webmaster@1 | 358   if (!empty($db_port) && !is_numeric($db_port)) { | 
| webmaster@1 | 359     form_set_error('db_port', st('Database port must be a number.')); | 
| webmaster@1 | 360   } | 
| webmaster@1 | 361 | 
| webmaster@1 | 362   // Check database type | 
| webmaster@1 | 363   if (!isset($form)) { | 
| webmaster@1 | 364     $_db_url = is_array($db_url) ? $db_url['default'] : $db_url; | 
| webmaster@1 | 365     $db_type = substr($_db_url, 0, strpos($_db_url, '://')); | 
| webmaster@1 | 366   } | 
| webmaster@1 | 367   $databases = drupal_detect_database_types(); | 
| webmaster@1 | 368   if (!in_array($db_type, $databases)) { | 
| webmaster@1 | 369     form_set_error('db_type', st("In your %settings_file file you have configured @drupal to use a %db_type server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@drupal' => drupal_install_profile_name(), '%db_type' => $db_type))); | 
| webmaster@1 | 370   } | 
| webmaster@1 | 371   else { | 
| webmaster@1 | 372     // Verify | 
| webmaster@1 | 373     $db_url = $db_type .'://'. urlencode($db_user) . ($db_pass ? ':'. urlencode($db_pass) : '') .'@'. ($db_host ? urlencode($db_host) : 'localhost') . ($db_port ? ":$db_port" : '') .'/'. urlencode($db_path); | 
| webmaster@1 | 374     if (isset($form)) { | 
| webmaster@1 | 375       form_set_value($form['_db_url'], $db_url, $form_state); | 
| webmaster@1 | 376     } | 
| webmaster@1 | 377     $success = array(); | 
| webmaster@1 | 378 | 
| webmaster@1 | 379     $function = 'drupal_test_'. $db_type; | 
| webmaster@1 | 380     if (!$function($db_url, $success)) { | 
| webmaster@1 | 381       if (isset($success['CONNECT'])) { | 
| webmaster@1 | 382         form_set_error('db_type', st('In order for Drupal to work, and to continue with the installation process, you must resolve all permission issues reported above. We were able to verify that we have permission for the following commands: %commands. For more help with configuring your database server, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what any of this means you should probably contact your hosting provider.', array('%commands' => implode($success, ', ')))); | 
| webmaster@1 | 383       } | 
| webmaster@1 | 384       else { | 
| webmaster@1 | 385         form_set_error('db_type', ''); | 
| webmaster@1 | 386       } | 
| webmaster@1 | 387     } | 
| webmaster@1 | 388   } | 
| webmaster@1 | 389 } | 
| webmaster@1 | 390 | 
| webmaster@1 | 391 /** | 
| webmaster@1 | 392  * Form API submit for install_settings form. | 
| webmaster@1 | 393  */ | 
| webmaster@1 | 394 function install_settings_form_submit($form, &$form_state) { | 
| webmaster@1 | 395   global $profile, $install_locale; | 
| webmaster@1 | 396 | 
| webmaster@1 | 397   // Update global settings array and save | 
| webmaster@1 | 398   $settings['db_url'] = array( | 
| webmaster@1 | 399     'value'    => $form_state['values']['_db_url'], | 
| webmaster@1 | 400     'required' => TRUE, | 
| webmaster@1 | 401   ); | 
| webmaster@1 | 402   $settings['db_prefix'] = array( | 
| webmaster@1 | 403     'value'    => $form_state['values']['db_prefix'], | 
| webmaster@1 | 404     'required' => TRUE, | 
| webmaster@1 | 405   ); | 
| webmaster@1 | 406   drupal_rewrite_settings($settings); | 
| webmaster@1 | 407 | 
| webmaster@1 | 408   // Continue to install profile step | 
| webmaster@1 | 409   install_goto("install.php?profile=$profile". ($install_locale ? "&locale=$install_locale" : '')); | 
| webmaster@1 | 410 } | 
| webmaster@1 | 411 | 
| webmaster@1 | 412 /** | 
| webmaster@1 | 413  * Find all .profile files. | 
| webmaster@1 | 414  */ | 
| webmaster@1 | 415 function install_find_profiles() { | 
| webmaster@1 | 416   return file_scan_directory('./profiles', '\.profile$', array('.', '..', 'CVS'), 0, TRUE, 'name', 0); | 
| webmaster@1 | 417 } | 
| webmaster@1 | 418 | 
| webmaster@1 | 419 /** | 
| webmaster@1 | 420  * Allow admin to select which profile to install. | 
| webmaster@1 | 421  * | 
| webmaster@1 | 422  * @return | 
| webmaster@1 | 423  *   The selected profile. | 
| webmaster@1 | 424  */ | 
| webmaster@1 | 425 function install_select_profile() { | 
| webmaster@1 | 426   include_once './includes/form.inc'; | 
| webmaster@1 | 427 | 
| webmaster@1 | 428   $profiles = install_find_profiles(); | 
| webmaster@1 | 429   // Don't need to choose profile if only one available. | 
| webmaster@1 | 430   if (sizeof($profiles) == 1) { | 
| webmaster@1 | 431     $profile = array_pop($profiles); | 
| webmaster@1 | 432     require_once $profile->filename; | 
| webmaster@1 | 433     return $profile->name; | 
| webmaster@1 | 434   } | 
| webmaster@1 | 435   elseif (sizeof($profiles) > 1) { | 
| webmaster@1 | 436     foreach ($profiles as $profile) { | 
| webmaster@1 | 437       if (!empty($_POST['profile']) && ($_POST['profile'] == $profile->name)) { | 
| webmaster@1 | 438         return $profile->name; | 
| webmaster@1 | 439       } | 
| webmaster@1 | 440     } | 
| webmaster@1 | 441 | 
| webmaster@1 | 442     install_task_list('profile-select'); | 
| webmaster@1 | 443 | 
| webmaster@1 | 444     drupal_set_title(st('Select an installation profile')); | 
| webmaster@1 | 445     print theme('install_page', drupal_get_form('install_select_profile_form', $profiles)); | 
| webmaster@1 | 446     exit; | 
| webmaster@1 | 447   } | 
| webmaster@1 | 448 } | 
| webmaster@1 | 449 | 
| webmaster@1 | 450 /** | 
| webmaster@1 | 451  * Form API array definition for the profile selection form. | 
| webmaster@1 | 452  */ | 
| webmaster@1 | 453 function install_select_profile_form(&$form_state, $profiles) { | 
| webmaster@1 | 454   foreach ($profiles as $profile) { | 
| webmaster@1 | 455     include_once($profile->filename); | 
| webmaster@1 | 456     // Load profile details. | 
| webmaster@1 | 457     $function = $profile->name .'_profile_details'; | 
| webmaster@1 | 458     if (function_exists($function)) { | 
| webmaster@1 | 459       $details = $function(); | 
| webmaster@1 | 460     } | 
| webmaster@1 | 461     // If set, used defined name. Otherwise use file name. | 
| webmaster@1 | 462     $name = isset($details['name']) ? $details['name'] : $profile->name; | 
| webmaster@1 | 463     $form['profile'][$name] = array( | 
| webmaster@1 | 464       '#type' => 'radio', | 
| webmaster@1 | 465       '#value' => 'default', | 
| webmaster@1 | 466       '#return_value' => $profile->name, | 
| webmaster@1 | 467       '#title' => $name, | 
| webmaster@1 | 468       '#description' => isset($details['description']) ? $details['description'] : '', | 
| webmaster@1 | 469       '#parents' => array('profile'), | 
| webmaster@1 | 470     ); | 
| webmaster@1 | 471   } | 
| webmaster@1 | 472   $form['submit'] =  array( | 
| webmaster@1 | 473     '#type' => 'submit', | 
| webmaster@1 | 474     '#value' => st('Save and continue'), | 
| webmaster@1 | 475   ); | 
| webmaster@1 | 476   return $form; | 
| webmaster@1 | 477 } | 
| webmaster@1 | 478 | 
| webmaster@1 | 479 /** | 
| webmaster@1 | 480  * Find all .po files for the current profile. | 
| webmaster@1 | 481  */ | 
| webmaster@1 | 482 function install_find_locales($profilename) { | 
| webmaster@1 | 483   $locales = file_scan_directory('./profiles/'. $profilename .'/translations', '\.po$', array('.', '..', 'CVS'), 0, FALSE); | 
| webmaster@1 | 484   array_unshift($locales, (object) array('name' => 'en')); | 
| webmaster@1 | 485   return $locales; | 
| webmaster@1 | 486 } | 
| webmaster@1 | 487 | 
| webmaster@1 | 488 /** | 
| webmaster@1 | 489  * Allow admin to select which locale to use for the current profile. | 
| webmaster@1 | 490  * | 
| webmaster@1 | 491  * @return | 
| webmaster@1 | 492  *   The selected language. | 
| webmaster@1 | 493  */ | 
| webmaster@1 | 494 function install_select_locale($profilename) { | 
| webmaster@1 | 495   include_once './includes/file.inc'; | 
| webmaster@1 | 496   include_once './includes/form.inc'; | 
| webmaster@1 | 497 | 
| webmaster@1 | 498   // Find all available locales. | 
| webmaster@1 | 499   $locales = install_find_locales($profilename); | 
| webmaster@1 | 500 | 
| webmaster@1 | 501   // If only the built-in (English) language is available, | 
| webmaster@1 | 502   // and we are using the default profile, inform the user | 
| webmaster@1 | 503   // that the installer can be localized. Otherwise we assume | 
| webmaster@1 | 504   // the user know what he is doing. | 
| webmaster@1 | 505   if (count($locales) == 1) { | 
| webmaster@1 | 506     if ($profilename == 'default') { | 
| webmaster@1 | 507       install_task_list('locale-select'); | 
| webmaster@1 | 508       drupal_set_title(st('Choose language')); | 
| webmaster@1 | 509       if (!empty($_GET['localize'])) { | 
| webmaster@1 | 510         $output = '<p>'. st('With the addition of an appropriate translation package, this installer is capable of proceeding in another language of your choice. To install and use Drupal in a language other than English:') .'</p>'; | 
| webmaster@1 | 511         $output .= '<ul><li>'. st('Determine if <a href="@translations" target="_blank">a translation of this Drupal version</a> is available in your language of choice. A translation is provided via a translation package; each translation package enables the display of a specific version of Drupal in a specific language. Not all languages are available for every version of Drupal.', array('@translations' => 'http://drupal.org/project/translations')) .'</li>'; | 
| webmaster@1 | 512         $output .= '<li>'. st('If an alternative translation package of your choice is available, download and extract its contents to your Drupal root directory.') .'</li>'; | 
| webmaster@1 | 513         $output .= '<li>'. st('Return to choose language using the second link below and select your desired language from the displayed list. Reloading the page allows the list to automatically adjust to the presence of new translation packages.') .'</li>'; | 
| webmaster@1 | 514         $output .= '</ul><p>'. st('Alternatively, to install and use Drupal in English, or to defer the selection of an alternative language until after installation, select the first link below.') .'</p>'; | 
| webmaster@1 | 515         $output .= '<p>'. st('How should the installation continue?') .'</p>'; | 
| webmaster@1 | 516         $output .= '<ul><li><a href="install.php?profile='. $profilename .'&locale=en">'. st('Continue installation in English') .'</a></li><li><a href="install.php?profile='. $profilename .'">'. st('Return to choose a language') .'</a></li></ul>'; | 
| webmaster@1 | 517       } | 
| webmaster@1 | 518       else { | 
| webmaster@1 | 519         $output = '<ul><li><a href="install.php?profile='. $profilename .'&locale=en">'. st('Install Drupal in English') .'</a></li><li><a href="install.php?profile='. $profilename .'&localize=true">'. st('Learn how to install Drupal in other languages') .'</a></li></ul>'; | 
| webmaster@1 | 520       } | 
| webmaster@1 | 521       print theme('install_page', $output); | 
| webmaster@1 | 522       exit; | 
| webmaster@1 | 523     } | 
| webmaster@1 | 524     // One language, but not the default profile, assume | 
| webmaster@1 | 525     // the user knows what he is doing. | 
| webmaster@1 | 526     return FALSE; | 
| webmaster@1 | 527   } | 
| webmaster@1 | 528   else { | 
| webmaster@1 | 529     // Allow profile to pre-select the language, skipping the selection. | 
| webmaster@1 | 530     $function = $profilename .'_profile_details'; | 
| webmaster@1 | 531     if (function_exists($function)) { | 
| webmaster@1 | 532       $details = $function(); | 
| webmaster@1 | 533       if (isset($details['language'])) { | 
| webmaster@1 | 534         foreach ($locales as $locale) { | 
| webmaster@1 | 535           if ($details['language'] == $locale->name) { | 
| webmaster@1 | 536             return $locale->name; | 
| webmaster@1 | 537           } | 
| webmaster@1 | 538         } | 
| webmaster@1 | 539       } | 
| webmaster@1 | 540     } | 
| webmaster@1 | 541 | 
| webmaster@1 | 542     foreach ($locales as $locale) { | 
| webmaster@1 | 543       if ($_POST['locale'] == $locale->name) { | 
| webmaster@1 | 544         return $locale->name; | 
| webmaster@1 | 545       } | 
| webmaster@1 | 546     } | 
| webmaster@1 | 547 | 
| webmaster@1 | 548     install_task_list('locale-select'); | 
| webmaster@1 | 549 | 
| webmaster@1 | 550     drupal_set_title(st('Choose language')); | 
| webmaster@1 | 551     print theme('install_page', drupal_get_form('install_select_locale_form', $locales)); | 
| webmaster@1 | 552     exit; | 
| webmaster@1 | 553   } | 
| webmaster@1 | 554 } | 
| webmaster@1 | 555 | 
| webmaster@1 | 556 /** | 
| webmaster@1 | 557  * Form API array definition for language selection. | 
| webmaster@1 | 558  */ | 
| webmaster@1 | 559 function install_select_locale_form(&$form_state, $locales) { | 
| webmaster@1 | 560   include_once './includes/locale.inc'; | 
| webmaster@1 | 561   $languages = _locale_get_predefined_list(); | 
| webmaster@1 | 562   foreach ($locales as $locale) { | 
| webmaster@1 | 563     // Try to use verbose locale name | 
| webmaster@1 | 564     $name = $locale->name; | 
| webmaster@1 | 565     if (isset($languages[$name])) { | 
| webmaster@1 | 566       $name = $languages[$name][0] . (isset($languages[$name][1]) ? ' '. st('(@language)', array('@language' => $languages[$name][1])) : ''); | 
| webmaster@1 | 567     } | 
| webmaster@1 | 568     $form['locale'][$locale->name] = array( | 
| webmaster@1 | 569       '#type' => 'radio', | 
| webmaster@1 | 570       '#return_value' => $locale->name, | 
| webmaster@1 | 571       '#default_value' => ($locale->name == 'en' ? TRUE : FALSE), | 
| webmaster@1 | 572       '#title' => $name . ($locale->name == 'en' ? ' '. st('(built-in)') : ''), | 
| webmaster@1 | 573       '#parents' => array('locale') | 
| webmaster@1 | 574     ); | 
| webmaster@1 | 575   } | 
| webmaster@1 | 576   $form['submit'] =  array( | 
| webmaster@1 | 577     '#type' => 'submit', | 
| webmaster@1 | 578     '#value' => st('Select language'), | 
| webmaster@1 | 579   ); | 
| webmaster@1 | 580   return $form; | 
| webmaster@1 | 581 } | 
| webmaster@1 | 582 | 
| webmaster@1 | 583 /** | 
| webmaster@1 | 584  * Show an error page when there are no profiles available. | 
| webmaster@1 | 585  */ | 
| webmaster@1 | 586 function install_no_profile_error() { | 
| webmaster@1 | 587   install_task_list('profile-select'); | 
| webmaster@1 | 588   drupal_set_title(st('No profiles available')); | 
| webmaster@1 | 589   print theme('install_page', '<p>'. st('We were unable to find any installer profiles. Installer profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.') .'</p>'); | 
| webmaster@1 | 590   exit; | 
| webmaster@1 | 591 } | 
| webmaster@1 | 592 | 
| webmaster@1 | 593 | 
| webmaster@1 | 594 /** | 
| webmaster@1 | 595  * Show an error page when Drupal has already been installed. | 
| webmaster@1 | 596  */ | 
| webmaster@1 | 597 function install_already_done_error() { | 
| webmaster@1 | 598   global $base_url; | 
| webmaster@1 | 599 | 
| webmaster@1 | 600   drupal_set_title(st('Drupal already installed')); | 
| webmaster@1 | 601   print theme('install_page', st('<ul><li>To start over, you must empty your existing database.</li><li>To install to a different database, edit the appropriate <em>settings.php</em> file in the <em>sites</em> folder.</li><li>To upgrade an existing installation, proceed to the <a href="@base-url/update.php">update script</a>.</li><li>View your <a href="@base-url">existing site</a>.</li></ul>', array('@base-url' => $base_url))); | 
| webmaster@1 | 602   exit; | 
| webmaster@1 | 603 } | 
| webmaster@1 | 604 | 
| webmaster@1 | 605 /** | 
| webmaster@1 | 606  * Tasks performed after the database is initialized. | 
| webmaster@1 | 607  */ | 
| webmaster@1 | 608 function install_tasks($profile, $task) { | 
| webmaster@1 | 609   global $base_url, $install_locale; | 
| webmaster@1 | 610 | 
| webmaster@1 | 611   // Bootstrap newly installed Drupal, while preserving existing messages. | 
| webmaster@1 | 612   $messages = isset($_SESSION['messages']) ? $_SESSION['messages'] : ''; | 
| webmaster@1 | 613   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); | 
| webmaster@1 | 614   $_SESSION['messages'] = $messages; | 
| webmaster@1 | 615 | 
| webmaster@1 | 616   // URL used to direct page requests. | 
| webmaster@1 | 617   $url = $base_url .'/install.php?locale='. $install_locale .'&profile='. $profile; | 
| webmaster@1 | 618 | 
| webmaster@1 | 619   // Build a page for final tasks. | 
| webmaster@1 | 620   if (empty($task)) { | 
| webmaster@1 | 621     variable_set('install_task', 'profile-install'); | 
| webmaster@1 | 622     $task = 'profile-install'; | 
| webmaster@1 | 623   } | 
| webmaster@1 | 624 | 
| webmaster@1 | 625   // We are using a list of if constructs here to allow for | 
| webmaster@1 | 626   // passing from one task to the other in the same request. | 
| webmaster@1 | 627 | 
| webmaster@1 | 628   // Install profile modules. | 
| webmaster@1 | 629   if ($task == 'profile-install') { | 
| webmaster@1 | 630     $modules = variable_get('install_profile_modules', array()); | 
| webmaster@1 | 631     $files = module_rebuild_cache(); | 
| webmaster@1 | 632     variable_del('install_profile_modules'); | 
| webmaster@1 | 633     $operations = array(); | 
| webmaster@1 | 634     foreach ($modules as $module) { | 
| webmaster@1 | 635       $operations[] = array('_install_module_batch', array($module, $files[$module]->info['name'])); | 
| webmaster@1 | 636     } | 
| webmaster@1 | 637     $batch = array( | 
| webmaster@1 | 638       'operations' => $operations, | 
| webmaster@1 | 639       'finished' => '_install_profile_batch_finished', | 
| webmaster@1 | 640       'title' => st('Installing @drupal', array('@drupal' => drupal_install_profile_name())), | 
| webmaster@1 | 641       'error_message' => st('The installation has encountered an error.'), | 
| webmaster@1 | 642     ); | 
| webmaster@1 | 643     // Start a batch, switch to 'profile-install-batch' task. We need to | 
| webmaster@1 | 644     // set the variable here, because batch_process() redirects. | 
| webmaster@1 | 645     variable_set('install_task', 'profile-install-batch'); | 
| webmaster@1 | 646     batch_set($batch); | 
| webmaster@1 | 647     batch_process($url, $url); | 
| webmaster@1 | 648   } | 
| webmaster@1 | 649   // We are running a batch install of the profile's modules. | 
| webmaster@1 | 650   // This might run in multiple HTTP requests, constantly redirecting | 
| webmaster@1 | 651   // to the same address, until the batch finished callback is invoked | 
| webmaster@1 | 652   // and the task advances to 'locale-initial-import'. | 
| webmaster@1 | 653   if ($task == 'profile-install-batch') { | 
| webmaster@1 | 654     include_once 'includes/batch.inc'; | 
| webmaster@1 | 655     $output = _batch_page(); | 
| webmaster@1 | 656   } | 
| webmaster@1 | 657 | 
| webmaster@1 | 658   // Import interface translations for the enabled modules. | 
| webmaster@1 | 659   if ($task == 'locale-initial-import') { | 
| webmaster@1 | 660     if (!empty($install_locale) && ($install_locale != 'en')) { | 
| webmaster@1 | 661       include_once 'includes/locale.inc'; | 
| webmaster@1 | 662       // Enable installation language as default site language. | 
| webmaster@1 | 663       locale_add_language($install_locale, NULL, NULL, NULL, NULL, NULL, 1, TRUE); | 
| webmaster@1 | 664       // Collect files to import for this language. | 
| webmaster@1 | 665       $batch = locale_batch_by_language($install_locale, '_install_locale_initial_batch_finished'); | 
| webmaster@1 | 666       if (!empty($batch)) { | 
| webmaster@1 | 667         // Remember components we cover in this batch set. | 
| webmaster@1 | 668         variable_set('install_locale_batch_components', $batch['#components']); | 
| webmaster@1 | 669         // Start a batch, switch to 'locale-batch' task. We need to | 
| webmaster@1 | 670         // set the variable here, because batch_process() redirects. | 
| webmaster@1 | 671         variable_set('install_task', 'locale-initial-batch'); | 
| webmaster@1 | 672         batch_set($batch); | 
| webmaster@1 | 673         batch_process($url, $url); | 
| webmaster@1 | 674       } | 
| webmaster@1 | 675     } | 
| webmaster@1 | 676     // Found nothing to import or not foreign language, go to next task. | 
| webmaster@1 | 677     $task = 'configure'; | 
| webmaster@1 | 678   } | 
| webmaster@1 | 679   if ($task == 'locale-initial-batch') { | 
| webmaster@1 | 680     include_once 'includes/batch.inc'; | 
| webmaster@1 | 681     include_once 'includes/locale.inc'; | 
| webmaster@1 | 682     $output = _batch_page(); | 
| webmaster@1 | 683   } | 
| webmaster@1 | 684 | 
| webmaster@1 | 685   if ($task == 'configure') { | 
| webmaster@1 | 686     if (variable_get('site_name', FALSE) || variable_get('site_mail', FALSE)) { | 
| webmaster@1 | 687       // Site already configured: This should never happen, means re-running | 
| webmaster@1 | 688       // the installer, possibly by an attacker after the 'install_task' variable | 
| webmaster@1 | 689       // got accidentally blown somewhere. Stop it now. | 
| webmaster@1 | 690       install_already_done_error(); | 
| webmaster@1 | 691     } | 
| webmaster@1 | 692     $form = drupal_get_form('install_configure_form', $url); | 
| webmaster@1 | 693 | 
| webmaster@1 | 694     if (!variable_get('site_name', FALSE) && !variable_get('site_mail', FALSE)) { | 
| webmaster@1 | 695       // Not submitted yet: Prepare to display the form. | 
| webmaster@1 | 696       $output = $form; | 
| webmaster@1 | 697       drupal_set_title(st('Configure site')); | 
| webmaster@1 | 698 | 
| webmaster@1 | 699       // Warn about settings.php permissions risk | 
| webmaster@1 | 700       $settings_dir = './'. conf_path(); | 
| webmaster@1 | 701       $settings_file = $settings_dir .'/settings.php'; | 
| webmaster@1 | 702       if (!drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE) || !drupal_verify_install_file($settings_dir, FILE_NOT_WRITABLE, 'dir')) { | 
| webmaster@1 | 703         drupal_set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, please consult the <a href="@handbook_url">on-line handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/getting-started')), 'error'); | 
| webmaster@1 | 704       } | 
| webmaster@1 | 705       else { | 
| webmaster@1 | 706         drupal_set_message(st('All necessary changes to %dir and %file have been made. They have been set to read-only for security.', array('%dir' => $settings_dir, '%file' => $settings_file))); | 
| webmaster@1 | 707       } | 
| webmaster@1 | 708 | 
| webmaster@1 | 709       // Add JavaScript validation. | 
| webmaster@1 | 710       _user_password_dynamic_validation(); | 
| webmaster@1 | 711       drupal_add_js(drupal_get_path('module', 'system') .'/system.js', 'module'); | 
| webmaster@1 | 712       // We add these strings as settings because JavaScript translation does not | 
| webmaster@1 | 713       // work on install time. | 
| webmaster@1 | 714       drupal_add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail')), 'cleanURL' => array('success' => st('Your server has been successfully tested to support this feature.'), 'failure' => st('Your system configuration does not currently support this feature. The <a href="http://drupal.org/node/15365">handbook page on Clean URLs</a> has additional troubleshooting information.'), 'testing' => st('Testing clean URLs...'))), 'setting'); | 
| webmaster@1 | 715       drupal_add_js(' | 
| webmaster@1 | 716 // Global Killswitch | 
| webmaster@1 | 717 if (Drupal.jsEnabled) { | 
| webmaster@1 | 718   $(document).ready(function() { | 
| webmaster@1 | 719     Drupal.cleanURLsInstallCheck(); | 
| webmaster@1 | 720     Drupal.setDefaultTimezone(); | 
| webmaster@1 | 721   }); | 
| webmaster@1 | 722 }', 'inline'); | 
| webmaster@1 | 723       // Build menu to allow clean URL check. | 
| webmaster@1 | 724       menu_rebuild(); | 
| webmaster@1 | 725     } | 
| webmaster@1 | 726 | 
| webmaster@1 | 727     else { | 
| webmaster@1 | 728       $task = 'profile'; | 
| webmaster@1 | 729     } | 
| webmaster@1 | 730   } | 
| webmaster@1 | 731 | 
| webmaster@1 | 732   // If found an unknown task or the 'profile' task, which is | 
| webmaster@1 | 733   // reserved for profiles, hand over the control to the profile, | 
| webmaster@1 | 734   // so it can run any number of custom tasks it defines. | 
| webmaster@1 | 735   if (!in_array($task, install_reserved_tasks())) { | 
| webmaster@1 | 736     $function = $profile .'_profile_tasks'; | 
| webmaster@1 | 737     if (function_exists($function)) { | 
| webmaster@1 | 738       // The profile needs to run more code, maybe even more tasks. | 
| webmaster@1 | 739       // $task is sent through as a reference and may be changed! | 
| webmaster@1 | 740       $output = $function($task, $url); | 
| webmaster@1 | 741     } | 
| webmaster@1 | 742 | 
| webmaster@1 | 743     // If the profile doesn't move on to a new task we assume | 
| webmaster@1 | 744     // that it is done. | 
| webmaster@1 | 745     if ($task == 'profile') { | 
| webmaster@1 | 746       $task = 'profile-finished'; | 
| webmaster@1 | 747     } | 
| webmaster@1 | 748   } | 
| webmaster@1 | 749 | 
| webmaster@1 | 750   // Profile custom tasks are done, so let the installer regain | 
| webmaster@1 | 751   // control and proceed with importing the remaining translations. | 
| webmaster@1 | 752   if ($task == 'profile-finished') { | 
| webmaster@1 | 753     if (!empty($install_locale) && ($install_locale != 'en')) { | 
| webmaster@1 | 754       include_once 'includes/locale.inc'; | 
| webmaster@1 | 755       // Collect files to import for this language. Skip components | 
| webmaster@1 | 756       // already covered in the initial batch set. | 
| webmaster@1 | 757       $batch = locale_batch_by_language($install_locale, '_install_locale_remaining_batch_finished', variable_get('install_locale_batch_components', array())); | 
| webmaster@1 | 758       // Remove temporary variable. | 
| webmaster@1 | 759       variable_del('install_locale_batch_components'); | 
| webmaster@1 | 760       if (!empty($batch)) { | 
| webmaster@1 | 761         // Start a batch, switch to 'locale-remaining-batch' task. We need to | 
| webmaster@1 | 762         // set the variable here, because batch_process() redirects. | 
| webmaster@1 | 763         variable_set('install_task', 'locale-remaining-batch'); | 
| webmaster@1 | 764         batch_set($batch); | 
| webmaster@1 | 765         batch_process($url, $url); | 
| webmaster@1 | 766       } | 
| webmaster@1 | 767     } | 
| webmaster@1 | 768     // Found nothing to import or not foreign language, go to next task. | 
| webmaster@1 | 769     $task = 'finished'; | 
| webmaster@1 | 770   } | 
| webmaster@1 | 771   if ($task == 'locale-remaining-batch') { | 
| webmaster@1 | 772     include_once 'includes/batch.inc'; | 
| webmaster@1 | 773     include_once 'includes/locale.inc'; | 
| webmaster@1 | 774     $output = _batch_page(); | 
| webmaster@1 | 775   } | 
| webmaster@1 | 776 | 
| webmaster@1 | 777   // Display a 'finished' page to user. | 
| webmaster@1 | 778   if ($task == 'finished') { | 
| webmaster@1 | 779     drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_name()))); | 
| webmaster@1 | 780     $messages = drupal_set_message(); | 
| webmaster@1 | 781     $output = '<p>'. st('Congratulations, @drupal has been successfully installed.', array('@drupal' => drupal_install_profile_name())) .'</p>'; | 
| webmaster@1 | 782     $output .= '<p>'. (isset($messages['error']) ? st('Please review the messages above before continuing on to <a href="@url">your new site</a>.', array('@url' => url(''))) : st('You may now visit <a href="@url">your new site</a>.', array('@url' => url('')))) .'</p>'; | 
| webmaster@1 | 783     $task = 'done'; | 
| webmaster@1 | 784   } | 
| webmaster@1 | 785 | 
| webmaster@1 | 786   // The end of the install process. Remember profile used. | 
| webmaster@1 | 787   if ($task == 'done') { | 
| webmaster@1 | 788     // Rebuild menu to get content type links registered by the profile, | 
| webmaster@1 | 789     // and possibly any other menu items created through the tasks. | 
| webmaster@1 | 790     menu_rebuild(); | 
| webmaster@1 | 791 | 
| webmaster@1 | 792     // Register actions declared by any modules. | 
| webmaster@1 | 793     actions_synchronize(); | 
| webmaster@1 | 794 | 
| webmaster@1 | 795     // Randomize query-strings on css/js files, to hide the fact that | 
| webmaster@1 | 796     // this is a new install, not upgraded yet. | 
| webmaster@1 | 797     _drupal_flush_css_js(); | 
| webmaster@1 | 798 | 
| webmaster@1 | 799     variable_set('install_profile', $profile); | 
| webmaster@1 | 800   } | 
| webmaster@1 | 801 | 
| webmaster@1 | 802   // Set task for user, and remember the task in the database. | 
| webmaster@1 | 803   install_task_list($task); | 
| webmaster@1 | 804   variable_set('install_task', $task); | 
| webmaster@1 | 805 | 
| webmaster@1 | 806   // Output page, if some output was required. Otherwise it is possible | 
| webmaster@1 | 807   // that we are printing a JSON page and theme output should not be there. | 
| webmaster@1 | 808   if (isset($output)) { | 
| webmaster@1 | 809     print theme('maintenance_page', $output); | 
| webmaster@1 | 810   } | 
| webmaster@1 | 811 } | 
| webmaster@1 | 812 | 
| webmaster@1 | 813 /** | 
| webmaster@1 | 814  * Batch callback for batch installation of modules. | 
| webmaster@1 | 815  */ | 
| webmaster@1 | 816 function _install_module_batch($module, $module_name, &$context) { | 
| webmaster@1 | 817   _drupal_install_module($module); | 
| webmaster@1 | 818   // We enable the installed module right away, so that the module will be | 
| webmaster@1 | 819   // loaded by drupal_bootstrap in subsequent batch requests, and other | 
| webmaster@1 | 820   // modules possibly depending on it can safely perform their installation | 
| webmaster@1 | 821   // steps. | 
| webmaster@1 | 822   module_enable(array($module)); | 
| webmaster@1 | 823   $context['results'][] = $module; | 
| webmaster@1 | 824   $context['message'] = 'Installed '. $module_name .' module.'; | 
| webmaster@1 | 825 } | 
| webmaster@1 | 826 | 
| webmaster@1 | 827 /** | 
| webmaster@1 | 828  * Finished callback for the modules install batch. | 
| webmaster@1 | 829  * | 
| webmaster@1 | 830  * Advance installer task to language import. | 
| webmaster@1 | 831  */ | 
| webmaster@1 | 832 function _install_profile_batch_finished($success, $results) { | 
| webmaster@1 | 833   variable_set('install_task', 'locale-initial-import'); | 
| webmaster@1 | 834 } | 
| webmaster@1 | 835 | 
| webmaster@1 | 836 /** | 
| webmaster@1 | 837  * Finished callback for the first locale import batch. | 
| webmaster@1 | 838  * | 
| webmaster@1 | 839  * Advance installer task to the configure screen. | 
| webmaster@1 | 840  */ | 
| webmaster@1 | 841 function _install_locale_initial_batch_finished($success, $results) { | 
| webmaster@1 | 842   variable_set('install_task', 'configure'); | 
| webmaster@1 | 843 } | 
| webmaster@1 | 844 | 
| webmaster@1 | 845 /** | 
| webmaster@1 | 846  * Finished callback for the second locale import batch. | 
| webmaster@1 | 847  * | 
| webmaster@1 | 848  * Advance installer task to the finished screen. | 
| webmaster@1 | 849  */ | 
| webmaster@1 | 850 function _install_locale_remaining_batch_finished($success, $results) { | 
| webmaster@1 | 851   variable_set('install_task', 'finished'); | 
| webmaster@1 | 852 } | 
| webmaster@1 | 853 | 
| webmaster@1 | 854 /** | 
| webmaster@1 | 855  * The list of reserved tasks to run in the installer. | 
| webmaster@1 | 856  */ | 
| webmaster@1 | 857 function install_reserved_tasks() { | 
| webmaster@1 | 858   return array('configure', 'profile-install', 'profile-install-batch', 'locale-initial-import', 'locale-initial-batch', 'profile-finished', 'locale-remaining-batch', 'finished', 'done'); | 
| webmaster@1 | 859 } | 
| webmaster@1 | 860 | 
| webmaster@1 | 861 /** | 
| webmaster@1 | 862  * Check installation requirements and report any errors. | 
| webmaster@1 | 863  */ | 
| webmaster@1 | 864 function install_check_requirements($profile, $verify) { | 
| webmaster@1 | 865 | 
| webmaster@1 | 866   // If Drupal is not set up already, we need to create a settings file. | 
| webmaster@1 | 867   if (!$verify) { | 
| webmaster@1 | 868     $writable = FALSE; | 
| webmaster@1 | 869     $conf_path = './'. conf_path(FALSE, TRUE); | 
| webmaster@1 | 870     $settings_file = $conf_path .'/settings.php'; | 
| webmaster@1 | 871     $file = $conf_path; | 
| webmaster@1 | 872     // Verify that the directory exists. | 
| webmaster@1 | 873     if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) { | 
| webmaster@1 | 874       // Check to see if a settings.php already exists. | 
| webmaster@1 | 875       if (drupal_verify_install_file($settings_file, FILE_EXIST)) { | 
| webmaster@1 | 876         // If it does, make sure it is writable. | 
| webmaster@1 | 877         $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE); | 
| webmaster@1 | 878         $file = $settings_file; | 
| webmaster@1 | 879       } | 
| webmaster@1 | 880       else { | 
| webmaster@1 | 881         // If not, make sure the directory is. | 
| webmaster@1 | 882         $writable = drupal_verify_install_file($conf_path, FILE_READABLE|FILE_WRITABLE, 'dir'); | 
| webmaster@1 | 883       } | 
| webmaster@1 | 884     } | 
| webmaster@1 | 885 | 
| webmaster@1 | 886     if (!$writable) { | 
| webmaster@1 | 887       drupal_set_message(st('The @drupal installer requires write permissions to %file during the installation process. If you are unsure how to grant file permissions, please consult the <a href="@handbook_url">on-line handbook</a>.', array('@drupal' => drupal_install_profile_name(), '%file' => $file, '@handbook_url' => 'http://drupal.org/server-permissions')), 'error'); | 
| webmaster@1 | 888     } | 
| webmaster@1 | 889   } | 
| webmaster@1 | 890 | 
| webmaster@1 | 891   // Check the other requirements. | 
| webmaster@1 | 892   $requirements = drupal_check_profile($profile); | 
| webmaster@1 | 893   $severity = drupal_requirements_severity($requirements); | 
| webmaster@1 | 894 | 
| webmaster@1 | 895   // If there are issues, report them. | 
| webmaster@1 | 896   if ($severity == REQUIREMENT_ERROR) { | 
| webmaster@1 | 897 | 
| webmaster@1 | 898     foreach ($requirements as $requirement) { | 
| webmaster@1 | 899       if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) { | 
| webmaster@1 | 900         $message = $requirement['description']; | 
| webmaster@1 | 901         if (isset($requirement['value']) && $requirement['value']) { | 
| webmaster@1 | 902           $message .= ' ('. st('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) .')'; | 
| webmaster@1 | 903         } | 
| webmaster@1 | 904         drupal_set_message($message, 'error'); | 
| webmaster@1 | 905       } | 
| webmaster@1 | 906     } | 
| webmaster@1 | 907   } | 
| webmaster@1 | 908   if ($severity == REQUIREMENT_WARNING) { | 
| webmaster@1 | 909 | 
| webmaster@1 | 910     foreach ($requirements as $requirement) { | 
| webmaster@1 | 911       if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_WARNING) { | 
| webmaster@1 | 912         $message = $requirement['description']; | 
| webmaster@1 | 913         if (isset($requirement['value']) && $requirement['value']) { | 
| webmaster@1 | 914           $message .= ' ('. st('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) .')'; | 
| webmaster@1 | 915         } | 
| webmaster@1 | 916         drupal_set_message($message, 'warning'); | 
| webmaster@1 | 917       } | 
| webmaster@1 | 918     } | 
| webmaster@1 | 919   } | 
| webmaster@1 | 920 } | 
| webmaster@1 | 921 | 
| webmaster@1 | 922 /** | 
| webmaster@1 | 923  * Add the installation task list to the current page. | 
| webmaster@1 | 924  */ | 
| webmaster@1 | 925 function install_task_list($active = NULL) { | 
| webmaster@1 | 926   // Default list of tasks. | 
| webmaster@1 | 927   $tasks = array( | 
| webmaster@1 | 928     'profile-select'        => st('Choose profile'), | 
| webmaster@1 | 929     'locale-select'         => st('Choose language'), | 
| webmaster@1 | 930     'requirements'          => st('Verify requirements'), | 
| webmaster@1 | 931     'database'              => st('Set up database'), | 
| webmaster@1 | 932     'profile-install-batch' => st('Install profile'), | 
| webmaster@1 | 933     'locale-initial-batch'  => st('Set up translations'), | 
| webmaster@1 | 934     'configure'             => st('Configure site'), | 
| webmaster@1 | 935   ); | 
| webmaster@1 | 936 | 
| webmaster@1 | 937   $profiles = install_find_profiles(); | 
| webmaster@1 | 938   $profile = isset($_GET['profile']) && isset($profiles[$_GET['profile']]) ? $_GET['profile'] : '.'; | 
| webmaster@1 | 939   $locales = install_find_locales($profile); | 
| webmaster@1 | 940 | 
| webmaster@1 | 941   // If we have only one profile, remove 'Choose profile' | 
| webmaster@1 | 942   // and rename 'Install profile'. | 
| webmaster@1 | 943   if (count($profiles) == 1) { | 
| webmaster@1 | 944     unset($tasks['profile-select']); | 
| webmaster@1 | 945     $tasks['profile-install-batch'] = st('Install site'); | 
| webmaster@1 | 946   } | 
| webmaster@1 | 947 | 
| webmaster@1 | 948   // Add tasks defined by the profile. | 
| webmaster@1 | 949   if ($profile) { | 
| webmaster@1 | 950     $function = $profile .'_profile_task_list'; | 
| webmaster@1 | 951     if (function_exists($function)) { | 
| webmaster@1 | 952       $result = $function(); | 
| webmaster@1 | 953       if (is_array($result)) { | 
| webmaster@1 | 954         $tasks += $result; | 
| webmaster@1 | 955       } | 
| webmaster@1 | 956     } | 
| webmaster@1 | 957   } | 
| webmaster@1 | 958 | 
| webmaster@1 | 959   if (count($locales) < 2 || empty($_GET['locale']) || $_GET['locale'] == 'en') { | 
| webmaster@1 | 960     // If not required, remove translation import from the task list. | 
| webmaster@1 | 961     unset($tasks['locale-initial-batch']); | 
| webmaster@1 | 962   } | 
| webmaster@1 | 963   else { | 
| webmaster@1 | 964     // If required, add remaining translations import task. | 
| webmaster@1 | 965     $tasks += array('locale-remaining-batch' => st('Finish translations')); | 
| webmaster@1 | 966   } | 
| webmaster@1 | 967 | 
| webmaster@1 | 968   // Add finished step as the last task. | 
| webmaster@1 | 969   $tasks += array( | 
| webmaster@1 | 970     'finished'     => st('Finished') | 
| webmaster@1 | 971   ); | 
| webmaster@1 | 972 | 
| webmaster@1 | 973   // Let the theming function know that 'finished' and 'done' | 
| webmaster@1 | 974   // include everything, so every step is completed. | 
| webmaster@1 | 975   if (in_array($active, array('finished', 'done'))) { | 
| webmaster@1 | 976     $active = NULL; | 
| webmaster@1 | 977   } | 
| webmaster@1 | 978   drupal_set_content('left', theme_task_list($tasks, $active)); | 
| webmaster@1 | 979 } | 
| webmaster@1 | 980 | 
| webmaster@1 | 981 /** | 
| webmaster@1 | 982  * Form API array definition for site configuration. | 
| webmaster@1 | 983  */ | 
| webmaster@1 | 984 function install_configure_form(&$form_state, $url) { | 
| webmaster@1 | 985 | 
| webmaster@1 | 986   $form['intro'] = array( | 
| webmaster@1 | 987     '#value' => st('To configure your website, please provide the following information.'), | 
| webmaster@1 | 988     '#weight' => -10, | 
| webmaster@1 | 989   ); | 
| webmaster@1 | 990   $form['site_information'] = array( | 
| webmaster@1 | 991     '#type' => 'fieldset', | 
| webmaster@1 | 992     '#title' => st('Site information'), | 
| webmaster@1 | 993     '#collapsible' => FALSE, | 
| webmaster@1 | 994   ); | 
| webmaster@1 | 995   $form['site_information']['site_name'] = array( | 
| webmaster@1 | 996     '#type' => 'textfield', | 
| webmaster@1 | 997     '#title' => st('Site name'), | 
| webmaster@1 | 998     '#required' => TRUE, | 
| webmaster@1 | 999     '#weight' => -20, | 
| webmaster@1 | 1000   ); | 
| webmaster@1 | 1001   $form['site_information']['site_mail'] = array( | 
| webmaster@1 | 1002     '#type' => 'textfield', | 
| webmaster@1 | 1003     '#title' => st('Site e-mail address'), | 
| webmaster@1 | 1004     '#default_value' => ini_get('sendmail_from'), | 
| webmaster@1 | 1005     '#description' => st("The <em>From</em> address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"), | 
| webmaster@1 | 1006     '#required' => TRUE, | 
| webmaster@1 | 1007     '#weight' => -15, | 
| webmaster@1 | 1008   ); | 
| webmaster@1 | 1009   $form['admin_account'] = array( | 
| webmaster@1 | 1010     '#type' => 'fieldset', | 
| webmaster@1 | 1011     '#title' => st('Administrator account'), | 
| webmaster@1 | 1012     '#collapsible' => FALSE, | 
| webmaster@1 | 1013   ); | 
| webmaster@1 | 1014   $form['admin_account']['account']['#tree'] = TRUE; | 
| webmaster@1 | 1015   $form['admin_account']['markup'] = array( | 
| webmaster@1 | 1016     '#value' => '<p class="description">'. st('The administrator account has complete access to the site; it will automatically be granted all permissions and can perform any administrative activity. This will be the only account that can perform certain activities, so keep its credentials safe.') .'</p>', | 
| webmaster@1 | 1017     '#weight' => -10, | 
| webmaster@1 | 1018   ); | 
| webmaster@1 | 1019 | 
| webmaster@1 | 1020   $form['admin_account']['account']['name'] = array('#type' => 'textfield', | 
| webmaster@1 | 1021     '#title' => st('Username'), | 
| webmaster@1 | 1022     '#maxlength' => USERNAME_MAX_LENGTH, | 
| webmaster@1 | 1023     '#description' => st('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'), | 
| webmaster@1 | 1024     '#required' => TRUE, | 
| webmaster@1 | 1025     '#weight' => -10, | 
| webmaster@1 | 1026   ); | 
| webmaster@1 | 1027 | 
| webmaster@1 | 1028   $form['admin_account']['account']['mail'] = array('#type' => 'textfield', | 
| webmaster@1 | 1029     '#title' => st('E-mail address'), | 
| webmaster@1 | 1030     '#maxlength' => EMAIL_MAX_LENGTH, | 
| webmaster@1 | 1031     '#description' => st('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.'), | 
| webmaster@1 | 1032     '#required' => TRUE, | 
| webmaster@1 | 1033     '#weight' => -5, | 
| webmaster@1 | 1034   ); | 
| webmaster@1 | 1035   $form['admin_account']['account']['pass'] = array( | 
| webmaster@1 | 1036     '#type' => 'password_confirm', | 
| webmaster@1 | 1037     '#required' => TRUE, | 
| webmaster@1 | 1038     '#size' => 25, | 
| webmaster@1 | 1039     '#weight' => 0, | 
| webmaster@1 | 1040   ); | 
| webmaster@1 | 1041 | 
| webmaster@1 | 1042   $form['server_settings'] = array( | 
| webmaster@1 | 1043     '#type' => 'fieldset', | 
| webmaster@1 | 1044     '#title' => st('Server settings'), | 
| webmaster@1 | 1045     '#collapsible' => FALSE, | 
| webmaster@1 | 1046   ); | 
| webmaster@1 | 1047   $form['server_settings']['date_default_timezone'] = array( | 
| webmaster@1 | 1048     '#type' => 'select', | 
| webmaster@1 | 1049     '#title' => st('Default time zone'), | 
| webmaster@1 | 1050     '#default_value' => 0, | 
| webmaster@1 | 1051     '#options' => _system_zonelist(), | 
| webmaster@1 | 1052     '#description' => st('By default, dates in this site will be displayed in the chosen time zone.'), | 
| webmaster@1 | 1053     '#weight' => 5, | 
| webmaster@1 | 1054   ); | 
| webmaster@1 | 1055 | 
| webmaster@1 | 1056   $form['server_settings']['clean_url'] = array( | 
| webmaster@1 | 1057     '#type' => 'radios', | 
| webmaster@1 | 1058     '#title' => st('Clean URLs'), | 
| webmaster@1 | 1059     '#default_value' => 0, | 
| webmaster@1 | 1060     '#options' => array(0 => st('Disabled'), 1 => st('Enabled')), | 
| webmaster@1 | 1061     '#description' => st('This option makes Drupal emit "clean" URLs (i.e. without <code>?q=</code> in the URL).'), | 
| webmaster@1 | 1062     '#disabled' => TRUE, | 
| webmaster@1 | 1063     '#prefix' => '<div id="clean-url" class="install">', | 
| webmaster@1 | 1064     '#suffix' => '</div>', | 
| webmaster@1 | 1065     '#weight' => 10, | 
| webmaster@1 | 1066   ); | 
| webmaster@1 | 1067 | 
| webmaster@1 | 1068   $form['server_settings']['update_status_module'] = array( | 
| webmaster@1 | 1069     '#type' => 'checkboxes', | 
| webmaster@1 | 1070     '#title' => st('Update notifications'), | 
| webmaster@1 | 1071     '#options' => array(1 => st('Check for updates automatically')), | 
| webmaster@1 | 1072     '#default_value' => array(1), | 
| webmaster@1 | 1073     '#description' => st('With this option enabled, Drupal will notify you when new releases are available. This will significantly enhance your site\'s security and is <strong>highly recommended</strong>. This requires your site to periodically send anonymous information on its installed components to <a href="@drupal">drupal.org</a>. For more information please see the <a href="@update">update notification information</a>.', array('@drupal' => 'http://drupal.org', '@update' => 'http://drupal.org/handbook/modules/update')), | 
| webmaster@1 | 1074     '#weight' => 15, | 
| webmaster@1 | 1075   ); | 
| webmaster@1 | 1076 | 
| webmaster@1 | 1077   $form['submit'] = array( | 
| webmaster@1 | 1078     '#type' => 'submit', | 
| webmaster@1 | 1079     '#value' => st('Save and continue'), | 
| webmaster@1 | 1080     '#weight' => 15, | 
| webmaster@1 | 1081   ); | 
| webmaster@1 | 1082   $form['#action'] = $url; | 
| webmaster@1 | 1083   $form['#redirect'] = FALSE; | 
| webmaster@1 | 1084 | 
| webmaster@1 | 1085   // Allow the profile to alter this form. $form_state isn't available | 
| webmaster@1 | 1086   // here, but to conform to the hook_form_alter() signature, we pass | 
| webmaster@1 | 1087   // an empty array. | 
| webmaster@1 | 1088   $hook_form_alter = $_GET['profile'] .'_form_alter'; | 
| webmaster@1 | 1089   if (function_exists($hook_form_alter)) { | 
| webmaster@1 | 1090     $hook_form_alter($form, array(), 'install_configure'); | 
| webmaster@1 | 1091   } | 
| webmaster@1 | 1092   return $form; | 
| webmaster@1 | 1093 } | 
| webmaster@1 | 1094 | 
| webmaster@1 | 1095 /** | 
| webmaster@1 | 1096  * Form API validate for the site configuration form. | 
| webmaster@1 | 1097  */ | 
| webmaster@1 | 1098 function install_configure_form_validate($form, &$form_state) { | 
| webmaster@1 | 1099   if ($error = user_validate_name($form_state['values']['account']['name'])) { | 
| webmaster@1 | 1100     form_error($form['admin_account']['account']['name'], $error); | 
| webmaster@1 | 1101   } | 
| webmaster@1 | 1102   if ($error = user_validate_mail($form_state['values']['account']['mail'])) { | 
| webmaster@1 | 1103     form_error($form['admin_account']['account']['mail'], $error); | 
| webmaster@1 | 1104   } | 
| webmaster@1 | 1105   if ($error = user_validate_mail($form_state['values']['site_mail'])) { | 
| webmaster@1 | 1106     form_error($form['site_information']['site_mail'], $error); | 
| webmaster@1 | 1107   } | 
| webmaster@1 | 1108 } | 
| webmaster@1 | 1109 | 
| webmaster@1 | 1110 /** | 
| webmaster@1 | 1111  * Form API submit for the site configuration form. | 
| webmaster@1 | 1112  */ | 
| webmaster@1 | 1113 function install_configure_form_submit($form, &$form_state) { | 
| webmaster@1 | 1114   global $user; | 
| webmaster@1 | 1115 | 
| webmaster@1 | 1116   variable_set('site_name', $form_state['values']['site_name']); | 
| webmaster@1 | 1117   variable_set('site_mail', $form_state['values']['site_mail']); | 
| webmaster@1 | 1118   variable_set('date_default_timezone', $form_state['values']['date_default_timezone']); | 
| webmaster@1 | 1119 | 
| webmaster@1 | 1120   // Enable update.module if this option was selected. | 
| webmaster@1 | 1121   if ($form_state['values']['update_status_module'][1]) { | 
| webmaster@1 | 1122     drupal_install_modules(array('update')); | 
| webmaster@1 | 1123   } | 
| webmaster@1 | 1124 | 
| webmaster@1 | 1125   // Turn this off temporarily so that we can pass a password through. | 
| webmaster@1 | 1126   variable_set('user_email_verification', FALSE); | 
| webmaster@1 | 1127   $form_state['old_values'] = $form_state['values']; | 
| webmaster@1 | 1128   $form_state['values'] = $form_state['values']['account']; | 
| webmaster@1 | 1129 | 
| webmaster@1 | 1130   // We precreated user 1 with placeholder values. Let's save the real values. | 
| webmaster@1 | 1131   $account = user_load(1); | 
| webmaster@1 | 1132   $merge_data = array('init' => $form_state['values']['mail'], 'roles' => array(), 'status' => 1); | 
| webmaster@1 | 1133   user_save($account, array_merge($form_state['values'], $merge_data)); | 
| webmaster@1 | 1134   // Log in the first user. | 
| webmaster@1 | 1135   user_authenticate($form_state['values']); | 
| webmaster@1 | 1136   $form_state['values'] = $form_state['old_values']; | 
| webmaster@1 | 1137   unset($form_state['old_values']); | 
| webmaster@1 | 1138   variable_set('user_email_verification', TRUE); | 
| webmaster@1 | 1139 | 
| webmaster@1 | 1140   if (isset($form_state['values']['clean_url'])) { | 
| webmaster@1 | 1141     variable_set('clean_url', $form_state['values']['clean_url']); | 
| webmaster@1 | 1142   } | 
| webmaster@1 | 1143   // The user is now logged in, but has no session ID yet, which | 
| webmaster@1 | 1144   // would be required later in the request, so remember it. | 
| webmaster@1 | 1145   $user->sid = session_id(); | 
| webmaster@1 | 1146 | 
| webmaster@1 | 1147   // Record when this install ran. | 
| webmaster@1 | 1148   variable_set('install_time', time()); | 
| webmaster@1 | 1149 } | 
| webmaster@1 | 1150 | 
| webmaster@1 | 1151 // Start the installer. | 
| webmaster@1 | 1152 install_main(); |