From f0a0c1ff3d81f8a58459ea500968748d268a6e91 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 18 Dec 2009 13:01:02 +0300 Subject: [PATCH] mobile: add preferences --- mobile/backend.php | 6 +++ mobile/functions.php | 95 ++++++++++++++++++++++++++++++-------------- mobile/index.php | 2 +- mobile/mobile.js | 19 +++++++++ mobile/prefs.php | 43 ++++++++++++++++++++ 5 files changed, 134 insertions(+), 31 deletions(-) create mode 100644 mobile/prefs.php diff --git a/mobile/backend.php b/mobile/backend.php index c6b75c51b..85018c580 100644 --- a/mobile/backend.php +++ b/mobile/backend.php @@ -35,6 +35,12 @@ publishArticlesById($link, array($id), $cmode); break; + case "setPref": + $id = db_escape_string($_REQUEST["id"]); + $value = db_escape_string($_REQUEST["to"]); + mobile_set_pref($link, $id, $value); + print_r($_SESSION); + break; default: print json_encode(array("error", "UNKNOWN_METHOD")); break; diff --git a/mobile/functions.php b/mobile/functions.php index 1806e0eda..ff0510dcd 100644 --- a/mobile/functions.php +++ b/mobile/functions.php @@ -1,6 +1,21 @@ '; + print '"; @@ -67,7 +91,13 @@ } else { $cat_query = "cat_id IS NULL"; } - + + if (mobile_get_pref($link, "SORT_FEEDS_UNREAD")) { + $order_by = "unread DESC, title"; + } else { + $order_by = "title"; + } + $result = db_query($link, "SELECT id, title, (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries @@ -80,7 +110,7 @@ ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL AND $cat_query - ORDER BY unread DESC,title"); + ORDER BY $order_by"); $title = getCategoryTitle($link, $cat_id); @@ -107,10 +137,12 @@ } else { $icon_url = "../images/blank_icon.gif"; } - - print "
  • " . - "". - $line["title"] . "
  • "; + + if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) { + print "
  • " . + "". + $line["title"] . "
  • "; + } } print ""; @@ -132,8 +164,10 @@ $class = 'oldItem'; } - print "
  • - $title
  • "; + if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) { + print "
  • + $title
  • "; + } } print ""; @@ -163,9 +197,10 @@ $class = 'oldItem'; } - print "
  • - $title
  • "; - + if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) { + print "
  • + $title
  • "; + } } print ""; } @@ -175,7 +210,8 @@ $owner_uid = $_SESSION["uid"]; - print '