function favorites_add_favorite in Favorites 6
Same name and namespace in other branches
- 7.2 favorites.module \favorites_add_favorite()
- 7 favorites.module \favorites_add_favorite()
Add a favorite.
2 calls to favorites_add_favorite()
- favorites_add_favorite_form_submit in ./
favorites.module - Submit callback for "add favorite" form.
- favorites_add_favorite_js in ./
favorites.module - AHAH callback for add favorites form.
File
- ./
favorites.module, line 165 - The favorites module allows users to bookmark any path within a site.
Code
function favorites_add_favorite($values) {
global $user;
if (empty($user->uid)) {
return;
}
$now = time();
// Normalize the path to the drupal internal path.
// This helps in case the path alias changes or will be removed.
$values['path'] = drupal_get_normal_path($values['path']);
// Delete an existing entry with the same link to avoid duplicates.
db_query("DELETE FROM {favorites} WHERE uid = %d AND path = '%s' AND query = '%s'", $user->uid, $values['path'], $values['query']);
db_query("INSERT INTO {favorites} (uid, path, query, title, timestamp) VALUES (%d, '%s', '%s', '%s', %d)", $user->uid, $values['path'], $values['query'], $values['title'], $now);
}