]> git.wh0rd.org Git - tt-rss.git/commitdiff
optimize mark selected function
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 19 Sep 2006 04:16:42 +0000 (05:16 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 19 Sep 2006 04:16:42 +0000 (05:16 +0100)
backend-rpc.php
functions.php

index 6de87aa840513f953c247123c2e158f16be1c1b0..92fe23468b71813d99ff5b5ce8d99794b8fdc182 100644 (file)
                if ($subop == "markSelected") {
 
                        $ids = split(",", db_escape_string($_GET["ids"]));
-
                        $cmode = sprintf("%d", $_GET["cmode"]);
 
-                       foreach ($ids as $id) {
-
-                               if ($cmode == 0) {
-                                       db_query($link, "UPDATE ttrss_user_entries SET 
-                                       marked = false
-                                       WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
-                               } else if ($cmode == 1) {
-                                       db_query($link, "UPDATE ttrss_user_entries SET 
-                                       marked = true
-                                       WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
-                               } else {
-                                       db_query($link, "UPDATE ttrss_user_entries SET 
-                                       marked = NOT marked
-                                       WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
-                               }
-                       }
+                       markArticlesById($link, $ids, $cmode);
+
                        print "<rpc-reply>";
                        print "<counters>";
                        getAllCounters($link);
index bb80cac57232ab90fe3657038116aad0515a0532..600a776c6394cd1e5a1bb5cb79dc3afd7dcb16aa 100644 (file)
                }
        }
 
+       function markArticlesById($link, $ids, $cmode) {
+
+               $tmp_ids = array();
+
+               foreach ($ids as $id) {
+                       array_push($tmp_ids, "ref_id = '$id'");
+               }
+
+               $ids_qpart = join(" OR ", $tmp_ids);
+
+               if ($cmode == 0) {
+                       db_query($link, "UPDATE ttrss_user_entries SET 
+                       marked = false,last_read = NOW()
+                       WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
+               } else if ($cmode == 1) {
+                       db_query($link, "UPDATE ttrss_user_entries SET 
+                       marked = true
+                       WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
+               } else {
+                       db_query($link, "UPDATE ttrss_user_entries SET 
+                       marked = NOT marked,last_read = NOW()
+                       WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
+               }
+       }
+
        function catchupArticlesById($link, $ids, $cmode) {
 
                $tmp_ids = array();