You are here

function quotes_get_authors in Quotes 6

Same name and namespace in other branches
  1. 5 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.admin.inc
Bios maintenance page.
quotes_block_configure in ./quotes.module
Quotes block configuration.

File

./quotes.module, line 1677
The quotes module allows users to maintain a list of quotes that can be displayed in any number of administrator-defined quote blocks.

Code

function quotes_get_authors($none = FALSE) {
  if ($none) {
    $list = array(
      0 => '- ' . t('none') . ' -',
    );
  }
  else {
    $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 ON q.aid=qa.aid GROUP BY qa.name, qa.aid 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 {
      db_query("DELETE FROM {quotes_authors} WHERE aid=%d", $row['aid']);
      watchdog('Quotes', '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;
}