You are here

function user_variable_del in User variable 7

Same name and namespace in other branches
  1. 6 user_variable.module \user_variable_del()

Remove the variable with the given name.

Parameters

$name: Variable name.

$common: If TRUE then the variable does not depend on user ID.

$uid: User ID.

$session: Session ID.

File

./user_variable.module, line 190
User variable - Creating and working with user variables.

Code

function user_variable_del($name, $common = FALSE, $uid = 0, $session = '') {
  global $user_variables_array, $user;
  if ($session === TRUE) {
    $session = session_id();
  }
  elseif ($session === FALSE) {
    $session = '';
  }
  if ($common) {
    db_query("DELETE FROM {user_variable}\n      WHERE common = 1 AND name = :name AND sid = :sid", array(
      ':name' => $name,
      ':sid' => $session,
    ));
    if ($session == '') {
      unset($user_variables_array['common_session'][$name]);
    }
    else {
      unset($user_variables_array['common'][$session][$name]);
    }
  }
  else {
    if (!$uid) {
      $uid = $user->uid;
    }
    db_query("DELETE FROM {user_variable}\n      WHERE common = 0 AND name = :name AND uid = :uid AND sid = :sid", array(
      ':name' => $name,
      ':uid' => $uid,
      ':sid' => $session,
    ));
    if ($session == '') {
      unset($user_variables_array['uid_session'][$uid][$name]);
    }
    else {
      unset($user_variables_array['uid'][$uid][$session][$name]);
    }
  }
}