function biblio_delete_orphan_authors in Bibliography Module 6
Same name and namespace in other branches
- 6.2 includes/biblio.contributors.inc \biblio_delete_orphan_authors()
- 7 includes/biblio.contributors.inc \biblio_delete_orphan_authors()
- 7.2 includes/biblio.contributors.inc \biblio_delete_orphan_authors()
1 call to biblio_delete_orphan_authors()
- biblio_cron in ./
biblio.module
File
- ./
biblio.contributors.inc, line 143
Code
function biblio_delete_orphan_authors($force = FALSE) {
if (variable_get('biblio_auto_orphaned_author_delete', 0) || $force) {
$active_cids = array();
$all_cids = array();
$result = db_query('SELECT cid FROM {biblio_contributor} GROUP BY cid');
while ($author = db_fetch_object($result)) {
$active_cids[] = $author->cid;
}
$result = db_query('SELECT cid FROM {biblio_contributor_data} GROUP BY cid');
while ($author = db_fetch_object($result)) {
$all_cids[] = $author->cid;
}
$orphans = array_diff($all_cids, $active_cids);
if (!empty($orphans)) {
db_query('DELETE FROM {biblio_contributor_data} WHERE cid IN (' . implode(',', $orphans) . ')');
$count = db_affected_rows();
$message = t('%count orphaned authors were deleted from the biblio_contributor_data table.', array(
'%count' => $count,
));
watchdog('biblio_cron', $message);
}
}
}