You are here

function party_get_all_emails in Party 8.2

Get all the emails on a Party

@todo: build in special case for user mail

Parameters

$party an party object:

Return value

An array of emails keyed by field reference

4 calls to party_get_all_emails()
party_simplenews_handler_field_primary_email::render in modules/party_simplenews/includes/views/party_simplenews_handler_field_primary_email.inc
party_simplenews_party_get_properties in modules/party_simplenews/party_simplenews.module
Get email related properties
party_subscription_settings_edit_form in modules/party_simplenews/party_subscription_settings.api.inc
Party subscription settings edit form
party_subscription_settings_edit_form_submit in modules/party_simplenews/party_subscription_settings.api.inc
Submit party subscription settings form

File

modules/party_simplenews/party_simplenews.module, line 462
Main module file for Party Simplenews integration

Code

function party_get_all_emails($party) {
  $fields = party_get_email_fields();
  $emails = array();
  foreach ($fields as $data_set_name => $fields) {
    $data_set_controller = party_get_data_set($party, $data_set_name);
    $data_set_def = party_get_data_set_info($data_set_name);
    $entity_ids = $data_set_controller
      ->getEntityIds();
    foreach ($data_set_controller
      ->getEntities() as $data_set_delta => $entity) {
      foreach ($fields as $field_name) {
        $items = field_get_items($data_set_def['entity type'], $entity, $field_name);
        if (!$items) {
          continue;
        }
        foreach ($items as $delta => $item) {
          $field_ref = $data_set_name . '__' . $entity_ids[$data_set_delta] . '__' . $field_name . '__' . $delta;
          $emails[$field_ref] = $item['email'];
        }
      }
    }
  }
  return $emails;
}