function favorites_remove_favorite in Favorites 7.2
Same name and namespace in other branches
- 6 favorites.module \favorites_remove_favorite()
- 7 favorites.module \favorites_remove_favorite()
Deletes a favorite.
Parameters
$favorite: The loaded favorite object.
1 string reference to 'favorites_remove_favorite'
- favorites_menu in ./
favorites.module - Implements hook_menu().
File
- ./
favorites.module, line 91 - The favorites module allows users to bookmark any path within a site.
Code
function favorites_remove_favorite($favorite) {
global $user;
$access = user_access('manage own favorites') && $user->uid == $favorite->uid;
// no admin page implemented yet! || user_access('manage all favorites');
if ($access && drupal_valid_token($_GET['token'], $favorite->timestamp . $favorite->uid . $favorite->path)) {
_favorites_delete($favorite);
if (!empty($_GET['js'])) {
drupal_json_output(array(
'list' => favorites_list(),
));
return;
}
}
else {
drupal_set_message(t('You do not have permission to remove this favorite.'), 'error');
}
// Unless this is an AJAX request, the query string contains the redirection page.
if (empty($_GET['js'])) {
drupal_goto();
}
}