function db_maintenance_email in DB Maintenance 5.2
Same name and namespace in other branches
- 6.2 db_maintenance.module \db_maintenance_email()
1 call to db_maintenance_email()
- db_maintenance_cron in ./
db_maintenance.module - Implementation of hook_cron().
File
- ./
db_maintenance.module, line 365 - Optimizes database tables during cron runs.
Code
function db_maintenance_email($email) {
global $base_url;
$email_list = variable_get('db_maintenance_email_notify', '');
if (!empty($email) && !empty($email_list)) {
$message = array();
$backupdir = variable_get('db_maintenance_backup_directory', '/tmp');
foreach ($email as $task => $status) {
switch ($task) {
case 'db_backup':
// db_backup returns filename
if (is_file($status)) {
$message[] = t('Database backed up. mysqldump is available at \'!STATUS\' when connected to \'!URL\'', array(
'!STATUS' => $status,
'!URL' => $base_url,
));
}
else {
$message[] = t('Database backup failed. Please review watchdog for important messages');
}
break;
case 'files_backup':
if (is_file($status)) {
$message[] = t('Site files backed up. Files tarball are available at \'!STATUS\' when connected to \'!URL\'', array(
'!STATUS' => $status,
'!URL' => $base_url,
));
}
else {
$message[] = t('Files directory backup failed. Please review watchdog for important messages');
}
break;
case 'db_maintenance':
$badstatus = db_maintenance_return_non_okay($status);
if (empty($badstatus)) {
$message[] = t('DB maintenance tasks ran successfully.');
}
else {
$message[] = t('DB maintenance tasks encountered at least one issue. These may have been automatically been recovered from, but at least one table was in a non-okay state. Please review the messages below, watchdog, and manually review the database table status to ensure the system is working properly.');
$message[] = db_maintenance_format_status($badstatus);
}
break;
}
}
$body = implode("\n", $message);
$subject = t('[drupal db_maintenance] site: !URL', array(
'!URL' => $base_url,
));
drupal_mail('db_maintenance', $email_list, $subject, $body);
}
}