You are here

function multiple_email_register_email in Multiple E-mail Addresses 7

Same name and namespace in other branches
  1. 5 multiple_email.module \multiple_email_register_email()
  2. 6 multiple_email.module \multiple_email_register_email()
  3. 2.x multiple_email.module \multiple_email_register_email()

Adds an unconfirmed e-mail address to the e-mail registry.

If you specify the 3rd parameter to be true, the e-mail address will be recorded as having been confirmed.

Returns the email's eid on success, false on failure.

Parameters

integer $uid:

string $email:

boolean $confirmed:

Return value

mixed

4 calls to multiple_email_register_email()
multiple_email_edit_form_submit in ./multiple_email_edit_page.inc
Processes form submission of multiple_email_edit_form
multiple_email_manage_submit in ./multiple_email_manage.inc
Handle submission of multiple_email_manage_form.
multiple_email_user_insert in ./multiple_email.module
Implements hook_user_insert().
multiple_email_user_update in ./multiple_email.module
Implements hook_user_update().

File

./multiple_email.module, line 515
multiple_email module file

Code

function multiple_email_register_email($uid, $email, $confirmed = FALSE, $eid = NULL) {
  $email = trim($email);
  if ($eid) {
    $query = db_update('multiple_email')
      ->fields(array(
      'email' => $email,
      'time_registered' => REQUEST_TIME,
      'confirmed' => (int) $confirmed,
      'confirm_code' => $code = multiple_email_code(),
      'time_code_generated' => REQUEST_TIME,
    ))
      ->condition('eid', $eid);
    $success = $query
      ->execute();
  }
  else {
    $query = db_insert('multiple_email')
      ->fields(array(
      'uid',
      'email',
      'time_registered',
      'confirmed',
      'confirm_code',
      'time_code_generated',
    ), array(
      $uid,
      $email,
      REQUEST_TIME,
      (int) $confirmed,
      $code = multiple_email_code(),
      REQUEST_TIME,
    ));
    $success = $eid = $query
      ->execute();
  }
  if ($success !== FALSE) {
    $email = multiple_email_load($eid);

    // Fires off hook_multiple_email_register().
    module_invoke_all('multiple_email_register', $email);
    return $eid;
  }
  else {
    return FALSE;
  }
}