You are here

function theme_multiple_email_manage in Multiple E-mail Addresses 7

Same name and namespace in other branches
  1. 6 multiple_email_manage.inc \theme_multiple_email_manage()
  2. 2.x multiple_email_manage.inc \theme_multiple_email_manage()

Theme multiple_email_manage form.

Parameters

array $form:

File

./multiple_email_manage.inc, line 129
Callbacks for user management of users e-mail addresses.

Code

function theme_multiple_email_manage($variables) {
  $form = $variables['form'];
  $rows = array();
  $account = $form['#account'];
  foreach (element_children($form['addresses']) as $eid) {
    $address = $form['addresses'][$eid]['#email'];
    $row = array();
    $row[] = drupal_render($form['addresses'][$eid]['email']);
    if (isset($form['addresses'][$eid]['confirm'])) {
      $row[] = drupal_render($form['addresses'][$eid]['confirm']);
    }
    else {
      $row[] = $address->confirmed == 1 ? t('Yes') : l(t('Click to confirm'), 'user/' . $account->uid . '/edit/email-addresses/confirm/' . $eid);
    }
    $ops = array();

    // See if they can edit this e-mail address.
    if (user_access('administer multiple emails') || variable_get('multiple_email_edit_emails', 0) && !$address->primary_address) {
      $ops[] = l(t('Edit'), 'user/' . $account->uid . '/edit/email-addresses/edit/' . $address->eid);
    }
    if ($address->primary_address == 0) {

      // Only non-primary addresses can be deleted and set as primary
      $ops[] = l(t('Delete'), 'user/' . $account->uid . '/edit/email-addresses/delete/' . $address->eid);
      if (_multiple_email_access('primary', $account, $address)) {
        $ops[] = l(t('Set as primary'), 'user/' . $account->uid . '/edit/email-addresses/primary/' . $address->eid);
      }
    }
    else {

      // Let the user know that this is the primary address.
      $ops[] = t('Primary address');
    }
    $row[] = implode(' | ', $ops);
    $rows[] = $row;
  }
  if (empty($rows)) {
    $rows = array(
      array(
        'class' => array(
          'error',
        ),
        'data' => array(
          array(
            'colspan' => 3,
            'data' => t('Unable to find any e-mail addresses.'),
          ),
        ),
      ),
    );
  }
  $rows[] = array(
    drupal_render($form['new']['email']),
    drupal_render($form['new']['confirm']),
    '',
  );
  $headers = array(
    t('E-mail'),
    t('Confirmed'),
    t('Operations'),
  );
  $output = theme('table', array(
    'header' => $headers,
    'rows' => $rows,
  ));
  $output .= drupal_render_children($form);
  return $output;
}