simplenews.api.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the Simplenews module.
  5. */
  6. /**
  7. * @mainpage Simplenews API documentation.
  8. *
  9. * Simplenews builds on the following basic concepts.
  10. *
  11. * @link subscriber Subscribers @endlink subscribe to @link newsletter
  12. * newsletters (categories) @endlink. That connection is called
  13. * a @link subscription subscription @endlink. Nodes of enabled content types
  14. * are @link issue newsletter issues @endlink. These are then sent to the
  15. * subscribers of the newsletter the issue is attached to.
  16. *
  17. * Sending is done by first adding a row for each subscriber to the @link spool
  18. * mail spool @endlink.
  19. * Then they are processed either immediatly or during cron runs. The actual
  20. * sending happens through a @link source source instance @endlink, which is
  21. * first instanciated based on the mail spool and then used to generated the
  22. * actual mail content.
  23. *
  24. */
  25. /**
  26. * @defgroup subscriber Subscriber
  27. *
  28. * @todo
  29. */
  30. /**
  31. * @defgroup newsletter Newsletter (category)
  32. *
  33. * @todo
  34. */
  35. /**
  36. * @defgroup subscription Subscription
  37. *
  38. * @todo
  39. */
  40. /**
  41. * @defgroup issue Newsletter issue
  42. *
  43. * @todo
  44. */
  45. /**
  46. * @defgroup spool Mail spool
  47. *
  48. * @todo
  49. */
  50. /**
  51. * @defgroup source Source
  52. *
  53. * @todo
  54. */
  55. /**
  56. * Return operations to be applied to newsletter issues.
  57. *
  58. * @ingroup issue
  59. */
  60. function hook_simplenews_issue_operations() {
  61. $operations = array(
  62. 'activate' => array(
  63. 'label' => t('Send'),
  64. 'callback' => 'simplenews_issue_send',
  65. ),
  66. );
  67. return $operations;
  68. }
  69. /**
  70. * Return operations to be applied to subscriptions.
  71. *
  72. * @ingroup issue
  73. */
  74. function hook_simplenews_subscription_operations() {
  75. $operations = array(
  76. 'activate' => array(
  77. 'label' => t('Activate'),
  78. 'callback' => 'simplenews_subscription_activate',
  79. 'callback arguments' => array(SIMPLENEWS_SUBSCRIPTION_ACTIVE),
  80. ),
  81. 'inactivate' => array(
  82. 'label' => t('Inactivate'),
  83. 'callback' => 'simplenews_subscription_activate',
  84. 'callback arguments' => array(SIMPLENEWS_SUBSCRIPTION_INACTIVE),
  85. ),
  86. 'delete' => array(
  87. 'label' => t('Delete'),
  88. 'callback' => 'simplenews_subscription_delete_multiple',
  89. ),
  90. );
  91. return $operations;
  92. }
  93. /**
  94. * Act after a newsletter category has been saved.
  95. *
  96. * @ingroup newsletter
  97. */
  98. function hook_simplenews_category_update($category) {
  99. }
  100. /**
  101. * Act after a newsletter category has been deleted.
  102. *
  103. * @ingroup newsletter
  104. */
  105. function hook_simplenews_category_delete($category) {
  106. }
  107. /**
  108. * Act after a subscriber is updated.
  109. *
  110. * @ingroup subscriber
  111. */
  112. function hook_simplenews_subscriber_update($subscriber) {
  113. }
  114. /**
  115. * Act after a new subscriber has been created.
  116. *
  117. * @ingroup subscriber
  118. */
  119. function hook_simplenews_subscriber_insert($subscriber) {
  120. }
  121. /**
  122. * Act after a subscriber has been deleted.
  123. *
  124. * @ingroup subscriber
  125. */
  126. function hook_simplenews_subscriber_delete($subscriber) {
  127. }
  128. /**
  129. * Invoked if a user is subscribed to a newsletter.
  130. *
  131. * @param $subscriber
  132. * The subscriber object including all subscriptions of this user.
  133. *
  134. * @param $subscription
  135. * The subscription object for this specific subscribe action.
  136. *
  137. * @ingroup subscriber
  138. */
  139. function hook_simplenews_subscribe_user($subscriber, $subscription) {
  140. }
  141. /**
  142. * Invoked if a user is unsubscribed from a newsletter.
  143. *
  144. * @param $subscriber
  145. * The subscriber object including all subscriptions of this user.
  146. *
  147. * @param $subscription
  148. * The subscription object for this specific unsubscribe action.
  149. *
  150. * @ingroup subscriber
  151. */
  152. function hook_simplenews_unsubscribe_user($subscriber, $subscription) {
  153. }
  154. /**
  155. * Expose SimplenewsSource cache implementations.
  156. *
  157. * @return
  158. * An array keyed by the name of the class that provides the implementation,
  159. * the array value consists of another array with the keys label and
  160. * description.
  161. *
  162. * @ingroup source
  163. */
  164. function hook_simplenews_source_cache_info() {
  165. return array(
  166. 'SimplenewsSourceCacheNone' => array(
  167. 'label' => t('No caching'),
  168. 'description' => t('This allows to theme each newsletter separately.'),
  169. ),
  170. 'SimplenewsSourceCacheBuild' => array(
  171. 'label' => t('Cached content source'),
  172. 'description' => t('This caches the rendered content to be sent for multiple recipients. It is not possible to use subscriber specific theming but tokens can be used for personalization.'),
  173. ),
  174. );
  175. }