function _quotes_handle_author in Quotes 6
Same name and namespace in other branches
- 5 quotes.module \_quotes_handle_author()
- 7 quotes.module \_quotes_handle_author()
Helper function to fetch or insert an author.
Parameters
$author: The text of the author's name.
@return The aid for the author in the quotes_authors table.
3 calls to _quotes_handle_author()
- quotes_delete in ./
quotes.module - Implementation of hook_delete().
- quotes_insert in ./
quotes.module - Implementation of hook_insert().
- quotes_update in ./
quotes.module - Implementation of hook_update().
File
- ./
quotes.module, line 456 - 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_handle_author($author) {
$aid = db_result(db_query("SELECT qa.aid FROM {quotes_authors} qa WHERE qa.name='%s'", $author));
if (empty($aid)) {
$result = db_query("INSERT INTO {quotes_authors} (name) VALUES ('%s')", $author);
if ($result === FALSE) {
drupal_set_message(t('Quotes: insert author failed.'), 'error');
}
$aid = db_last_insert_id('quotes_authors', 'aid');
if ($aid === FALSE) {
drupal_set_message(t('Quotes: get aid failed.'), 'error');
}
}
return $aid;
}