mirror of https://tt-rss.org/git/tt-rss.git
per-user preferences
This commit is contained in:
parent
46a1969d75
commit
ff485f1d50
16
backend.php
16
backend.php
|
@ -1555,8 +1555,8 @@
|
||||||
|
|
||||||
// print "$pref_name : $type_name : $value<br>";
|
// print "$pref_name : $type_name : $value<br>";
|
||||||
|
|
||||||
db_query($link, "UPDATE ttrss_prefs SET value = '$value'
|
db_query($link, "UPDATE ttrss_user_prefs SET value = '$value'
|
||||||
WHERE pref_name = '$pref_name'");
|
WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1582,18 +1582,22 @@
|
||||||
|
|
||||||
if (WEB_DEMO_MODE) return;
|
if (WEB_DEMO_MODE) return;
|
||||||
|
|
||||||
db_query($link, "UPDATE ttrss_prefs SET value = def_value");
|
db_query($link,"UPDATE ttrss_user_prefs
|
||||||
|
SET value = ttrss_prefs.def_value
|
||||||
|
WHERE owner_uid = '".$_SESSION["uid"]."' AND
|
||||||
|
ttrss_prefs.pref_name = ttrss_user_prefs.pref_name");
|
||||||
|
|
||||||
header("Location: prefs.php");
|
header("Location: prefs.php");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$result = db_query($link, "SELECT
|
$result = db_query($link, "SELECT
|
||||||
pref_name,short_desc,help_text,value,type_name,
|
ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,
|
||||||
section_name,def_value
|
section_name,def_value
|
||||||
FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections
|
FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs
|
||||||
WHERE type_id = ttrss_prefs_types.id AND
|
WHERE type_id = ttrss_prefs_types.id AND
|
||||||
section_id = ttrss_prefs_sections.id
|
section_id = ttrss_prefs_sections.id AND
|
||||||
|
ttrss_user_prefs.pref_name = ttrss_prefs.pref_name
|
||||||
ORDER BY section_id,short_desc");
|
ORDER BY section_id,short_desc");
|
||||||
|
|
||||||
print "<form action=\"backend.php\" method=\"POST\">";
|
print "<form action=\"backend.php\" method=\"POST\">";
|
||||||
|
|
|
@ -10,8 +10,12 @@
|
||||||
|
|
||||||
$result = db_query($link, "SELECT
|
$result = db_query($link, "SELECT
|
||||||
value,ttrss_prefs_types.type_name as type_name
|
value,ttrss_prefs_types.type_name as type_name
|
||||||
FROM ttrss_prefs,ttrss_prefs_types
|
FROM
|
||||||
WHERE pref_name = '$pref_name' AND ttrss_prefs_types.id = type_id");
|
ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types
|
||||||
|
WHERE
|
||||||
|
ttrss_user_prefs.pref_name = '$pref_name' AND
|
||||||
|
ttrss_prefs_types.id = type_id AND
|
||||||
|
ttrss_user_prefs.pref_name = ttrss_prefs.pref_name");
|
||||||
|
|
||||||
if (db_num_rows($result) > 0) {
|
if (db_num_rows($result) > 0) {
|
||||||
$value = db_fetch_result($result, 0, "value");
|
$value = db_fetch_result($result, 0, "value");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?
|
<?
|
||||||
require_once "version.php"
|
require_once "version.php";
|
||||||
require_once "config.php"
|
require_once "config.php";
|
||||||
require_once "db-prefs.php"
|
require_once "db-prefs.php";
|
||||||
|
|
||||||
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||||
|
|
||||||
|
|
|
@ -484,4 +484,36 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initialize_user_prefs($link, $uid) {
|
||||||
|
|
||||||
|
$uid = db_escape_string($uid);
|
||||||
|
|
||||||
|
db_query($link, "BEGIN");
|
||||||
|
|
||||||
|
$result = db_query($link, "SELECT pref_name,def_value FROM ttrss_prefs");
|
||||||
|
|
||||||
|
$u_result = db_query($link, "SELECT pref_name
|
||||||
|
FROM ttrss_user_prefs WHERE owner_uid = '$uid'");
|
||||||
|
|
||||||
|
$active_prefs = array();
|
||||||
|
|
||||||
|
while ($line = db_fetch_assoc($u_result)) {
|
||||||
|
array_push($active_prefs, $line["pref_name"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ($line = db_fetch_assoc($result)) {
|
||||||
|
if (array_search($line["pref_name"], $active_prefs) === FALSE) {
|
||||||
|
// print "adding " . $line["pref_name"] . "<br>";
|
||||||
|
|
||||||
|
db_query($link, "INSERT INTO ttrss_user_prefs
|
||||||
|
(owner_uid,pref_name,value) VALUES
|
||||||
|
('$uid', '".$line["pref_name"]."','".$line["def_value"]."')");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
db_query($link, "COMMIT");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -4,11 +4,16 @@
|
||||||
require_once "version.php";
|
require_once "version.php";
|
||||||
require_once "config.php";
|
require_once "config.php";
|
||||||
require_once "db-prefs.php";
|
require_once "db-prefs.php";
|
||||||
|
require_once "functions.php";
|
||||||
|
|
||||||
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||||
|
|
||||||
$_SESSION["uid"] = PLACEHOLDER_UID; // FIXME: placeholder
|
$_SESSION["uid"] = PLACEHOLDER_UID; // FIXME: placeholder
|
||||||
$_SESSION["name"] = PLACEHOLDER_NAME;
|
$_SESSION["name"] = PLACEHOLDER_NAME;
|
||||||
|
|
||||||
|
initialize_user_prefs($link, $_SESSION["uid"]);
|
||||||
|
// FIXME this needs to be moved somewhere after user creation
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|
|
@ -128,32 +128,31 @@ create table ttrss_prefs (pref_name varchar(250) primary key,
|
||||||
section_id integer not null references ttrss_prefs_sections(id) default 1,
|
section_id integer not null references ttrss_prefs_sections(id) default 1,
|
||||||
short_desc text not null,
|
short_desc text not null,
|
||||||
help_text text not null default '',
|
help_text text not null default '',
|
||||||
def_value text not null,
|
def_value text not null);
|
||||||
value text not null);
|
|
||||||
|
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id) values('ENABLE_FEED_ICONS', 1, 'true', 'true', 'Enable icons in feedlist',2);
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_FEED_ICONS', 1, 'true', 'Enable icons in feedlist',2);
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id) values('ICONS_DIR', 2, 'icons', 'icons', 'Local directory for feed icons',1);
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ICONS_DIR', 2, 'icons', 'Local directory for feed icons',1);
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id) values('ICONS_URL', 2, 'icons', 'icons', 'Local URL for icons',1);
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ICONS_URL', 2, 'icons', 'Local URL for icons',1);
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id) values('PURGE_OLD_DAYS', 3, '60', '60', 'Purge old posts after this number of days (0 - disables)',1);
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('PURGE_OLD_DAYS', 3, '60', 'Purge old posts after this number of days (0 - disables)',1);
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id) values('UPDATE_POST_ON_CHECKSUM_CHANGE', 1, 'true', 'true', 'Update post on checksum change',1);
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('UPDATE_POST_ON_CHECKSUM_CHANGE', 1, 'true', 'Update post on checksum change',1);
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id) values('ENABLE_PREFS_CATCHUP_UNCATCHUP', 1, 'false', 'false', 'Enable catchup/uncatchup buttons in feed editor',2);
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_PREFS_CATCHUP_UNCATCHUP', 1, 'false', 'Enable catchup/uncatchup buttons in feed editor',2);
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id,help_text) values('ENABLE_LABELS', 1, 'false', 'false', 'Enable labels',3,
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ENABLE_LABELS', 1, 'false', 'Enable labels',3,
|
||||||
'Experimental support for virtual feeds based on user crafted SQL queries. This feature is highly experimental and at this point not user friendly. Use with caution.');
|
'Experimental support for virtual feeds based on user crafted SQL queries. This feature is highly experimental and at this point not user friendly. Use with caution.');
|
||||||
|
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id) values('DEFAULT_UPDATE_INTERVAL', 3, '30', '30', 'Default interval between feed updates (in minutes)',1);
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DEFAULT_UPDATE_INTERVAL', 3, '30', 'Default interval between feed updates (in minutes)',1);
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id) values('DISPLAY_HEADER', 1, 'true', 'true', 'Display header',2);
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_HEADER', 1, 'true', 'Display header',2);
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id) values('DISPLAY_FOOTER', 1, 'true', 'true', 'Display footer',2);
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_FOOTER', 1, 'true', 'Display footer',2);
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id) values('USE_COMPACT_STYLESHEET', 1, 'false', 'false', 'Use compact stylesheet by default',2);
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('USE_COMPACT_STYLESHEET', 1, 'false', 'Use compact stylesheet by default',2);
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id,help_text) values('DEFAULT_ARTICLE_LIMIT', 3, '0', '0', 'Default article limit',2,
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DEFAULT_ARTICLE_LIMIT', 3, '0', 'Default article limit',2,
|
||||||
'Default limit for articles to display, any custom number you like (0 - disables).');
|
'Default limit for articles to display, any custom number you like (0 - disables).');
|
||||||
|
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id,help_text) values('DAEMON_REFRESH_ONLY', 1, 'false', 'false', 'Daemon refresh only', 3,
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DAEMON_REFRESH_ONLY', 1, 'false', 'Daemon refresh only', 3,
|
||||||
'Updates to all feeds will only run when the backend script is invoked with a "daemon" option on the URI stem.');
|
'Updates to all feeds will only run when the backend script is invoked with a "daemon" option on the URI stem.');
|
||||||
|
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id,help_text) values('DISPLAY_FEEDLIST_ACTIONS', 1, 'false', 'false', 'Display feedlist actions',2,
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DISPLAY_FEEDLIST_ACTIONS', 1, 'false', 'Display feedlist actions',2,
|
||||||
'Display separate dropbox for feedlist actions, if disabled these actions are available in global actions menu.');
|
'Display separate dropbox for feedlist actions, if disabled these actions are available in global actions menu.');
|
||||||
|
|
||||||
insert into ttrss_prefs (pref_name,type_id,value,def_value,short_desc,section_id) values('ENABLE_SPLASH', 1, 'false', 'false', 'Enable loading splashscreen',2);
|
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_SPLASH', 1, 'false', 'Enable loading splashscreen',2);
|
||||||
|
|
||||||
create table ttrss_user_prefs (
|
create table ttrss_user_prefs (
|
||||||
owner_uid integer not null references ttrss_users(id) on delete cascade,
|
owner_uid integer not null references ttrss_users(id) on delete cascade,
|
||||||
|
|
|
@ -4,12 +4,17 @@
|
||||||
require_once "version.php";
|
require_once "version.php";
|
||||||
require_once "config.php";
|
require_once "config.php";
|
||||||
require_once "db-prefs.php";
|
require_once "db-prefs.php";
|
||||||
|
require_once "functions.php";
|
||||||
|
|
||||||
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||||
|
|
||||||
$_SESSION["uid"] = PLACEHOLDER_UID; // FIXME: placeholder
|
$_SESSION["uid"] = PLACEHOLDER_UID; // FIXME: placeholder
|
||||||
$_SESSION["name"] = PLACEHOLDER_NAME;
|
$_SESSION["name"] = PLACEHOLDER_NAME;
|
||||||
|
|
||||||
|
|
||||||
|
initialize_user_prefs($link, $_SESSION["uid"]);
|
||||||
|
// FIXME this needs to be moved somewhere after user creation
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|
Loading…
Reference in New Issue