You are here

function redhen_contact_property_email_set in RedHen CRM 7

Entity metadata property setter for default email.

1 call to redhen_contact_property_email_set()
redhen_contact_user_registration_submit in modules/redhen_contact/redhen_contact.module
Registration form RedHen contact submit handler.
1 string reference to 'redhen_contact_property_email_set'
RedhenContactMetadataController::entityPropertyInfo in modules/redhen_contact/lib/redhen_contact.metadata.inc
Overrides entityPropertyInfo().

File

modules/redhen_contact/redhen_contact.module, line 1465
Module file for RedHen contacts.

Code

function redhen_contact_property_email_set(RedhenContact $contact, $name, $value) {
  $key = 0;

  // Reset the default flag for any existing emails.
  if (!empty($contact->{REDHEN_CONTACT_EMAIL_FIELD})) {
    foreach ($contact->{REDHEN_CONTACT_EMAIL_FIELD}[LANGUAGE_NONE] as $key => $email) {
      $contact->{REDHEN_CONTACT_EMAIL_FIELD}[LANGUAGE_NONE][$key]['default'] = 0;
    }
  }

  // Now set the new email as default.
  $contact->{REDHEN_CONTACT_EMAIL_FIELD}[LANGUAGE_NONE][$key] = array(
    'value' => $value,
    'default' => 1,
  );
}