function _quotes_handle_author in Quotes 7
Same name and namespace in other branches
- 5 quotes.module \_quotes_handle_author()
- 6 quotes.module \_quotes_handle_author()
Helper function to fetch or insert an author.
Parameters
string $author: The text of the author's name.
3 calls to _quotes_handle_author()
- quotes_delete in ./
quotes.module - Implements hook_delete().
- quotes_import in ./
quotes.module - Inserts quotes data into db tables and handles %id variable in quotes title.
- quotes_update in ./
quotes.module - Implements hook_update().
File
- ./
quotes.module, line 598 - 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 = NULL) {
if (empty($author)) {
return FALSE;
}
$result = db_select('quotes_authors', 'a')
->fields('a', array(
'aid',
))
->condition('a.name', $author)
->execute();
if ($result
->rowCount()) {
return $result
->fetchField();
}
$aid = db_insert('quotes_authors')
->fields(array(
'name' => $author,
))
->execute();
if ($aid === FALSE) {
drupal_set_message(t('Quotes: insert author failed.'), 'error');
}
return $aid;
}