Commit 35075a60 authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian

Merge changes from DRUPAL-5 with HEAD

parent b670e664
......@@ -78,7 +78,7 @@ function _provision_drupal_site_exists($url) {
function _provision_drupal_site_installed($url) {
if (_provision_drupal_site_exists($url)) {
if ($data = provision_load_site_data($url)) {
return isset($data['site_installed']) ? $data['site_installed'] : FALSE;
return isset($data['installed']) ? $data['installed'] : FALSE;
}
}
return FALSE;
......@@ -338,6 +338,7 @@ function _provision_drupal_install_schema($profile, $language = 'en', $client_em
}
if ($client_email) {
// create the admin account
$account = new stdClass();
$edit['name'] = 'admin';
$edit['pass'] = user_password();
......@@ -345,26 +346,51 @@ function _provision_drupal_install_schema($profile, $language = 'en', $client_em
$edit['status'] = 1;
$account = user_save($account, $edit);
// Mail one time login URL and instructions.
$from = variable_get('site_mail', ini_get('sendmail_from'));
$onetime = user_pass_reset_url($account);
// Mail one time login URL and instructions.
$variables = array(
'!username' => $account->name, '!site' => variable_get('site_name', 'Drupal'), '!login_url' => $onetime,
'!uri' => $base_url, '!uri_brief' => preg_replace('!^https?://!', '', $base_url), '!mailto' => $account->mail,
'!date' => format_date(time()), '!login_uri' => url('user', NULL, NULL, TRUE),
'!edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE));
$subject = _user_mail_text('pass_subject', $variables);
$body = _user_mail_text('pass_body', $variables);
$mail_success = drupal_mail('user-pass', $account->mail, $subject, $body, $from);
// allow the profile to override welcome email text
if (file_exists("./profiles/$profile/provision_welcome_mail.inc")) {
require_once "./profiles/$profile/provision_welcome_mail.inc";
$mailkey = 'welcome-mail-admin';
}
elseif (file_exists(dirname(__FILE__) . '/provision_welcome_mail.inc')) {
/** use the module provided welcome email
* We can not use drupal_get_path here,
* as we are connected to the provisioned site's database
*/
require_once dirname(__FILE__) . '/provision_welcome_mail.inc';
$mailkey = 'welcome-mail-admin';
}
else {
// last resort use the user-pass mail text
$mailkey = 'user-pass';
}
if ($mailkey == 'welcome-mail-admin') {
$subject = st($mail['subject'], $variables);
$body = st($mail['body'], $variables);
}
else {
$subject = _user_mail_text('pass_subject', $variables);
$body = _user_mail_text('pass_body', $variables);
}
$mail_success = drupal_mail($mailkey, $account->mail, $subject, $body, $from);
if ($mail_success) {
provision_log('message', t('Sent welcome mail to @client', array('@client' => $client_email)));
provision_log('message', t('Login url: !onetime', array('!onetime' => $onetime)));
}
else {
provision_log('notice', t('Could not send welcome mail to @client', array('@client' => $client_email)));
}
provision_log('message', t('Login url: !onetime', array('!onetime' => $onetime)));
}
variable_set('install_profile', $profile);
......
......@@ -352,3 +352,22 @@ function _provision_basic_unix_requirements() {
return $help;
}
function _provision_provision_setup_requirements() {
$docroot = PROVISION_DOCROOT_PATH;
$uri = PROVISION_BASE_URL;
$drush_path = rtrim(drupal_get_path('module', 'drush'), '/') . '/drush.php';
$username = PROVISION_SCRIPT_USER;
$setup_cmd = <<<EOF
[$username@hm2 ~]$ cd $docroot
[$username@hm2 ~]$ $drush_path provision setup
EOF;
$help['title'] = t('Generate your configuration file using the <code>Provision Setup</code> command');
$help['summary'][] = t('The provision setup command inspects your environment and creates an initial configuration file in <code>sites/default/provision.settings.php</code>.<br />This configuration file stores important settings such as paths, binary locations and database credentials.');
$help['summary'][] = t('<strong>If you are using this platform as the back end to an existing Hostmaster installation: </strong><br /> you need to run this command before adding the platform node to your hosting site, to allow the hosting site to communicate with this platform.');
$help['configuration'] = t('Ensure that you are logged into the shell as %script_user, and then execute the following commands :<pre>@setup_cmd</pre>',
array('%script_user' => $username, '@setup_cmd' => $setup_cmd));
return $help;
}
......@@ -176,6 +176,15 @@ function provision_menu($may_cache) {
'callback' => 'provision_help_requirements',
'type' => MENU_CALLBACK
);
$items[] = array(
'path' => 'provision',
'title' => t('Configure your platform'),
'description' => t('Configure your platform.'),
'callback' => 'provision_front',
'type' => MENU_CALLBACK,
'access' => TRUE,
);
$items[] = array(
'path' => 'provision/disabled',
'title' => t('Site disabled'),
......@@ -192,19 +201,39 @@ function provision_menu($may_cache) {
'type' => MENU_CALLBACK,
'access' => user_access('access content'),
);
$items[] = array(
'path' => 'provision/notfound',
'title' => t('Site not found.'),
'description' => t('The site you have requested is not available.'),
'callback' => 'provision_site_notfound',
'type' => MENU_CALLBACK,
'access' => user_access('access content'),
);
return $items;
}
function provision_front() {
if (variable_get('provision_setup', FALSE)) {
drupal_goto('provision/notfound');
}
return _provision_requirements("provision_setup");
}
function provision_disabled_site() {
drupal_set_breadcrumb(array());
return "<p>This site was disabled by the site administrators.</p>";
}
function provision_site_maintenance() {
drupal_set_breadcrumb(array());
return "<p>This site is being worked on presently. Check back later.</p>";
}
function provision_site_notfound() {
drupal_set_breadcrumb(array());
return "<p>The site you have requested does not exist.</p>";
}
/**
* @} End of "defgroup provisionui"
*/
......@@ -697,7 +726,9 @@ function _provision_setup() {
* Drush command wrapper for the setup of the platform
*/
function _provision_setup_cmd() {
_provision_setup();
if (_provision_setup()) {
variable_set('provision_setup', TRUE);
}
// @TODO use provision_output for this, but we need pretty print first.
$logs = provision_get_log();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment