simplenews.api.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 has been spooled.
  95. *
  96. * @param $node
  97. * The node that has just been spooled.
  98. */
  99. function hook_simplenews_spooled($node) {
  100. }
  101. /**
  102. * Act after a newsletter category has been saved.
  103. *
  104. * @ingroup newsletter
  105. */
  106. function hook_simplenews_category_update($category) {
  107. }
  108. /**
  109. * Act after a newsletter category has been deleted.
  110. *
  111. * @ingroup newsletter
  112. */
  113. function hook_simplenews_category_delete($category) {
  114. }
  115. /**
  116. * Act after a subscriber is updated.
  117. *
  118. * @ingroup subscriber
  119. */
  120. function hook_simplenews_subscriber_update($subscriber) {
  121. }
  122. /**
  123. * Act after a new subscriber has been created.
  124. *
  125. * @ingroup subscriber
  126. */
  127. function hook_simplenews_subscriber_insert($subscriber) {
  128. }
  129. /**
  130. * Act after a subscriber has been deleted.
  131. *
  132. * @ingroup subscriber
  133. */
  134. function hook_simplenews_subscriber_delete($subscriber) {
  135. }
  136. /**
  137. * Invoked if a user is subscribed to a newsletter.
  138. *
  139. * @param $subscriber
  140. * The subscriber object including all subscriptions of this user.
  141. *
  142. * @param $subscription
  143. * The subscription object for this specific subscribe action.
  144. *
  145. * @ingroup subscriber
  146. */
  147. function hook_simplenews_subscribe_user($subscriber, $subscription) {
  148. }
  149. /**
  150. * Invoked if a user is unsubscribed from a newsletter.
  151. *
  152. * @param $subscriber
  153. * The subscriber object including all subscriptions of this user.
  154. *
  155. * @param $subscription
  156. * The subscription object for this specific unsubscribe action.
  157. *
  158. * @ingroup subscriber
  159. */
  160. function hook_simplenews_unsubscribe_user($subscriber, $subscription) {
  161. }
  162. /**
  163. * Expose SimplenewsSource cache implementations.
  164. *
  165. * @return
  166. * An array keyed by the name of the class that provides the implementation,
  167. * the array value consists of another array with the keys label and
  168. * description.
  169. *
  170. * @ingroup source
  171. */
  172. function hook_simplenews_source_cache_info() {
  173. return array(
  174. 'SimplenewsSourceCacheNone' => array(
  175. 'label' => t('No caching'),
  176. 'description' => t('This allows to theme each newsletter separately.'),
  177. ),
  178. 'SimplenewsSourceCacheBuild' => array(
  179. 'label' => t('Cached content source'),
  180. '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.'),
  181. ),
  182. );
  183. }