You are here

function _homebox_get_user_settings in Homebox 7.2

Same name and namespace in other branches
  1. 6.3 homebox.module \_homebox_get_user_settings()
  2. 6.2 homebox.module \_homebox_get_user_settings()
  3. 7.3 homebox.module \_homebox_get_user_settings()

Fetch user page settings, if they exist.

Parameters

$page: A page object

$init: Make sure the user object is fully initialized, not FALSE. Needed for adding/editing a single block.

$_reset: Reload settings from the database.

Return value

An object representing the user's page settings, or FALSE.

5 calls to _homebox_get_user_settings()
homebox_add_block in ./homebox.module
Add a custom block to a user's page.
homebox_block_edit_form_builder_submit in ./homebox.module
Save settings for the block and render a replacement with the updated settings.
homebox_build in ./homebox.module
Responsible for firing the hook_theme().
homebox_prepare_block in ./homebox.module
Prepare a block for rendering with theme('homebox_block').
_homebox_save_user_settings in ./homebox.module
Save the user's page settings

File

./homebox.module, line 1392
Homebox main file, takes care of global functions settings constants, etc.

Code

function _homebox_get_user_settings($page, $init = FALSE, $_reset = FALSE) {
  global $user;
  static $cache = array();
  $key = $user->uid . ':' . $page->name;
  if ($_reset) {
    unset($cache[$key]);
  }
  if (!isset($cache[$key]) || $init && $cache[$key] === FALSE) {
    $settings = db_query("SELECT settings FROM {homebox_users}\n      WHERE uid = :uid AND name = :name", array(
      ':uid' => $user->uid,
      ':name' => $page->name,
    ))
      ->fetchField();
    $cache[$key] = $settings ? unserialize($settings) : FALSE;
    if ($cache[$key] === FALSE && $init) {
      _homebox_save_user_settings($page, $page->settings['blocks']);
      $cache[$key] = _homebox_get_user_settings($page);
    }
  }
  return $cache[$key];
}