$value) { prefs::$prefs['main'][$pref] = $value; } } } /** This function sets user preferences. */ static function set($path, $val) { if (!$_SESSION['authok']) { return false; } if (!is_array(prefs::$prefs)) { prefs::load(); } list($ver, $pref) = explode('/', $path); $q = dbQuery("DELETE FROM user_preferences WHERE account={$_SESSION['userid']} AND id='$pref' AND version='$ver'"); $q = dbQuery("INSERT INTO user_preferences VALUES('$pref','$ver',{$_SESSION['userid']},'".addslashes($val)."')"); if ($q) { prefs::$prefs[$ver][$pref] = $val; return true; } return false; } /** This function returns a value from the preferences using a version/pref_name path. */ static function get($path, $default = null) { if (!is_array(prefs::$prefs)) { prefs::load(); } list($version, $name) = explode('/', $path); if (isset(prefs::$prefs[$version])) { $v = prefs::$prefs[$version][$name]; } else { $v = null; } if (is_null($v) && !is_null($default)) { $v = $default; } return $v; } } ?>