/**
  * Adds a language
  * 
  * @param $langcode
  * @param $default
  *   Whether this is the default language
  * @param $load
  *   Whether to load available translations for that language
  */
 function addLanguage($langcode, $default = FALSE, $load = TRUE)
 {
     require_once './includes/locale.inc';
     // Enable installation language as default site language.
     locale_add_language($langcode, NULL, NULL, NULL, NULL, NULL, 1, $default);
     // Reset language list
     language_list('language', TRUE);
     // We may need to refresh default language
     drupal_init_language();
 }
Example #2
0
/**
 * The Drupal installation happens in a series of steps. We begin by verifying
 * that the current environment meets our minimum requirements. We then go
 * on to verify that settings.php is properly configured. From there we
 * connect to the configured database and verify that it meets our minimum
 * requirements. Finally we can allow the user to select an installation
 * profile and complete the installation process.
 *
 * @param $phase
 *   The installation phase we should proceed to.
 */
function install_main()
{
    require_once './includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
    // The user agent header is used to pass a database prefix in the request when
    // running tests. However, for security reasons, it is imperative that no
    // installation be permitted using such a prefix.
    if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], "simpletest") !== FALSE) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
        exit;
    }
    // This must go after drupal_bootstrap(), which unsets globals!
    global $profile, $install_locale, $conf;
    require_once './modules/system/system.install';
    require_once './includes/file.inc';
    // Ensure correct page headers are sent (e.g. caching)
    drupal_page_header();
    // Set up $language, so t() caller functions will still work.
    drupal_init_language();
    // Load module basics (needed for hook invokes).
    include_once './includes/module.inc';
    $module_list['system']['filename'] = 'modules/system/system.module';
    $module_list['filter']['filename'] = 'modules/filter/filter.module';
    module_list(TRUE, FALSE, FALSE, $module_list);
    drupal_load('module', 'system');
    drupal_load('module', 'filter');
    // Install profile chosen, set the global immediately.
    // This needs to be done before the theme cache gets
    // initialized in drupal_maintenance_theme().
    if (!empty($_GET['profile'])) {
        $profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']);
    }
    // Set up theme system for the maintenance page.
    drupal_maintenance_theme();
    // Check existing settings.php.
    $verify = install_verify_settings();
    if ($verify) {
        // Since we have a database connection, we use the normal cache system.
        // This is important, as the installer calls into the Drupal system for
        // the clean URL checks, so we should maintain the cache properly.
        require_once './includes/cache.inc';
        $conf['cache_inc'] = './includes/cache.inc';
        // Establish a connection to the database.
        require_once './includes/database.inc';
        db_set_active();
        // Check if Drupal is installed.
        $task = install_verify_drupal();
        if ($task == 'done') {
            install_already_done_error();
        }
    } else {
        // Since no persistent storage is available yet, and functions that check
        // for cached data will fail, we temporarily replace the normal cache
        // system with a stubbed-out version that short-circuits the actual
        // caching process and avoids any errors.
        require_once './includes/cache-install.inc';
        $conf['cache_inc'] = './includes/cache-install.inc';
        $task = NULL;
    }
    // No profile was passed in GET, ask the user.
    if (empty($_GET['profile'])) {
        if ($profile = install_select_profile()) {
            install_goto("install.php?profile={$profile}");
        } else {
            install_no_profile_error();
        }
    }
    // Load the profile.
    require_once "./profiles/{$profile}/{$profile}.profile";
    // Locale selection
    if (!empty($_GET['locale'])) {
        $install_locale = preg_replace('/[^a-zA-Z_0-9\\-]/', '', $_GET['locale']);
    } elseif (($install_locale = install_select_locale($profile)) !== FALSE) {
        install_goto("install.php?profile={$profile}&locale={$install_locale}");
    }
    // Tasks come after the database is set up
    if (!$task) {
        global $db_url;
        if (!$verify && !empty($db_url)) {
            // Do not install over a configured settings.php.
            install_already_done_error();
        }
        // Check the installation requirements for Drupal and this profile.
        install_check_requirements($profile, $verify);
        // Verify existence of all required modules.
        $modules = drupal_verify_profile($profile, $install_locale);
        // If any error messages are set now, it means a requirement problem.
        $messages = drupal_set_message();
        if (!empty($messages['error'])) {
            install_task_list('requirements');
            drupal_set_title(st('Requirements problem'));
            print theme('install_page', '');
            exit;
        }
        // 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);
        }
        // Install system.module.
        drupal_install_system();
        // Save the list of other modules to install for the 'profile-install'
        // task. variable_set() can be used now that system.module is installed
        // and drupal is bootstrapped.
        variable_set('install_profile_modules', array_diff($modules, array('system')));
    }
    // The database is set up, turn to further tasks.
    install_tasks($profile, $task);
}
Example #3
0
// to run updates (since it may expose sensitive information about the site's
// configuration).
$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
if (empty($op) && $update_access_allowed) {
    require_once DRUPAL_ROOT . '/includes/install.inc';
    require_once DRUPAL_ROOT . '/includes/file.inc';
    require_once DRUPAL_ROOT . '/modules/system/system.install';
    // Load module basics.
    include_once DRUPAL_ROOT . '/includes/module.inc';
    $module_list['system']['filename'] = 'modules/system/system.module';
    $module_list['filter']['filename'] = 'modules/filter/filter.module';
    module_list(TRUE, FALSE, $module_list);
    drupal_load('module', 'system');
    drupal_load('module', 'filter');
    // Set up $language, since the installer components require it.
    drupal_init_language();
    // Set up theme system for the maintenance page.
    drupal_maintenance_theme();
    // Check the update requirements for Drupal.
    update_check_requirements();
    // Redirect to the update information page if all requirements were met.
    install_goto('update.php?op=info');
}
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_maintenance_theme();
// Turn error reporting back on. From now on, only fatal errors (which are
// not passed through the error handler) will cause a message to be printed.
ini_set('display_errors', TRUE);
// Only proceed with updates if the user is allowed to run them.
if ($update_access_allowed) {
    include_once DRUPAL_ROOT . '/includes/install.inc';
 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $db_prefix, $user, $language;
     // In case a fatal error occured that was not in the test process read the
     // log to pick up any fatal errors.
     $db_prefix_temp = $db_prefix;
     $db_prefix = $this->originalPrefix;
     simpletest_log_read($this->testId, $db_prefix, get_class($this), TRUE);
     $db_prefix = $db_prefix_temp;
     $emailCount = count(variable_get('drupal_test_email_collector', array()));
     if ($emailCount) {
         $message = format_plural($emailCount, t('!count e-mail was sent during this test.'), t('!count e-mails were sent during this test.'), array('!count' => $emailCount));
         $this->pass($message, t('E-mail'));
     }
     if (preg_match('/simpletest\\d+/', $db_prefix)) {
         // Delete temporary files directory.
         //      file_unmanaged_delete_recursive(file_directory_path());
         simpletest_clean_temporary_directory(file_directory_path());
         // Remove all prefixed tables (all the tables in the schema).
         $schema = drupal_get_schema(NULL, TRUE);
         $ret = array();
         foreach ($schema as $name => $table) {
             db_drop_table($ret, $name);
         }
         // Return the database prefix to the original.
         $db_prefix = $this->originalPrefix;
         // Return the user to the original one.
         $user = $this->originalUser;
         //      drupal_save_session(TRUE);
         session_save_session(TRUE);
         // Bring back default language. (Drupal 6)
         if (module_exists('locale')) {
             drupal_init_language();
             locale(NULL, NULL, TRUE);
         }
         // Ensure that internal logged in variable and cURL options are reset.
         $this->loggedInUser = FALSE;
         $this->additionalCurlOptions = array();
         // Reload module list and implementations to ensure that test module hooks
         // aren't called after tests.
         module_list(TRUE);
         //      module_implements('', FALSE, TRUE);
         module_implements('', '', TRUE);
         // Reset the Field API.
         //      field_cache_clear();
         // Rebuild caches.
         $this->refreshVariables();
         //      // Reset language.
         //      $language = $this->originalLanguage;
         //      if ($this->originalLanguageDefault) {
         //        $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
         //      }
         // Close the CURL handler.
         $this->curlClose();
     }
 }
 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $db_prefix, $user;
     if (preg_match('/simpletest\\d+/', $db_prefix)) {
         // Delete temporary files directory and reset files directory path.
         //      file_unmanaged_delete_recursive(file_directory_path());
         simpletest_clean_temporary_directory(file_directory_path());
         variable_set('file_directory_path', $this->originalFileDirectory);
         // Remove all prefixed tables (all the tables in the schema).
         $schema = drupal_get_schema(NULL, TRUE);
         $ret = array();
         foreach ($schema as $name => $table) {
             db_drop_table($ret, $name);
         }
         // Return the database prefix to the original.
         $db_prefix = $this->originalPrefix;
         // Return the user to the original one.
         $user = $this->originalUser;
         //      drupal_save_session(TRUE);
         session_save_session(TRUE);
         // Bring back default language. (Drupal 6)
         if (module_exists('locale')) {
             drupal_init_language();
             locale(NULL, NULL, TRUE);
         }
         // Ensure that internal logged in variable and cURL options are reset.
         $this->loggedInUser = FALSE;
         $this->additionalCurlOptions = array();
         // Reload module list and implementations to ensure that test module hooks
         // aren't called after tests.
         module_list(TRUE);
         //      module_implements(MODULE_IMPLEMENTS_CLEAR_CACHE);
         module_implements('', '', TRUE);
         // Reset the Field API.
         //      field_cache_clear();
         // Rebuild caches.
         $this->refreshVariables();
         // Close the CURL handler.
         $this->curlClose();
     }
 }
