Newer
Older
Adrian Rossouw
committed
<?php
// $Id$
/**
* @file Install file for provision module
*/
Adrian Rossouw
committed
/**
* Configure the module weights for the core modules, to ensure that the
* hooks always fire in a predictable pattern.
*
* Provision module - does necessary setup for an task to occur.
* Mysql module - creates the necessary database settings
* Drupal module - manages installations and the like.
* Apache module - ensures that web server can see the site
*/
function provision_install() {
db_query("UPDATE {system} SET weight = 0 WHERE type='module' AND name='provision'");
db_query("UPDATE {system} SET weight = 1 WHERE type='module' AND name='provision_mysql'");
db_query("UPDATE {system} SET weight = 2 WHERE type='module' AND name='provision_drupal'");
db_query("UPDATE {system} SET weight = 3 WHERE type='module' AND name='provision_apache'");
}
Adrian Rossouw
committed
/**
Adrian Rossouw
committed
* Implementation of hook_requirements
*
Adrian Rossouw
committed
* Make sure that the POSIX library is available, and that we are not running on a windows based host.
Adrian Rossouw
committed
* Make sure that site is not installed in a subdirectory, but that the DocumentRoot directive points at the installation.
* Make sure the site is not being installed in sites/default
* @TODO: make sure the required modules are installed in the right places
Adrian Rossouw
committed
*/
function provision_requirements($phase) {
Adrian Rossouw
committed
global $base_path;
Adrian Rossouw
committed
$t = get_t();
$has_posix = function_exists('posix_uname');
$requirements['posix']['title'] = $t('POSIX library');
$requirements['posix']['value'] = ($has_posix) ? $t('Enabled') : $t('Not found');
if (!$has_posix) {
$requirements['posix']['description'] = $t('<p>The <a href="@helpurl">POSIX library</a> has not been compiled into PHP.</p>', array("@helpurl" => 'http://www.php.net/manual/en/book.posix.php')) .
$t("<p><strong>This library is not available on Windows based hosts</strong>, and you will not be able to install this system.</p>");
$requirements['posix']['severity'] = REQUIREMENT_ERROR;
}
Adrian Rossouw
committed
$is_in_docroot = $base_path == '/';
$docroot = $_SERVER['DOCUMENT_ROOT'];
$requirements['docroot']['title'] = $t("Document root");
$requirements['docroot']['value'] = ($is_in_docroot) ? $t('Correct') :
$t("Installed in the @subdir sub directory of @root", array('@root' => rtrim($docroot, '/'), '@subdir' => trim($base_path, '/')));
Adrian Rossouw
committed
if (!$is_in_docroot) {
$requirements['docroot']['value'] = $t("Drupal has been installed in a subdirectory.
You will need to modify your virtual host configuration to point a ServerName directly at the installation path.");
$requirements['docroot']['severity'] = REQUIREMENT_ERROR;
}
Adrian Rossouw
committed
$url = parse_url($GLOBALS['base_url']);
$conf_path = (conf_path() == 'sites/default');
Adrian Rossouw
committed
$requirements['confpath']['title'] = $t('Configuration path');
$requirements['confpath']['value'] = conf_path();
if (!$conf_path) {
$requirements['confpath']['description'] = $t('Provision may only be installed as the default site in a Drupal installation. It is currently installed in the "sites/@url" directory. Please move this directory to "sites/default".', array('@url' => $url['host']));
Adrian Rossouw
committed
$requirements['confpath']['severity'] = REQUIREMENT_ERROR;
}
Adrian Rossouw
committed
return $requirements;
}