You are here

function _favorites_parse_cookie in Favorites 7

Same name and namespace in other branches
  1. 7.2 favorites.module \_favorites_parse_cookie()

Helper function: Builds a favorite object from a user cookie.

Used to abstract the storage model (cookie vs. db).

Parameters

$fid: The unique favorite ID for this cookie.

$data: The data as stored in the cookie.

Return value

array|bool The requested favorite, if found. Otherwise FALSE.

2 calls to _favorites_parse_cookie()
_favorites_load_favorites_cookie in ./favorites.module
Helper function: Load favorites from the user's cookies.
_favorites_load_favorite_cookie in ./favorites.module
Helper function: Load a single favorite from the user's cookies.

File

./favorites.module, line 649
The favorites module allows users to bookmark any path within a site.

Code

function _favorites_parse_cookie($fid, $data) {
  global $user;
  $favorite = new stdClass();
  $favorite->fid = $fid;

  // Cookie storage is always for the current user.
  $favorite->uid = $user->uid;
  $data = unserialize($data);
  foreach ($data as $k => $v) {
    $favorite->{$k} = $v;
  }
  return $favorite;
}