diff --git a/civicrm_newsletter.cmrf.inc b/civicrm_newsletter.cmrf.inc index aca7dbc..53d94d3 100644 --- a/civicrm_newsletter.cmrf.inc +++ b/civicrm_newsletter.cmrf.inc @@ -70,14 +70,14 @@ function _civicrm_newsletter_send_call($entity, $action, $parameters = array(), * The Advanced Newsletter Management profile configuration, or NULL if the * profile could not be retrieved. */ -function _civicrm_newsletter_profile_get($profile_name = NULL) { +function _civicrm_newsletter_profile_getsingle($profile_name = NULL) { $params = array(); if ($profile_name) { $params['name'] = $profile_name; } $call = _civicrm_newsletter_send_call( 'NewsletterProfile', - 'get', + 'getsingle', $params, array(), _civicrm_newsletter_get_cmrf_profile() @@ -96,6 +96,33 @@ function _civicrm_newsletter_profile_get($profile_name = NULL) { return $return; } +/** + * Retrieves the configuration for all Advanced Newsletter Management profiles + * from CiviCRM. + * + * @return array + * An array of Advanced Newsletter Management profile configurations. + */ +function _civicrm_newsletter_profile_get() { + $params = array(); + $call = _civicrm_newsletter_send_call( + 'NewsletterProfile', + 'get', + $params, + array(), + _civicrm_newsletter_get_cmrf_profile() + ); + $reply = $call->getReply(); + if ($reply['is_error'] == 1) { + $return = NULL; + } + else { + $return = $reply['values']; + } + + return $return; +} + /** * Retrieves the subscription status for a given contact hash. * diff --git a/civicrm_newsletter.module b/civicrm_newsletter.module index 0936994..e98cd69 100644 --- a/civicrm_newsletter.module +++ b/civicrm_newsletter.module @@ -130,7 +130,7 @@ function _civicrm_newsletter_subscription_form($form, &$form_state, $profile_nam // Retrieve CiviCRM Advanced Newsletter Management extension configuration for // given profile. - if (!$profile = _civicrm_newsletter_profile_get($profile_name)) { + if (!$profile = _civicrm_newsletter_profile_getsingle($profile_name)) { drupal_not_found(); } else { @@ -242,7 +242,7 @@ function _civicrm_newsletter_preferences_form($form, &$form_state, $profile_name // Retrieve CiviCRM Advanced Newsletter Management extension configuration for // given profile. - if (!$profile = _civicrm_newsletter_profile_get($profile_name)) { + if (!$profile = _civicrm_newsletter_profile_getsingle($profile_name)) { drupal_not_found(); } else { @@ -412,7 +412,7 @@ function _civicrm_newsletter_request_form($form, &$form_state, $profile_name, $c // Retrieve CiviCRM Advanced Newsletter Management extension configuration for // given profile. - if (!$profile = _civicrm_newsletter_profile_get($profile_name)) { + if (!$profile = _civicrm_newsletter_profile_getsingle($profile_name)) { drupal_not_found(); } else {