You are here

function patron_get_patrons in Library 6

Same name and namespace in other branches
  1. 5.2 patron/patron.module \patron_get_patrons()

Retrieve a list of patrons

Parameters

$nid : If this is blank, only active patrons are returned. If 'all', all are returned. If a number, a specific patron is returned.

3 calls to patron_get_patrons()
patron_email_form in patron/patron.pages.inc
patron_email_form_submit in patron/patron.pages.inc
patron_list_patrons in patron/patron.pages.inc
@file Functions for generating page displays related to the patron module

File

patron/patron.module, line 382

Code

function patron_get_patrons($nid = NULL) {
  if (!$nid) {
    $result = db_query("SELECT * FROM {node} n, {library_patrons} lp WHERE lp.nid = n.nid AND n.type = 'patron' AND lp.disabled = %d ORDER BY lp.name_last, lp.name_first", PATRON_ENABLED);
  }
  elseif (is_numeric($nid)) {
    $result = db_query_range("SELECT * FROM {node} n, {library_patrons} lp WHERE lp.nid = n.nid AND n.type = 'patron' AND n.nid = %d ORDER BY lp.name_last, lp.name_first", $nid, 0, 1);
  }
  else {
    $result = db_query("SELECT * FROM {node} n, {library_patrons} lp WHERE lp.nid = n.nid AND n.type = 'patron' ORDER BY lp.name_last, lp.name_first");
  }
  $patrons = array();
  while ($patron = db_fetch_object($result)) {
    $patrons[] = $patron;
  }
  return empty($patrons) ? FALSE : $patrons;
}