You are here

function favorites_add_favorite in Favorites 7

Same name and namespace in other branches
  1. 6 favorites.module \favorites_add_favorite()
  2. 7.2 favorites.module \favorites_add_favorite()

Add a favorite.

Parameters

$values: A keyed array submitted by the favorites form with the following elements:

  • 'path' => The page path of the URL.
  • 'query' => The query part of the URL.
  • 'title' => The title as entered by the user.
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 188
The favorites module allows users to bookmark any path within a site.

Code

function favorites_add_favorite($values) {

  // 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']);

  // Prepare the query values
  $values['query'] = drupal_get_query_array($values['query']);

  // Remove useless q value
  unset($values['query']['q']);
  $values['query'] = serialize($values['query']);
  _favorites_save_favorite($values);
}