function _biblio_get_authors in Bibliography Module 6.2
Same name and namespace in other branches
- 6 biblio.pages.inc \_biblio_get_authors()
- 7 includes/biblio.pages.inc \_biblio_get_authors()
- 7.2 includes/biblio.pages.inc \_biblio_get_authors()
Parameters
bool $filter: (optional)
Return value
array
1 call to _biblio_get_authors()
- biblio_author_page in includes/
biblio.pages.inc
File
- includes/
biblio.pages.inc, line 1295 - Functions in the biblio module related to filtering and page generation.
Code
function _biblio_get_authors($filter = NULL) {
global $user;
$where = array();
$where_clause = '';
$base = variable_get('biblio_base', 'biblio');
$menu = menu_get_active_title();
if ($menu == 'Authors') {
$path = $base . '/authors/';
}
if ($menu == 'Biblio settings') {
$path = 'admin/settings/biblio/author/list/';
}
if ($filter) {
$filter = strtoupper($filter);
$where['filter'] = "UPPER(SUBSTRING(lastname,1,1)) = '%s' ";
$header_ext = t(' (whose last name starts with the letter "@letter") ', array(
'@letter' => $filter,
));
}
else {
$query_ext = NULL;
$header_ext = NULL;
}
if (!biblio_access('edit_author')) {
//show only published entries to everyone except admin
$where['status'] = 'n.status = 1 ';
}
if (variable_get('biblio_view_only_own', 0)) {
//show only authors that belong to nodes that the user has access to
$where[] = "n.uid = {$user->uid}";
}
if (count($where)) {
$where_clause = 'WHERE (' . implode(') AND (', $where) . ')';
}
$suspects = array();
$result = db_query('SELECT lastname FROM {biblio_contributor_data} ' . (isset($where['filter']) ? 'WHERE ' . $where['filter'] : '') . ' GROUP BY lastname HAVING COUNT(*) > 1', array(
':filter' => $filter,
));
while ($author = db_fetch_object($result)) {
$suspects[] = $author->lastname;
}
$sql = 'SELECT bd.cid, bd.drupal_uid, bd.name, bd.lastname, bd.firstname, bd.prefix, ' . 'bd.suffix, bd.initials, bd.affiliation, bd.md5, bd.literal, COUNT(*) AS cnt ' . 'FROM {biblio_contributor} b ' . 'LEFT JOIN {biblio_contributor_data} bd ON b.cid = bd.cid ' . 'INNER JOIN {node} n on n.vid = b.vid ' . $where_clause . ' ' . 'GROUP BY bd.cid, bd.drupal_uid, bd.name, bd.lastname, bd.firstname, bd.prefix, ' . 'bd.suffix, bd.initials, bd.affiliation, bd.md5, bd.literal ' . 'HAVING COUNT(*) > 0 ' . 'ORDER BY lastname ASC, SUBSTRING(firstname, 1, 1) ASC, initials ASC';
$db_result = db_query($sql, $filter);
while ($author = db_fetch_array($db_result)) {
if (array_search($author['lastname'], $suspects) !== FALSE) {
$author['#suspect'] = TRUE;
}
$authors[] = $author;
}
return $authors;
}