mailgun.install 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the Mailgun module.
  5. */
  6. /**
  7. * Implements hook_uninstall().
  8. */
  9. function mailgun_uninstall() {
  10. // Delete variables.
  11. $variables = array(
  12. 'mailgun_api_key',
  13. 'mailgun_from_action',
  14. 'mailgun_from_name',
  15. 'mailgun_from_mail',
  16. 'mailgun_tracking',
  17. 'mailgun_tracking_clicks',
  18. 'mailgun_tracking_opens',
  19. 'mailgun_queue',
  20. 'mailgun_log',
  21. 'mailgun_format',
  22. 'mailgun_tagging_mailkey',
  23. );
  24. foreach ($variables as $variable) {
  25. variable_del($variable);
  26. }
  27. }
  28. /**
  29. * Implements hook_enable().
  30. */
  31. function mailgun_enable() {
  32. mailsystem_set(array('mailgun_test' => 'MailgunMailSystem'));
  33. }
  34. /**
  35. * Implements hook_disable().
  36. */
  37. function mailgun_disable() {
  38. // Tell Mail System to remove Mailgun and restore to defaults.
  39. mailsystem_clear(array('mailgun_test' => 'MailgunMailSystem'));
  40. watchdog('mailgun', 'Mailgun has been disabled.');
  41. }
  42. /**
  43. * Implements hook_requirements().
  44. */
  45. function mailgun_requirements($phase) {
  46. // Ensure translations don't break during installation.
  47. $t = get_t();
  48. $requirements = array();
  49. if ($phase === 'runtime') {
  50. $requirements['mailgun']['title'] = $t('Mailgun');
  51. if (mailgun_check_library()) {
  52. $requirements['mailgun']['value'] = $t('The Mailgun library is installed correctly.');
  53. $requirements['mailgun']['severity'] = REQUIREMENT_OK;
  54. }
  55. else {
  56. $requirements['mailgun']['value'] = $t('The Mailgun library has not been installed correctly.');
  57. $requirements['mailgun']['severity'] = REQUIREMENT_ERROR;
  58. }
  59. }
  60. return $requirements;
  61. }