]> git.wh0rd.org - tt-rss.git/commitdiff
allow adding/removing labels from frontend
authorAndrew Dolgov <fox@bah.spb.su>
Sun, 18 Jan 2009 14:36:50 +0000 (15:36 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sun, 18 Jan 2009 14:36:50 +0000 (15:36 +0100)
functions.php
modules/pref-feeds.php
modules/pref-labels.php
tt-rss.js
tt-rss.php

index 5bcfa3e35f35350aaa58a401590ad7f2fac3a026..1d5210677d7bd3e4dfb24ad49ed94e926b7aea87 100644 (file)
                                (label_id, article_id) VALUES ('$label_id', '$id')");
                }
        }
+
+       function label_remove($link, $id, $owner_uid) {
+
+               db_query($link, "BEGIN");
+
+               $result = db_query($link, "SELECT caption FROM ttrss_labels2
+                       WHERE id = '$id'");
+
+               $caption = db_fetch_result($result, 0, "caption");
+
+               $result = db_query($link, "DELETE FROM ttrss_labels2 WHERE id = '$id'
+                       AND owner_uid = " . $_SESSION["uid"]);
+
+               if (db_affected_rows($link, $result) != 0 && $caption) {
+
+                       /* Disable filters that reference label being removed */
+       
+                       db_query($link, "UPDATE ttrss_filters SET
+                               enabled = false WHERE action_param = '$caption'
+                                       AND action_id = 7
+                                       AND owner_uid = " . $_SESSION["uid"]);
+                       }
+
+               db_query($link, "COMMIT");
+       }
 ?>
index ee4e4d1f8f1203093a9971f709c4e7f69ad3a227..8b715e48f87ae04d0588aa828bed0d47d1898c25 100644 (file)
                                        if (file_exists($icons_dir . "/$id.ico")) {
                                                unlink($icons_dir . "/$id.ico");
                                        }
+                               } else {
+                                       label_remove($link, -11-$id, $_SESSION["uid"]);
                                }
                        }
                }
index 797d2de3f5fcb142d20f891410cd68496b46ceb1..c645b12a1e0853d9cfc47aff5b1994162fa20899 100644 (file)
 
                        $ids = split(",", db_escape_string($_GET["ids"]));
 
-                       db_query($link, "BEGIN");
-
                        foreach ($ids as $id) {
-                               $result = db_query($link, "SELECT caption FROM ttrss_labels2
-                                       WHERE id = '$id'");
-
-                               $caption = db_fetch_result($result, 0, "caption");
-
-                               $result = db_query($link, "DELETE FROM ttrss_labels2 WHERE id = '$id'
-                                       AND owner_uid = " . $_SESSION["uid"]);
-
-                               if (db_affected_rows($link, $result) != 0 && $caption) {
-
-                                               /* Disable filters that reference label being removed */
-
-                                               db_query($link, "UPDATE ttrss_filters SET
-                                                       enabled = false WHERE action_param = '$caption'
-                                                       AND action_id = 7
-                                                       AND owner_uid = " . $_SESSION["uid"]);
-                               }
+                               label_remove($link, $id, $_SESSION["uid"]);
                        }
 
-                       db_query($link, "COMMIT");
-
                }
 
                if ($subop == "add") {
index fba1158f0d4f06e2cb88fc8b082d6761692d98d0..9757639b3345a27b68e59952edc1349e34a644d5 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -562,11 +562,6 @@ function quickMenuGo(opid) {
                                return;
                        }       
 
-                       if (actid <= 0) {
-                               alert(__("You can't unsubscribe from this kind of feed."));
-                               return;
-                       }       
-
                        if (!actid) {
                                alert(__("Please select some feed first."));
                                return;
@@ -627,6 +622,10 @@ function quickMenuGo(opid) {
                        displayDlg("quickAddFilter", getActiveFeedId());
                }
 
+               if (opid == "qmcAddLabel") {
+                       addLabel();
+               }
+
                if (opid == "qmcRescoreFeed") {
                        rescoreCurrentFeed();
                }
@@ -1391,3 +1390,35 @@ function hotkey_handler(e) {
 function feedsSortByUnread() {
        return feeds_sort_by_unread;
 }
+
+function addLabel() {
+
+       try {
+
+               var caption = prompt(__("Please enter label caption:"), "");
+
+               if (caption != undefined) {
+       
+                       if (caption == "") {
+                               alert(__("Can't create label: missing caption."));
+                               return false;
+                       }
+
+                       var query = "backend.php?op=pref-labels&subop=add&caption=" + 
+                               param_escape(caption);
+
+                       notify_progress("Loading, please wait...", true);
+
+                       new Ajax.Request(query, {
+                               onComplete: function(transport) { 
+                                       updateFeedList();
+                       } });
+
+               }
+
+       } catch (e) {
+               exception_error("addLabel", e);
+       }
+}
+
+
index 6e3d19a293f1f0040854f4bef916c2fe0b9871d7..3454a3484c66d377cb4828a8d680436d81281375 100644 (file)
@@ -160,6 +160,8 @@ window.onload = init;
                                        <option value="qmcShowOnlyUnread"><?php echo __('&nbsp;&nbsp;(Un)hide read feeds') ?></option>
                                        <option disabled="disabled">--------</option>
                                        <option style="color : #5050aa" disabled="disabled"><?php echo __('Other actions:') ?></option>                         
+
+                                       <option value="qmcAddLabel"><?php echo __('&nbsp;&nbsp;Create label') ?></option>
                                        <option value="qmcAddFilter"><?php echo __('&nbsp;&nbsp;Create filter') ?></option>
                                        <option value="qmcResetUI"><?php echo __('&nbsp;&nbsp;Reset UI layout') ?></option>
                                        <option value="qmcResetCats"><?php echo __('&nbsp;&nbsp;Reset category order') ?></option>