You are here

function multiple_email_addresses_form in Multiple E-mail Addresses 5

Builds form which will output a table of email addresses with management links

Parameters

array $addresses:

array $headers:

1 string reference to 'multiple_email_addresses_form'
multiple_email_addresses_page in ./multiple_email_addresses_page.inc
Renders the page to manage user's email addresses

File

./multiple_email_addresses_page.inc, line 32
Contains functions for presentation and processing of email address management page

Code

function multiple_email_addresses_form($account) {
  $addresses = multiple_email_load_addresses($account->uid, $headers);
  unset($addresses[0]);
  $headers[] = array(
    'data' => t('Email Address'),
    'field' => 'a.email',
  );
  $headers[] = array(
    'data' => t('Confirmed?'),
    'field' => 'a.confirmed',
  );
  $headers[] = array(
    'data' => t('Primary Address?'),
    'field' => 'primary_address',
    'sort' => 'desc',
  );
  $headers[] = array(
    'data' => t('Remove'),
  );
  $form['#headers'] = $headers;
  $form['#columns'] = array(
    'email',
    'confirmed',
    'primary',
    'delete',
  );
  $form['add']['#value'] = theme('multiple_email_add_address_link');
  foreach ($addresses as $eid => $a) {
    $aid = "address_{$eid}";
    $form[$aid]["email_{$eid}"] = array(
      '#value' => $a->email,
    );
    $form[$aid]["confirmed_{$eid}"] = array(
      '#value' => $a->confirmed ? 'Yes' : l('Click here to confirm', "my-email-addresses/confirm/{$eid}"),
    );
    $form[$aid]["primary_{$eid}"] = array(
      '#value' => $a->primary_address ? 'Primary' : l('Make Primary', "my-email-addresses/make-primary/{$eid}"),
    );
    $form[$aid]["delete_{$eid}"] = array(
      '#value' => $a->primary_address ? '' : l('X', "my-email-addresses/delete/{$eid}"),
    );
  }
  return $form;
}