You are here

function patron_email_js in Library 5.2

Same name and namespace in other branches
  1. 6 patron/patron.module \patron_email_js()

File

patron/patron.module, line 422

Code

function patron_email_js() {
  $email = $_POST['email'];
  if ($email != '' && !is_null($email)) {
    $exists = db_query_range("SELECT uid, name from {users} where mail= '%s'", $node->email, 0, 1);
    if ($exists) {
      while ($patron = db_fetch_object($exists)) {

        // Build the new form.
        $form_state = array(
          'submitted' => FALSE,
        );
        $form_build_id = $_POST['form_build_id'];

        // We retreive the cached form, change the value, and resave.
        $form = form_get_cache($form_build_id, $form_state);
        form_set_value($form['required_for_library']['patron_uid'], $patron->uid, $form_state);
        $output = 'Matching Drupal user found. Username: ' . $patron->name;
        print drupal_json(array(
          'data' => $output,
        ));
      }
    }
  }
}