smtp.install 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /**
  3. * @file
  4. * The installation instructions for the SMTP Authentication Support.
  5. */
  6. /**
  7. * Implements hook_requirements().
  8. */
  9. function smtp_requirements($phase) {
  10. $requirements = array();
  11. if ($phase == 'runtime') {
  12. if (variable_get('smtp_queue', FALSE) || variable_get('smtp_queue_fail', FALSE)) {
  13. $count = db_query("SELECT count('name') FROM {queue} WHERE name='smtp_send_queue'")->fetchField();
  14. $requirements['smtp_queue'] = array(
  15. 'title' => t('SMTP Queue'),
  16. 'value' => '',
  17. 'severity' => REQUIREMENT_INFO,
  18. );
  19. if ($count > 0) {
  20. $requirements['smtp_queue']['value'] = format_plural($count, 'There is 1 message queued for delivery.', 'There are @count messages queued for delivery.', array('@count' => $count))
  21. . ' '
  22. . t('Delivery of the message(s) will be attempted the next time cron runs.');
  23. }
  24. else {
  25. $requirements['smtp_queue']['value'] = t('There are no messages queued for delivery.');
  26. }
  27. }
  28. }
  29. return $requirements;
  30. }
  31. /**
  32. * Implements hook_install().
  33. */
  34. function smtp_install() {
  35. variable_set('smtp_on', 0);
  36. }
  37. /**
  38. * Implements hook_uninstall().
  39. */
  40. function smtp_uninstall() {
  41. variable_del('smtp_allowhtml');
  42. variable_del('smtp_from');
  43. variable_del('smtp_fromname');
  44. variable_del('smtp_host');
  45. variable_del('smtp_hostbackup');
  46. variable_del('smtp_on');
  47. variable_del('smtp_password');
  48. variable_del('smtp_port');
  49. variable_del('smtp_protocol');
  50. variable_del('smtp_queue');
  51. variable_del('smtp_queue_fail');
  52. variable_del('smtp_username');
  53. variable_del('smtp_debugging');
  54. variable_del('smtp_client_hostname');
  55. variable_del('smtp_client_helo');
  56. variable_del('smtp_deliver');
  57. variable_del('smtp_reroute_address');
  58. }
  59. /**
  60. * Implements hook_disable().
  61. */
  62. function smtp_disable() {
  63. $mail_modes = variable_get('mail_system');
  64. $mail_modes['default-system'] = 'DefaultMailSystem';
  65. variable_set('mail_system', $mail_modes);
  66. }
  67. /**
  68. * Implementations of hook_update_N().
  69. */
  70. /**
  71. * Upgrade to Drupal 7.x
  72. */
  73. function smtp_update_7000() {
  74. if (variable_get('smtp_on', 0) != 0) {
  75. variable_set('mail_system', array('default-system' => 'SmtpMailSystem'));
  76. }
  77. // Not used any more in D7.
  78. variable_del('smtp_library');
  79. }
  80. /**
  81. * Back to default mail system if the status flag is off.
  82. */
  83. function smtp_update_7100() {
  84. $mail_modes = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
  85. if ($mail_modes['default-system'] == 'SmtpMailSystem' && !variable_get('smtp_on', FALSE)) {
  86. $mail_modes['default-system'] = 'DefaultMailSystem';
  87. variable_set('mail_system', $mail_modes);
  88. }
  89. }
  90. /**
  91. * Updating variable value now that new SMTP logging behavior has been
  92. * implemented.
  93. */
  94. function smtp_update_7101() {
  95. $old_debugging_value = variable_get('smtp_debugging', 0);
  96. $logging = SMTP_LOGGING_NONE;
  97. if ($old_debugging_value == 1) {
  98. $logging = SMTP_LOGGING_ERRORS;
  99. }
  100. variable_set('smtp_debugging', $logging);
  101. }
  102. /**
  103. * Remove the unused 'smtp_library' variable.
  104. */
  105. function smtp_update_7102() {
  106. variable_del('smtp_library');
  107. }
  108. /**
  109. * Delete the variable "smtp_test_address". It is unlikely that this would
  110. * actually be set in the normal course of events, and it's no longer needed as
  111. * it was replaced with a form submit handler.
  112. */
  113. function smtp_update_7103() {
  114. variable_del('smtp_test_address');
  115. }