]> git.wh0rd.org Git - tt-rss.git/commitdiff
add option to sort headlines by feed-specified date (bump schema)
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 10 Nov 2010 10:56:42 +0000 (13:56 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 10 Nov 2010 10:56:42 +0000 (13:56 +0300)
backend.php
functions.php
modules/pref-prefs.php
sanity_check.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/versions/mysql/73.sql [new file with mode: 0644]
schema/versions/pgsql/73.sql [new file with mode: 0644]

index 8b1454ad74e2c84c6ff3debaaf7591649f040eb4..5cef094d69f862227f6f8fd3320d1d7e667bcb58 100644 (file)
                
                        $override_order = false;
 
+                       if (get_pref($link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
+                               $date_sort_field = "updated";
+                       } else {
+                               $date_sort_field = "date_entered";
+                       }
+
                        switch ($order_by) {
                                case "date":
                                        if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
-                                               $override_order = "date_entered";
+                                               $override_order = "$date_sort_field";
                                        } else {        
-                                               $override_order = "date_entered DESC";
+                                               $override_order = "$date_sort_field DESC";
                                        }
                                        break;
 
                                case "title":
                                        if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
-                                               $override_order = "title DESC, date_entered";
+                                               $override_order = "title DESC, $date_sort_field";
                                        } else {
-                                               $override_order = "title, date_entered DESC";
+                                               $override_order = "title, $date_sort_field DESC";
                                        }
                                        break;
 
                                case "score":
                                        if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
-                                               $override_order = "score, date_entered";
+                                               $override_order = "score, $date_sort_field";
                                        } else {
-                                               $override_order = "score DESC, date_entered DESC";
+                                               $override_order = "score DESC, $date_sort_field DESC";
                                        }
                                        break;
                        }
index 835398cd6f8fb037cd1072b6bcac2796dbd865d7..a5d3a7cf6667190e1590399fa0423c6606c625d0 100644 (file)
                                $query_strategy_part = "id > 0"; // dumb
                        }
 
+                       if (get_pref($link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
+                               $date_sort_field = "updated";
+                       } else {
+                               $date_sort_field = "date_entered";
+                       }
+
                        if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
-                               $order_by = "date_entered";
+                               $order_by = "$date_sort_field";
                        } else {        
-                               $order_by = "date_entered DESC";
+                               $order_by = "$date_sort_field DESC";
                        }
 
                        if ($view_mode != "noscores") {
 
                if (!$limit) $limit = 30;
 
+               if (get_pref($link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
+                       $date_sort_field = "updated";
+               } else {
+                       $date_sort_field = "date_entered";
+               }
+
                $qfh_ret = queryFeedHeadlines($link, $feed, 
                        $limit, $view_mode, $is_cat, $search, $search_mode, 
-                       $match_on, "date_entered DESC", 0, $owner_uid);
+                       $match_on, "$date_sort_field DESC", 0, $owner_uid);
 
                $result = $qfh_ret[0];
                $feed_title = htmlspecialchars($qfh_ret[1]);
index 5fcb931151a30759b4ddf43e99d5d06c2541b3bf..e291e5c11c7e2c2f6ba5c0fa8c072f1eca57f44a 100644 (file)
@@ -20,7 +20,7 @@
                        "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", 
                        "BLACKLISTED_TAGS", "ENABLE_FEED_ICONS", "ENABLE_API_ACCESS",
                        "UPDATE_POST_ON_CHECKSUM_CHANGE", "DEFAULT_UPDATE_INTERVAL",
-                       "MARK_UNREAD_ON_UPDATE", "USER_TIMEZONE");
+                       "MARK_UNREAD_ON_UPDATE", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE");
 
                if (FORCE_ARTICLE_PURGE != 0) {
                        array_push($prefs_blacklist, "PURGE_OLD_DAYS");
index 20ef276c0dff5e83eca2aa4a3bd0e7b725c0f525..79291ef375a61144fbb201238687169e70eb78e4 100644 (file)
@@ -2,7 +2,7 @@
        require_once "functions.php";
 
        define('EXPECTED_CONFIG_VERSION', 19);
-       define('SCHEMA_VERSION', 72);
+       define('SCHEMA_VERSION', 73);
 
        if (!file_exists("config.php")) {
                print "<b>Fatal Error</b>: You forgot to copy 
index 527957038c9d2c9c0b01a9b34a55ddd2c5261002..e3408238063c0a5fd5a9142ae6bd741272a30222 100644 (file)
@@ -245,7 +245,7 @@ create table ttrss_tags (id integer primary key auto_increment,
 
 create table ttrss_version (schema_version int not null) TYPE=InnoDB DEFAULT CHARSET=UTF8;
 
-insert into ttrss_version values (72);
+insert into ttrss_version values (73);
 
 create table ttrss_enclosures (id integer primary key auto_increment,
        content_url text not null,
@@ -406,6 +406,9 @@ 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('USER_TIMEZONE', 2, 'UTC', 'User timezone', 1);
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'true', 'Sort headlines by feed date',3,
+       'Use feed-specified date to sort headlines instead of local import date.');
+
 create table ttrss_user_prefs (
    owner_uid integer not null,
    pref_name varchar(250),
index 29c82c0d29a885df346c6e553615fb688f43c957..fc12650054a73ab1147ba80441dd70bc70018e9b 100644 (file)
@@ -217,7 +217,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 (72);
+insert into ttrss_version values (73);
 
 create table ttrss_enclosures (id serial not null primary key,
        content_url text not null,
@@ -370,6 +370,9 @@ 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('USER_TIMEZONE', 2, 'UTC', 'User timezone', 1);
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'true', 'Sort headlines by feed date',3,
+       'Use feed-specified date to sort headlines instead of local import date.');
+
 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,
diff --git a/schema/versions/mysql/73.sql b/schema/versions/mysql/73.sql
new file mode 100644 (file)
index 0000000..051578d
--- /dev/null
@@ -0,0 +1,8 @@
+begin;
+
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'true', 'Sort headlines by feed date',3,
+       'Use feed-specified date to sort headlines instead of local import date.');
+
+update ttrss_version set schema_version = 73;
+
+commit;
diff --git a/schema/versions/pgsql/73.sql b/schema/versions/pgsql/73.sql
new file mode 100644 (file)
index 0000000..051578d
--- /dev/null
@@ -0,0 +1,8 @@
+begin;
+
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'true', 'Sort headlines by feed date',3,
+       'Use feed-specified date to sort headlines instead of local import date.');
+
+update ttrss_version set schema_version = 73;
+
+commit;