if (!$user_id) {
$user_id = $_SESSION["uid"];
+ $profile = $_SESSION["profile"];
} else {
$user_id = sprintf("%d", $user_id);
$prefs_cache = false;
}
+ if ($profile) {
+ $profile_qpart = "profile = '$profile' AND";
+ } else {
+ $profile_qpart = "profile IS NULL AND";
+ }
+
+ if (get_schema_version($link) < 63) $profile_qpart = "";
+
if ($prefs_cache && !defined('DISABLE_SESSIONS') && !SINGLE_USER_MODE) {
if ($_SESSION["prefs_cache"] && $_SESSION["prefs_cache"][$pref_name]) {
$tuple = $_SESSION["prefs_cache"][$pref_name];
FROM
ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types
WHERE
+ $profile_qpart
ttrss_user_prefs.pref_name = '$pref_name' AND
ttrss_prefs_types.id = type_id AND
owner_uid = '$user_id' AND
}
}
- // doesn't peform any type checking, be vigilant
-
- function set_pref($link, $key, $value) {
+ function set_pref($link, $key, $value, $user_id = false) {
$key = db_escape_string($key);
$value = db_escape_string($value);
+ if (!$user_id) {
+ $user_id = $_SESSION["uid"];
+ $profile = $_SESSION["profile"];
+ } else {
+ $user_id = sprintf("%d", $user_id);
+ $prefs_cache = false;
+ }
+
+ if ($profile) {
+ $profile_qpart = "AND profile = '$profile'";
+ } else {
+ $profile_qpart = "AND profile IS NULL";
+ }
+
+ if (get_schema_version($link) < 63) $profile_qpart = "";
+
$result = db_query($link, "SELECT type_name
FROM ttrss_prefs,ttrss_prefs_types
WHERE pref_name = '$key' AND type_id = ttrss_prefs_types.id");
db_query($link, "UPDATE ttrss_user_prefs SET
value = '$value' WHERE pref_name = '$key'
+ $profile_qpart
AND owner_uid = " . $_SESSION["uid"]);
$_SESSION["prefs_cache"] = array();