mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 20:55:55 +00:00
implement settings profiles (bump schema)
This commit is contained in:
26
db-prefs.php
26
db-prefs.php
@@ -14,11 +14,19 @@
|
||||
|
||||
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'";
|
||||
} else {
|
||||
$profile_qpart = "profile IS NULL";
|
||||
}
|
||||
|
||||
|
||||
if ($prefs_cache && !defined('DISABLE_SESSIONS') && !SINGLE_USER_MODE) {
|
||||
if ($_SESSION["prefs_cache"] && $_SESSION["prefs_cache"][$pref_name]) {
|
||||
$tuple = $_SESSION["prefs_cache"][$pref_name];
|
||||
@@ -31,6 +39,7 @@
|
||||
FROM
|
||||
ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types
|
||||
WHERE
|
||||
$profile_qpart AND
|
||||
ttrss_user_prefs.pref_name = '$pref_name' AND
|
||||
ttrss_prefs_types.id = type_id AND
|
||||
owner_uid = '$user_id' AND
|
||||
@@ -68,10 +77,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
function set_pref($link, $key, $value) {
|
||||
function set_pref($link, $key, $value, $user_id) {
|
||||
$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 = "profile = '$profile'";
|
||||
} else {
|
||||
$profile_qpart = "profile IS NULL";
|
||||
}
|
||||
|
||||
$result = db_query($link, "SELECT type_name
|
||||
FROM ttrss_prefs,ttrss_prefs_types
|
||||
WHERE pref_name = '$key' AND type_id = ttrss_prefs_types.id");
|
||||
@@ -96,6 +119,7 @@
|
||||
|
||||
db_query($link, "UPDATE ttrss_user_prefs SET
|
||||
value = '$value' WHERE pref_name = '$key'
|
||||
AND $profile_qpart
|
||||
AND owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
$_SESSION["prefs_cache"] = array();
|
||||
|
||||
Reference in New Issue
Block a user