mysite_type_book_search_form_submit

Definition

mysite_type_book_search_form_submit($form_id, $form_values)
plugins/types/book.inc, line 182

Description

Implements mysite_type_hook_search_form_submit().

Code

function mysite_type_book_search_form_submit($form_id, $form_values) {
  // we use LIKE here in case JavaScript autocomplete support doesn't work.
  // or in case the user doesn't autocomplete the form
  $sql = db_rewrite_sql("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON b.nid = n.nid WHERE LOWER(n.title) LIKE LOWER('%s%%') AND b.parent = 0");
  $result = db_query($sql, $form_values['book_title'], $book);
  $count = 0;
  while ($book = db_fetch_object($result)) {
    $data[$count]['uid'] = $form_values['uid'];
    $data[$count]['type'] = $form_values['type'];
    $data[$count]['type_id'] = $book->nid;
    $data[$count]['title'] = mysite_type_book_title($book->nid, $book->title);
    $data[$count]['description'] = $book->title;
    $count++;
  }
  // pass the $data to the universal handler
  mysite_search_handler($data, 'book');
  return;
}