mobile: properly save preferences
This commit is contained in:
parent
fbaca24658
commit
e9105eb50d
33
db-prefs.php
33
db-prefs.php
|
@ -73,12 +73,35 @@
|
|||
function set_pref($link, $key, $value) {
|
||||
$key = db_escape_string($key);
|
||||
$value = db_escape_string($value);
|
||||
|
||||
db_query($link, "UPDATE ttrss_user_prefs SET
|
||||
value = '$value' WHERE pref_name = '$key'
|
||||
AND owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
$_SESSION["prefs_cache"] = array();
|
||||
$result = db_query($link, "SELECT type_name
|
||||
FROM ttrss_prefs,ttrss_prefs_types
|
||||
WHERE pref_name = '$key' AND type_id = ttrss_prefs_types.id");
|
||||
|
||||
if (db_num_rows($result) > 0) {
|
||||
|
||||
$type_name = db_fetch_result($result, 0, "type_name");
|
||||
|
||||
if ($type_name == "bool") {
|
||||
if ($value == "1" || $value == "true") {
|
||||
$value = "true";
|
||||
} else {
|
||||
$value = "false";
|
||||
}
|
||||
} else if ($type_name == "integer") {
|
||||
$value = sprintf("%d", $value);
|
||||
}
|
||||
|
||||
if ($pref_name == 'DEFAULT_ARTICLE_LIMIT' && $value == 0) {
|
||||
$value = 30;
|
||||
}
|
||||
|
||||
db_query($link, "UPDATE ttrss_user_prefs SET
|
||||
value = '$value' WHERE pref_name = '$key'
|
||||
AND owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
$_SESSION["prefs_cache"] = array();
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -4,16 +4,20 @@
|
|||
/* TODO replace with interface to db-prefs */
|
||||
|
||||
function mobile_pref_toggled($link, $id) {
|
||||
if ($_SESSION["mobile-prefs"][$id]) return "true";
|
||||
|
||||
if (get_pref($link, "_MOBILE_$id"))
|
||||
return "true";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function mobile_get_pref($link, $id) {
|
||||
return $_SESSION["mobile-prefs"][$id];
|
||||
//return $_SESSION["mobile-prefs"][$id];
|
||||
return get_pref($link, "_MOBILE_$id");
|
||||
}
|
||||
|
||||
function mobile_set_pref($link, $id, $value) {
|
||||
$_SESSION["mobile-prefs"][$id] = $value;
|
||||
//$_SESSION["mobile-prefs"][$id] = $value;
|
||||
return set_pref($link, "_MOBILE_$id", $value);
|
||||
}
|
||||
|
||||
function mobile_feed_has_icon($id) {
|
||||
|
|
|
@ -84,36 +84,7 @@
|
|||
$pref_name = db_escape_string($pref_name);
|
||||
$value = db_escape_string($_POST[$pref_name]);
|
||||
|
||||
$result = db_query($link, "SELECT type_name
|
||||
FROM ttrss_prefs,ttrss_prefs_types
|
||||
WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id");
|
||||
|
||||
if (db_num_rows($result) > 0) {
|
||||
|
||||
$type_name = db_fetch_result($result, 0, "type_name");
|
||||
|
||||
// print "$pref_name : $type_name : $value<br>";
|
||||
|
||||
if ($type_name == "bool") {
|
||||
if ($value == "1") {
|
||||
$value = "true";
|
||||
} else {
|
||||
$value = "false";
|
||||
}
|
||||
} else if ($type_name == "integer") {
|
||||
$value = sprintf("%d", $value);
|
||||
}
|
||||
|
||||
// print "$pref_name : $type_name : $value<br>";
|
||||
|
||||
if ($pref_name == 'DEFAULT_ARTICLE_LIMIT' && $value == 0) {
|
||||
$value = 30;
|
||||
}
|
||||
|
||||
db_query($link, "UPDATE ttrss_user_prefs SET value = '$value'
|
||||
WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]);
|
||||
|
||||
}
|
||||
set_pref($link, $pref_name, $value);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
require_once "functions.php";
|
||||
|
||||
define('EXPECTED_CONFIG_VERSION', 18);
|
||||
define('SCHEMA_VERSION', 61);
|
||||
define('SCHEMA_VERSION', 62);
|
||||
|
||||
if (!file_exists("config.php")) {
|
||||
print "<b>Fatal Error</b>: You forgot to copy
|
||||
|
|
|
@ -238,7 +238,7 @@ create table ttrss_tags (id integer primary key auto_increment,
|
|||
|
||||
create table ttrss_version (schema_version int not null) TYPE=InnoDB;
|
||||
|
||||
insert into ttrss_version values (61);
|
||||
insert into ttrss_version values (62);
|
||||
|
||||
create table ttrss_enclosures (id serial not null primary key,
|
||||
content_url text not null,
|
||||
|
@ -381,6 +381,14 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
|
|||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_FEEDLIST', 1, 'false', '', 1);
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_ENABLE_CATS', 1, 'false', '', 1);
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_SHOW_IMAGES', 1, 'false', '', 1);
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_HIDE_READ', 1, 'false', '', 1);
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_SORT_FEEDS_UNREAD', 1, 'false', '', 1);
|
||||
|
||||
create table ttrss_user_prefs (
|
||||
owner_uid integer not null,
|
||||
pref_name varchar(250),
|
||||
|
|
|
@ -210,7 +210,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
|
|||
|
||||
create table ttrss_version (schema_version int not null);
|
||||
|
||||
insert into ttrss_version values (61);
|
||||
insert into ttrss_version values (62);
|
||||
|
||||
create table ttrss_enclosures (id serial not null primary key,
|
||||
content_url text not null,
|
||||
|
@ -347,6 +347,14 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
|
|||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_FEEDLIST', 1, 'false', '', 1);
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_ENABLE_CATS', 1, 'false', '', 1);
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_SHOW_IMAGES', 1, 'false', '', 1);
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_HIDE_READ', 1, 'false', '', 1);
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_SORT_FEEDS_UNREAD', 1, 'false', '', 1);
|
||||
|
||||
create table ttrss_user_prefs (
|
||||
owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
|
||||
pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,
|
||||
|
|
Loading…
Reference in New Issue