forked from a64f7bb4-7358-4778-9fbe-3b882c34cc1d/v1
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Module file for Simplenews rules integration.
|
|
*/
|
|
|
|
use Drupal\simplenews\Entity\Newsletter;
|
|
|
|
define('SIMPLENEWS_RULES_CONFIRMATION_DEFAULT', 0);
|
|
define('SIMPLENEWS_RULES_CONFIRMATION_YES', 1);
|
|
define('SIMPLENEWS_RULES_CONFIRMATION_NO', 2);
|
|
|
|
/**
|
|
* Returns the options for the confirmation paramter.
|
|
*/
|
|
function simplenews_rules_confirmation_list() {
|
|
return array(
|
|
SIMPLENEWS_RULES_CONFIRMATION_DEFAULT => t('Default'),
|
|
SIMPLENEWS_RULES_CONFIRMATION_YES => t('Yes'),
|
|
SIMPLENEWS_RULES_CONFIRMATION_NO => t('No'),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_simplenews_unsubscribe().
|
|
*/
|
|
function simplenews_rules_simplenews_unsubscribe($subscriber, $subscription) {
|
|
$args = array(
|
|
'mail' => $subscriber->mail,
|
|
'newsletter' => Newsletter::load($subscription->newsletter_id),
|
|
);
|
|
rules_invoke_event_by_args('simplenews_rules_event_unsubscribe', $args);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_simplenews_subscribe().
|
|
*/
|
|
function simplenews_rules_simplenews_subscribe($subscriber, $subscription) {
|
|
$args = array(
|
|
'mail' => $subscriber->mail,
|
|
'newsletter' => Newsletter::load($subscription->newsletter_id),
|
|
);
|
|
rules_invoke_event_by_args('simplenews_rules_event_subscribe', $args);
|
|
}
|