maillog.install 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * @file
  4. * Provides the installation routines for the maillog module
  5. */
  6. /**
  7. * Implements hook_install().
  8. */
  9. function maillog_install() {
  10. $config = \Drupal::configFactory()->getEditable('system.mail');
  11. $config->set('interface.default', 'maillog');
  12. $config->save();
  13. }
  14. /**
  15. * Implements hook_uninstall().
  16. */
  17. function maillog_uninstall() {
  18. $config = \Drupal::configFactory()->getEditable('system.mail');
  19. // Restore the mail configuration to php_mail if it currently uses maillog.
  20. if ($config->get('interface.default') == 'maillog') {
  21. $config->set('interface.default', 'php_mail');
  22. $config->save();
  23. }
  24. }
  25. /**
  26. * Implements hook_schema().
  27. */
  28. function maillog_schema() {
  29. $schema['maillog'] = array(
  30. 'description' => "Stores outgoing e-mail details for nodes of type 'maillog'.",
  31. 'fields' => array(
  32. 'idmaillog' => array(
  33. 'type' => 'serial',
  34. 'unsigned' => TRUE,
  35. 'not null' => TRUE,
  36. 'description' => "The mail_log {node}.nid",
  37. ),
  38. 'header_message_id' => array(
  39. 'type' => 'varchar',
  40. 'length' => 255,
  41. 'default' => '',
  42. 'description' => "The 'message-id' field of the e-mail.",
  43. ),
  44. 'header_from' => array(
  45. 'type' => 'text',
  46. 'not null' => TRUE,
  47. 'description' => "The 'From' field of the e-mail.",
  48. ),
  49. 'header_to' => array(
  50. 'type' => 'text',
  51. 'not null' => TRUE,
  52. 'description' => "The 'To' field of the e-mail.",
  53. ),
  54. 'header_reply_to' => array(
  55. 'type' => 'text',
  56. 'not null' => TRUE,
  57. 'description' => "The 'Reply-To' field of the e-mail.",
  58. ),
  59. 'header_all' => array(
  60. 'type' => 'text',
  61. 'not null' => TRUE,
  62. 'description' => "The 'Header' field of the e-mail.",
  63. ),
  64. 'subject' => array(
  65. 'description' => "The 'Subject' fieldof the e-mail.",
  66. 'type' => 'varchar',
  67. 'length' => 255,
  68. 'not null' => TRUE,
  69. 'default' => '',
  70. ),
  71. 'body' => array(
  72. 'description' => 'The body of this version.',
  73. 'type' => 'text',
  74. 'not null' => TRUE,
  75. 'size' => 'big',
  76. ),
  77. 'sent_date' => array(
  78. 'description' => 'The Unix timestamp when the mail was sent.',
  79. 'type' => 'int',
  80. 'not null' => TRUE,
  81. 'default' => 0,
  82. ),
  83. ),
  84. 'primary key' => array('idmaillog'),
  85. );
  86. return $schema;
  87. }