class backup_migrate_filter_statusnotify in Backup and Migrate 6.3
Same name and namespace in other branches
- 8.2 includes/filters.statusnotify.inc \backup_migrate_filter_statusnotify
- 8.3 includes/filters.statusnotify.inc \backup_migrate_filter_statusnotify
- 6.2 includes/filters.statusnotify.inc \backup_migrate_filter_statusnotify
- 7.3 includes/filters.statusnotify.inc \backup_migrate_filter_statusnotify
- 7.2 includes/filters.statusnotify.inc \backup_migrate_filter_statusnotify
A filter to send a notification email on success or failure of backup.
Hierarchy
- class \backup_migrate_filter
Expanded class hierarchy of backup_migrate_filter_statusnotify
1 string reference to 'backup_migrate_filter_statusnotify'
- backup_migrate_backup_migrate_filters in includes/
filters.inc - Implementation of hook_backup_migrate_filters().
File
- includes/
filters.statusnotify.inc, line 14 - A filter for compressing bckups with zip, gz bzip etc.
View source
class backup_migrate_filter_statusnotify extends backup_migrate_filter {
/**
* Get the default backup settings for this filter.
*/
function backup_settings_default() {
return array(
'notify_success_enable' => FALSE,
'notify_failure_enable' => FALSE,
'notify_success_email' => variable_get('site_mail', ''),
'notify_failure_email' => variable_get('site_mail', ''),
);
}
/**
* Get the form for the settings for this filter.
*/
function backup_settings_form($settings) {
$form = array();
$form['advanced']['notify_success_enable'] = array(
"#type" => 'checkbox',
"#title" => t("Send an email if backup succeeds"),
"#default_value" => @$settings['notify_success_enable'],
);
$form['advanced']['notify_success_email_wrapper'] = array(
'#type' => 'backup_migrate_dependent',
'#dependencies' => array(
'filters[notify_success_enable]' => TRUE,
),
);
$form['advanced']['notify_success_email_wrapper']['notify_success_email'] = array(
"#type" => "textfield",
"#title" => t("Email Address for Success Notices"),
"#default_value" => @$settings['notify_success_email'],
);
$form['advanced']['notify_failure_enable'] = array(
"#type" => 'checkbox',
"#title" => t("Send an email if backup fails"),
"#default_value" => @$settings['notify_failure_enable'],
);
$form['advanced']['notify_failure_email_wrapper'] = array(
'#type' => 'backup_migrate_dependent',
'#dependencies' => array(
'filters[notify_failure_enable]' => TRUE,
),
);
$form['advanced']['notify_failure_email_wrapper']['notify_failure_email'] = array(
"#type" => "textfield",
"#title" => t("Email Address for Failure Notices"),
"#default_value" => @$settings['notify_failure_email'],
);
return $form;
}
/**
* Send the success email.
*/
function backup_succeed($settings) {
if (@$settings->filters['notify_success_enable'] && ($to = @$settings->filters['notify_success_email'])) {
$messages = $this
->get_messages();
$subject = t('!site backup succeeded', array(
'!site' => variable_get('site_name', 'Drupal site'),
));
if ($messages = $this
->get_messages()) {
$body = t("The site backup has completed successfully with the following messages:\n!messages", array(
'!messages' => $messages,
));
}
else {
$body = t("The site backup has completed successfully.\n");
}
mail($settings->filters['notify_success_email'], $subject, $body);
}
}
/**
* Send the failure email.
*/
function backup_fail($settings) {
if (@$settings->filters['notify_failure_enable'] && ($to = @$settings->filters['notify_failure_email'])) {
$messages = $this
->get_messages();
$subject = t('!site backup failed', array(
'!site' => variable_get('site_name', 'Drupal site'),
));
if ($messages = $this
->get_messages()) {
$body = t("The site backup has failed with the following messages:\n!messages", array(
'!messages' => $messages,
));
}
else {
$body = t("The site backup has failed for an unknown reason.");
}
mail($settings->filters['notify_failure_email'], $subject, $body);
}
}
/**
* Render the messages and errors for the email.
*/
function get_messages() {
$out = "";
$messages = _backup_migrate_messages();
foreach ($messages as $message) {
$out .= strip_tags(t($message['message'], $message['replace'])) . "\n";
}
return $out;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
backup_migrate_filter:: |
property | 4 | ||
backup_migrate_filter:: |
property | |||
backup_migrate_filter:: |
function | This function is called on a backup file after the backup has been completed. | 3 | |
backup_migrate_filter:: |
function | Submit the settings form. Any values returned will be saved. | 1 | |
backup_migrate_filter:: |
function | Get the form for the settings for this filter. | 1 | |
backup_migrate_filter:: |
function | Declare any default destinations for this filter. | 1 | |
backup_migrate_filter:: |
function | Get a list of file types handled by this filter. | 3 | |
backup_migrate_filter:: |
function | This function is called immediately post backup. | 1 | |
backup_migrate_filter:: |
function | This function is called immediately post restore. | 1 | |
backup_migrate_filter:: |
function | This function is called immediately prior to backup. | 1 | |
backup_migrate_filter:: |
function | This function is called immediately prior to restore. | 1 | |
backup_migrate_filter:: |
function | This function is called on a backup file before importing it. | 3 | |
backup_migrate_filter:: |
function | Get the form for the settings for this filter. | 2 | |
backup_migrate_filter:: |
function | Get the form for the settings for this filter. | 2 | |
backup_migrate_filter:: |
function | Submit the settings form. Any values returned will be saved. | ||
backup_migrate_filter:: |
function | Get the form for the settings for this filter. | ||
backup_migrate_filter:: |
function | Get the weight of the filter for the given op. | ||
backup_migrate_filter_statusnotify:: |
function | Send the failure email. | ||
backup_migrate_filter_statusnotify:: |
function |
Get the default backup settings for this filter. Overrides backup_migrate_filter:: |
||
backup_migrate_filter_statusnotify:: |
function |
Get the form for the settings for this filter. Overrides backup_migrate_filter:: |
||
backup_migrate_filter_statusnotify:: |
function | Send the success email. | ||
backup_migrate_filter_statusnotify:: |
function | Render the messages and errors for the email. |