function _biblio_get_authors in Bibliography Module 7.2
Same name and namespace in other branches
- 6.2 includes/biblio.pages.inc \_biblio_get_authors()
- 6 biblio.pages.inc \_biblio_get_authors()
- 7 includes/biblio.pages.inc \_biblio_get_authors()
1 call to _biblio_get_authors()
- biblio_author_page in includes/
biblio.pages.inc
File
- includes/
biblio.pages.inc, line 1193
Code
function _biblio_get_authors($filter = NULL) {
global $user;
$where = array();
$authors = array();
$where_clause = '';
$output = '';
if ($filter) {
$filter = strtoupper($filter);
$where['filter'] = "UPPER(SUBSTRING(lastname,1,1)) = :filter ";
$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')) {
// $where['access'] = 'n.status = 1 ';
}
//show only published entries to everyone except admin
if (count($where)) {
$where_clause = 'WHERE (' . implode(') AND (', $where) . ')';
}
$suspects = array();
$query = db_select('biblio_contributor_data', 'bcd')
->fields('bcd', array(
'lastname',
))
->groupBy('lastname')
->having('COUNT(*) > 1');
if ($filter) {
$filter = strtoupper($filter);
$query
->where("UPPER(SUBSTRING(lastname,1,1)) = :filter ", array(
':filter' => $filter,
));
}
$result = $query
->execute();
foreach ($result as $author) {
$suspects[] = $author->lastname;
}
// $db_result = db_query('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
// ORDER BY lastname ASC, SUBSTRING(firstname,1,1) ASC,
// initials ASC', array(':filter' => $filter));
// Placeholder so page loads without errors
$db_result = db_query('SELECT * from biblio_contributor');
foreach ($db_result as $author) {
if (array_search($author->lastname, $suspects) !== FALSE) {
$author->suspect = TRUE;
}
$authors[] = $author;
}
return $authors;
}