filters.statusnotify.inc

  1. cis7 sites/all/modules/ulmus/backup_migrate/includes/filters.statusnotify.inc
  2. cle7 sites/all/modules/ulmus/backup_migrate/includes/filters.statusnotify.inc
  3. ecd7 sites/all/modules/ulmus/backup_migrate/includes/filters.statusnotify.inc
  4. elmsmedia7 sites/all/modules/ulmus/backup_migrate/includes/filters.statusnotify.inc
  5. harmony7 sites/all/modules/ulmus/backup_migrate/includes/filters.statusnotify.inc
  6. icor7 sites/all/modules/ulmus/backup_migrate/includes/filters.statusnotify.inc
  7. meedjum_blog7 sites/all/modules/ulmus/backup_migrate/includes/filters.statusnotify.inc
  8. mooc7 sites/all/modules/ulmus/backup_migrate/includes/filters.statusnotify.inc

A filter for compressing bckups with zip, gz bzip etc.

Classes

Namesort descending Description
backup_migrate_filter_statusnotify A filter to send a notification email on success or failure of backup.

File

sites/all/modules/ulmus/backup_migrate/includes/filters.statusnotify.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * A filter for compressing bckups with zip, gz bzip etc.
  5. */
  6. /**
  7. * A filter to send a notification email on success or failure of backup.
  8. *
  9. * @ingroup backup_migrate_filters
  10. */
  11. class backup_migrate_filter_statusnotify extends backup_migrate_filter {
  12. /**
  13. * Get the default backup settings for this filter.
  14. */
  15. function backup_settings_default() {
  16. return array(
  17. 'notify_success_enable' => FALSE,
  18. 'notify_failure_enable' => FALSE,
  19. 'notify_success_email' => variable_get('site_mail', ''),
  20. 'notify_failure_email' => variable_get('site_mail', ''),
  21. );
  22. }
  23. /**
  24. * Get the form for the settings for this filter.
  25. */
  26. function backup_settings_form($settings) {
  27. $form = array();
  28. $form['advanced']['notify_success_enable'] = array(
  29. "#type" => 'checkbox',
  30. "#title" => t("Send an email if backup succeeds"),
  31. "#default_value" => @$settings['notify_success_enable'],
  32. );
  33. $form['advanced']['notify_success_email'] = array(
  34. "#type" => "textfield",
  35. "#title" => t("Email Address for Success Notices"),
  36. "#default_value" => @$settings['notify_success_email'],
  37. );
  38. $form['advanced']['notify_failure_enable'] = array(
  39. "#type" => 'checkbox',
  40. "#title" => t("Send an email if backup fails"),
  41. "#default_value" => @$settings['notify_failure_enable'],
  42. );
  43. $form['advanced']['notify_failure_email'] = array(
  44. "#type" => "textfield",
  45. "#title" => t("Email Address for Failure Notices"),
  46. "#default_value" => @$settings['notify_failure_email'],
  47. );
  48. return $form;
  49. }
  50. /**
  51. * Send the success email.
  52. */
  53. function backup_succeed($settings) {
  54. if (@$settings->filters['notify_success_enable'] && $to = @$settings->filters['notify_success_email']) {
  55. $params = array(
  56. 'messages' => $this->get_messages(),
  57. );
  58. // Using the default language since this is not specific to a user.
  59. $language = language_default();
  60. drupal_mail('backup_migrate', 'backup_succeed', $settings->filters['notify_success_email'], $language, $params);
  61. }
  62. }
  63. /**
  64. * Send the failure email.
  65. */
  66. function backup_fail($settings) {
  67. if (@$settings->filters['notify_failure_enable'] && $to = @$settings->filters['notify_failure_email']) {
  68. $params = array(
  69. 'messages' => $this->get_messages(),
  70. );
  71. // Using the default language since this is not specific to a user.
  72. $language = language_default();
  73. drupal_mail('backup_migrate', 'backup_fail', $settings->filters['notify_failure_email'], $language, $params);
  74. }
  75. }
  76. /**
  77. * Render the messages and errors for the email.
  78. */
  79. function get_messages() {
  80. $out = "";
  81. $messages = _backup_migrate_messages();
  82. foreach ($messages as $message) {
  83. $out .= strip_tags(t($message['message'], $message['replace'])) . "\n";
  84. }
  85. return $out;
  86. }
  87. }