From 64ebb28c0167d25d16395e0a30fc35fb8e45a406 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Fri, 8 Nov 2013 22:34:54 +0100 Subject: [PATCH] updated materio_user_rules : rules event on user validation+has subscribed works --- materio_user_rules.module | 24 +++++++++++++++++++++--- materio_user_rules.rules.inc | 26 ++++++-------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/materio_user_rules.module b/materio_user_rules.module index a8eb5df6..7a02388d 100644 --- a/materio_user_rules.module +++ b/materio_user_rules.module @@ -7,8 +7,26 @@ */ function materio_user_rules_user_update(&$edit, $account) { if (!empty($account->logintoboggan_email_validated)) { - $subscritpions = ; - rules_invoke_event('materio_logintoboggan_validated', $account, $subscritpions); + + if($subscriber = simplenews_subscriber_load_by_mail($account->mail)){ + + foreach($subscriber->newsletter_subscription as $tid => $subscription){ + $term = taxonomy_term_load($tid); + $subscriptions_text_array[] = $term->name; + $subscriptions_tids[] = $tid; + } + + $subscriptions_text = implode(' ,', $subscriptions_text_array); + + $args = array( + 'account' => $account, + 'subscriptions_list' => $subscriptions_tids, + 'subscriptions_text' => $subscriptions_text, + ); + + rules_invoke_event_by_args('materio_logintoboggan_validated', $args); + + } } } @@ -21,6 +39,6 @@ function materio_user_rules_simplenews_subscribe_user($subscriber, $subscription 'mail' => $subscriber->mail, 'tid' => $subscription->tid, ); - rules_invoke_event_by_args('simplenews_rules_event_subscribe', $args); + // rules_invoke_event_by_args('simplenews_rules_event_subscribe', $args); } } \ No newline at end of file diff --git a/materio_user_rules.rules.inc b/materio_user_rules.rules.inc index 807b36ec..9efd7b3c 100644 --- a/materio_user_rules.rules.inc +++ b/materio_user_rules.rules.inc @@ -10,34 +10,20 @@ function materio_user_rules_rules_event_info() { return array( 'materio_logintoboggan_validated' => array( - 'label' => t("When the user account is validated."), + 'label' => t("a user is validated and subcribed to newsletter on registration."), 'group' => 'Materio', 'variables' => array( 'account' => array( 'type' => 'user', 'label' => t("The validated user's account"), ), - 'simplenews' => array( - 'type' => 'simplenews', - 'label' => t("The Simplenews info from the account validated"), + 'subscriptions_list' => array( + 'type' => 'list', + 'label' => t("The Simplenews info from the account validated as a list of tid for looping"), ), - ), - 'group' => t('User'), - ), - 'materio_simplenews_rules_event_subscribe' => array( - 'label' => t('A user has been subscribed and verified'), - 'group' => t('Simplenews'), - 'variables' => array( - 'mail' => array( + 'subscriptions_text' => array( 'type' => 'text', - 'label' => t('E-Mail'), - 'description' => t('The e-mail address that has been subscribed.'), - ), - 'tid' => array( - 'type' => 'integer', - 'label' => t('Simplenews category'), - 'descrption' => t('The newsletter category of the subscription.'), - 'options list' => 'simplenews_category_list', + 'label' => t("The Simplenews info from the account validated as a single text"), ), ), ),