Example #6
0
 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     parent::tearDown();
     // Reset language list
     language_list('language', TRUE);
     drupal_init_language();
     if (module_exists('locale')) {
         locale(NULL, NULL, TRUE);
     }
 }
Example #7
0
/**
 * The Drupal installation happens in a series of steps. We begin by verifying
 * that the current environment meets our minimum requirements. We then go
 * on to verify that settings.php is properly configured. From there we
 * connect to the configured database and verify that it meets our minimum
 * requirements. Finally we can allow the user to select an installation
 * profile and complete the installation process.
 *
 * @param $phase
 *   The installation phase we should proceed to.
 */
function install_main()
{
    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
    // The user agent header is used to pass a database prefix in the request when
    // running tests. However, for security reasons, it is imperative that no
    // installation be permitted using such a prefix.
    if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], "simpletest") !== FALSE) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
        exit;
    }
    // This must go after drupal_bootstrap(), which unsets globals!
    global $profile, $install_locale, $conf;
    require_once DRUPAL_ROOT . '/modules/system/system.install';
    require_once DRUPAL_ROOT . '/includes/file.inc';
    // Ensure correct page headers are sent (e.g. caching)
    drupal_page_header();
    // Set up $language, so t() caller functions will still work.
    drupal_init_language();
    // Load module basics (needed for hook invokes).
    include_once DRUPAL_ROOT . '/includes/module.inc';
    $module_list['system']['filename'] = 'modules/system/system.module';
    $module_list['filter']['filename'] = 'modules/filter/filter.module';
    module_list(TRUE, FALSE, FALSE, $module_list);
    drupal_load('module', 'system');
    drupal_load('module', 'filter');
    // Load the cache infrastructure using a "fake" cache implementation that
    // does not attempt to write to the database. We need this during the initial
    // part of the installer because the database is not available yet. We
    // continue to use it even when the database does become available, in order
    // to preserve consistency between interactive and command-line installations
    // (the latter complete in one page request and therefore are forced to
    // continue using the cache implementation they started with) and also
    // because any data put in the cache during the installer is inherently
    // suspect, due to the fact that Drupal is not fully set up yet.
    require_once DRUPAL_ROOT . '/includes/cache-install.inc';
    $conf['cache_inc'] = './includes/cache-install.inc';
    // Install profile chosen, set the global immediately.
    // This needs to be done before the theme cache gets
    // initialized in drupal_maintenance_theme().
    if (!empty($_GET['profile'])) {
        $profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']);
    }
    // Set up theme system for the maintenance page.
    drupal_maintenance_theme();
    // Check existing settings.php.
    $verify = install_verify_settings();
    if ($verify) {
        // Establish a connection to the database.
        require_once DRUPAL_ROOT . '/includes/database.inc';
        db_set_active();
        // Check if Drupal is installed.
        $task = install_verify_drupal();
        if ($task == 'done') {
            install_already_done_error();
        }
    } else {
        $task = NULL;
    }
    // No profile was passed in GET, ask the user.
    if (empty($_GET['profile'])) {
        if ($profile = install_select_profile()) {
            install_goto("install.php?profile={$profile}");
        } else {
            install_no_profile_error();
        }
    }
    // Load the profile.
    require_once DRUPAL_ROOT . "/profiles/{$profile}/{$profile}.profile";
    // Locale selection
    if (!empty($_GET['locale'])) {
        $install_locale = preg_replace('/[^a-zA-Z_0-9\\-]/', '', $_GET['locale']);
    } elseif (($install_locale = install_select_locale($profile)) !== FALSE) {
        install_goto("install.php?profile={$profile}&locale={$install_locale}");
    }
    // Tasks come after the database is set up
    if (!$task) {
        global $db_url;
        if (!$verify && !empty($db_url)) {
            // Do not install over a configured settings.php.
            install_already_done_error();
        }
        // Check the installation requirements for Drupal and this profile.
        install_check_requirements($profile, $verify);
        // Verify existence of all required modules.
        $modules = drupal_verify_profile($profile, $install_locale);
        // If any error messages are set now, it means a requirement problem.
        $messages = drupal_set_message();
        if (!empty($messages['error'])) {
            install_task_list('requirements');
            drupal_set_title(st('Requirements problem'));
            print theme('install_page', '');
            exit;
        }
        // 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);
        }
        // The default lock implementation uses a database table,
        // so we cannot use it for install, but we still need
        // the API functions available.
        require_once './includes/lock-install.inc';
        $conf['lock_inc'] = './includes/lock-install.inc';
        lock_init();
        // Install system.module.
        drupal_install_system();
        // Ensure that all of Drupal's standard directories have appropriate
        // .htaccess files. These directories will have already been created by
        // this point in the installer, since Drupal creates them during the
        // install_check_requirements() task. Note that we cannot create them any
        // earlier than this, since the code below relies on system.module in order
        // to work.
        file_create_htaccess(file_directory_path());
        file_create_htaccess(file_directory_temp());
        // Save the list of other modules to install for the 'profile-install'
        // task. variable_set() can be used now that system.module is installed
        // and drupal is bootstrapped.
        variable_set('install_profile_modules', array_diff($modules, array('system')));
    }
    // The database is set up, turn to further tasks.
    install_tasks($profile, $task);
}