You are here

function multiple_email_register_email in Multiple E-mail Addresses 6

Same name and namespace in other branches
  1. 5 multiple_email.module \multiple_email_register_email()
  2. 7 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

3 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 in ./multiple_email.module
Implementation of hook_user().

File

./multiple_email.module, line 496
multiple_email module file

Code

function multiple_email_register_email($uid, $email, $confirmed = FALSE, $eid = NULL) {
  if ($eid) {
    $success = db_query("\n      UPDATE {multiple_email}\n      SET\n        email = '%s',\n        time_registered = %d,\n        confirmed = %d,\n        confirm_code = '%s',\n        time_code_generated = %d\n      WHERE\n        eid = %d", $email, time(), (int) $confirmed, $code = multiple_email_code(), time(), $eid);
  }
  else {
    $success = db_query("\n      INSERT INTO {multiple_email}\n        (`uid`,`email`,`time_registered`,`confirmed`,`confirm_code`,`time_code_generated`)\n      VALUES\n        (%d, '%s', %d, %d, '%s', %d)", $uid, $email, time(), (int) $confirmed, $code = multiple_email_code(), time());
  }
  if ($success !== FALSE) {
    if (!$eid) {
      $eid = db_last_insert_id('multiple_email', 'eid');
    }
    $email = multiple_email_load($eid, TRUE);

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