function quotes_get_authors in Quotes 7
Same name and namespace in other branches
- 5 quotes.module \quotes_get_authors()
- 6 quotes.module \quotes_get_authors()
Produce an array of all authors.
Parameters
array $none: Returns a list of authors.
Return value
array 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 2316 - 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;
$sql = db_select('quotes_authors', 'qa');
$sql
->fields('qa', array(
'aid',
'name',
));
$q_alias = $sql
->leftjoin('quotes', 'q', "q.aid = qa.aid");
$count_alias = $sql
->addExpression('COUNT(q.nid)', 'count');
$sql
->groupBy('name, qa.aid')
->orderBy('name', 'ASC');
$result = $sql
->execute()
->fetchAll();
foreach ($result as $key => $value) {
$row = $value;
if (empty($row->name)) {
$unknown = $row->aid;
}
if ($row->count) {
$list[$row->aid] = $row->name;
}
else {
db_query("DELETE FROM {quotes_authors} WHERE aid=:aid", array(
':aid' => $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;
}