You are here

function quotes_get_authors in Quotes 5

Same name and namespace in other branches
  1. 6 quotes.module \quotes_get_authors()
  2. 7 quotes.module \quotes_get_authors()

Produce an array of all authors.

$return An associative array of authors in the quotes table.

3 calls to quotes_get_authors()
quotes_author_form in ./quotes.module
Form to select an author.
quotes_bios in ./quotes.module
Bios maintenance page.
_quotes_block_configure in ./quotes.module
Quotes block configuration.
1 string reference to 'quotes_get_authors'
quotes_views_tables in ./quotes_views.inc
Implementation of views_tables().

File

./quotes.module, line 1986

Code

function quotes_get_authors() {
  $list = array();
  $unknown = -1;
  $result = db_query('SELECT qa.aid, qa.name, COUNT(q.nid) as count FROM {quotes_authors} qa LEFT JOIN {quotes} q USING(aid) GROUP BY qa.name ORDER BY qa.name');
  while ($row = db_fetch_array($result)) {
    if (empty($row['name'])) {
      $unknown = $row['aid'];
    }
    if ($row['count']) {
      $list[$row['aid']] = $row['name'];
    }
    else {

      //      drupal_set_message('There are no quotes for: '. filter_xss($row['name'], array()));
      db_query("DELETE FROM {quotes_authors} WHERE aid=%d", $row['aid']);
      watchdog('Quotes', t('Deleted aid=!aid (!name) because of no quotes.', array(
        '!aid' => $row['aid'],
        '!name' => drupal_substr(filter_xss($row['name'], array()), 0, 40),
      )));
    }
  }
  if ($unknown != -1) {
    $list[$unknown] = t('unspecified');
  }
  return $list;
}