]> git.wh0rd.org - tt-rss.git/blobdiff - modules/pref-feeds.php
use POST parameters for frontend requests
[tt-rss.git] / modules / pref-feeds.php
index fae1fbe2fd2a4fc3caeae2165a443803f94f3b5e..4c9ed19a9a959ad7cdffccf5fb55337597ed1f44 100644 (file)
@@ -15,7 +15,7 @@
                $quiet = $_REQUEST["quiet"];
 
                if ($subop == "massSubscribe") {
-                       $ids = split(",", db_escape_string($_GET["ids"]));
+                       $ids = split(",", db_escape_string($_REQUEST["ids"]));
 
                        $subscribed = array();
 
                        
                        print "<div class=\"infoBoxContents\">";
 
-                       $browser_search = db_escape_string($_GET["search"]);
+                       $browser_search = db_escape_string($_REQUEST["search"]);
 
                        //print "<p>".__("Showing top 25 registered feeds, sorted by popularity:")."</p>";
 
                        print "
                                <div style='float : right'>
+                               <img style='display : none' 
+                                       id='feed_browser_spinner' src='images/indicator_white.gif'>
                                <input id=\"feed_browser_search\" size=\"20\" type=\"search\"
                                onfocus=\"javascript:disableHotkeys();\" 
                                onblur=\"javascript:enableHotkeys();\"
                                        } else {
                                                $is_selected = "";
                                        }
+
+                                       $linked_title = truncate_string(htmlspecialchars($tmp_line["title"]), 40);
+
                                        printf("<option $is_selected value='%d'>%s</option>", 
-                                               $tmp_line["id"], $tmp_line["title"]);
+                                               $tmp_line["id"], $linked_title);
                                }
 
                        print "</select>";
 
                        $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login"));
 
-                       print __('Login:') . " ";
+                       print "<table>";
+
+                       print "<tr><td>" . __('Login:') . "</td><td>";
+
                        print "<input size=\"20\" onkeypress=\"return filterCR(event, feedEditSave)\"
                                name=\"auth_login\" value=\"$auth_login\">";
 
-                       print " " . __("Password:") . " ";
+                       print "</tr><tr><td>" . __("Password:") . "</td><td>";
 
                        $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass"));
 
                                onkeypress=\"return filterCR(event, feedEditSave)\"
                                value=\"$auth_pass\">";
 
+                       print "</td></tr></table>";
+
                        print "</div>";
                        print "<div class=\"dlgSec\">".__("Options")."</div>";
                        print "<div class=\"dlgSecCont\">";
                                name=\"include_in_digest\"
                                $checked>&nbsp;<label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
 
+
+                       $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures"));
+
+                       if ($always_display_enclosures) {
+                               $checked = "checked";
+                       } else {
+                               $checked = "";
+                       }
+
+                       print "<br/><input type=\"checkbox\" id=\"always_display_enclosures\" 
+                               name=\"always_display_enclosures\"
+                               $checked>&nbsp;<label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
+
+
                        $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
 
                        if ($cache_images) {
 
                        print "&nbsp;"; batch_edit_cbox("include_in_digest", "include_in_digest_l");
 
+                       print "<br/><input disabled type=\"checkbox\" id=\"always_display_enclosures\" 
+                               name=\"always_display_enclosures\" 
+                               $checked>&nbsp;<label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
+
+                       print "&nbsp;"; batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l");
+
                        print "<br/><input disabled type=\"checkbox\" id=\"cache_images\" 
                                name=\"cache_images\" 
                                $checked>&nbsp;<label class='insensitive' id=\"cache_images_l\" 
                                db_escape_string($_POST["cache_images"]));
                        $update_method = (int) db_escape_string($_POST["update_method"]);
 
+                       $always_display_enclosures = checkbox_to_sql_bool(
+                               db_escape_string($_POST["always_display_enclosures"]));
+
                        if (get_pref($link, 'ENABLE_FEED_CATS')) {                      
                                if ($cat_id && $cat_id != 0) {
                                        $category_qpart = "cat_id = '$cat_id',";
                                        hidden = $hidden,
                                        $cache_images_qpart
                                        include_in_digest = $include_in_digest,
+                                       always_display_enclosures = $always_display_enclosures,
                                        update_method = '$update_method'
                                        WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
 
                                                        $qpart = "include_in_digest = '$include_in_digest'";
                                                        break;
 
+                                               case "always_display_enclosures":
+                                                       $qpart = "always_display_enclosures = '$always_display_enclosures'";
+                                                       break;
+
                                                case "cache_images":
                                                        $qpart = "cache_images = '$cache_images'";
                                                        break;
 
                if ($subop == "remove") {
 
-                       $ids = split(",", db_escape_string($_GET["ids"]));
+                       $ids = split(",", db_escape_string($_REQUEST["ids"]));
 
                        foreach ($ids as $id) {
-
-                               if ($id > 0) {
-
-                                       db_query($link, "DELETE FROM ttrss_feeds 
-                                               WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
-
-                                       $icons_dir = ICONS_DIR;
-                                       
-                                       if (file_exists($icons_dir . "/$id.ico")) {
-                                               unlink($icons_dir . "/$id.ico");
-                                       }
-                               } else {
-                                       label_remove($link, -11-$id, $_SESSION["uid"]);
-                               }
+                               remove_feed($link, $id, $_SESSION["uid"]);
                        }
                }
 
                if ($subop == "clear") {
-                       $id = db_escape_string($_GET["id"]);
+                       $id = db_escape_string($_REQUEST["id"]);
                        clear_feed_articles($link, $id);
                }
 
                if ($subop == "rescore") {
-                       $ids = split(",", db_escape_string($_GET["ids"]));
+                       $ids = split(",", db_escape_string($_REQUEST["ids"]));
 
                        foreach ($ids as $id) {
 
 
                        if (!WEB_DEMO_MODE) {
 
-                               $ids = split(",", db_escape_string($_GET["ids"]));
+                               $ids = split(",", db_escape_string($_REQUEST["ids"]));
 
-                               $cat_id = db_escape_string($_GET["cat_id"]);
+                               $cat_id = db_escape_string($_REQUEST["cat_id"]);
 
                                if ($cat_id == 0) {
                                        $cat_id_qpart = 'NULL';
                        if ($action == "save") {
 
                                $cat_title = db_escape_string(trim($_REQUEST["value"]));
-                               $cat_id = db_escape_string($_GET["cid"]);
+                               $cat_id = db_escape_string($_REQUEST["cid"]);
 
                                db_query($link, "BEGIN");
 
 
                                if (!WEB_DEMO_MODE) {
        
-                                       $feed_cat = db_escape_string(trim($_GET["cat"]));
+                                       $feed_cat = db_escape_string(trim($_REQUEST["cat"]));
        
                                        $result = db_query($link,
                                                "SELECT id FROM ttrss_feed_categories
 
                        if ($action == "remove") {
        
-                               if (!WEB_DEMO_MODE) {
-       
-                                       $ids = split(",", db_escape_string($_GET["ids"]));
-       
-                                       foreach ($ids as $id) {
-       
-                                               db_query($link, "BEGIN");
-       
-                                               $result = db_query($link, 
-                                                       "SELECT count(id) as num_feeds FROM ttrss_feeds 
-                                                               WHERE cat_id = '$id'");
-       
-                                               $num_feeds = db_fetch_result($result, 0, "num_feeds");
+                               $ids = split(",", db_escape_string($_REQUEST["ids"]));
        
-                                               if ($num_feeds == 0) {
-                                                       db_query($link, "DELETE FROM ttrss_feed_categories
-                                                               WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
-                                               } else {
-       
-                                                       print format_warning(__("Unable to delete non empty feed categories."));
-                                                               
-                                               }
-       
-                                               db_query($link, "COMMIT");
-                                       }
+                               foreach ($ids as $id) {
+                                       remove_feed_category($link, $id, $_SESSION["uid"]);
                                }
                        }
 
                                __('Some feeds have update errors (click for details)')."</a>");
                }
 
-               $feed_search = db_escape_string($_GET["search"]);
+               $feed_search = db_escape_string($_REQUEST["search"]);
 
-               if (array_key_exists("search", $_GET)) {
+               if (array_key_exists("search", $_REQUEST)) {
                        $_SESSION["prefs_feed_search"] = $feed_search;
                } else {
                        $feed_search = $_SESSION["prefs_feed_search"];
                                onclick=\"javascript:browseFeeds()\" value=\"".__('More Feeds')."\">";
                }
 
-               $feeds_sort = db_escape_string($_GET["sort"]);
+               $feeds_sort = db_escape_string($_REQUEST["sort"]);
 
                if (!$feeds_sort || $feeds_sort == "undefined") {
                        $feeds_sort = $_SESSION["pref_sort_feeds"];                     
                $_SESSION["pref_sort_feeds"] = $feeds_sort;
 
                if ($feed_search) {
-                       $search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR
-                               UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND";
+
+                       $feed_search = split(" ", $feed_search);
+                       $tokens = array();
+
+                       foreach ($feed_search as $token) {
+
+                               $token = trim($token);
+
+                               array_push($tokens, "(UPPER(F1.title) LIKE UPPER('%$token%') OR
+                                       UPPER(C1.title) LIKE UPPER('%$token%') OR
+                                       UPPER(F1.feed_url) LIKE UPPER('%$token%'))");
+                       }
+
+                       $search_qpart = "(" . join($tokens, " AND ") . ") AND ";
+
                } else {
                        $search_qpart = "";
                }
                $show_last_article_checked = "";
                $show_last_article_qpart = "";
 
-               if ($_GET["slat"] == "true") {
+               if ($_REQUEST["slat"] == "true") {
                        $show_last_article_info = true;
                        $show_last_article_checked = "checked";
                        $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE."(MAX(updated),1,16) FROM ttrss_user_entries,
 
                        print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\">
                                <option value=\"facDefault\" selected>".__('Actions...')."</option>
-                               <option disabled>--------</option>
-                               <option style=\"color : #5050aa\" disabled>".__('Selection:')."</option>
-                               <option value=\"facEdit\">&nbsp;&nbsp;".__('Edit')."</option>";
+                               <optgroup label=\"".__('Selection:')."\">
+                               <option value=\"facEdit\">".__('Edit')."</option>";
 
                        if (FORCE_ARTICLE_PURGE == 0) {
                                print 
-                                       "<option value=\"facPurge\">&nbsp;&nbsp;".__('Manual purge')."</option>";
+                                       "<option value=\"facPurge\">".__('Manual purge')."</option>";
                        }
 
                        print "
-                               <option value=\"facClear\">&nbsp;&nbsp;".__('Clear feed data')."</option>
-                               <option value=\"facRescore\">&nbsp;&nbsp;".__('Rescore articles')."</option>
-                               <option value=\"facUnsubscribe\">&nbsp;&nbsp;".__('Unsubscribe')."</option>";
+                               <option value=\"facClear\">".__('Clear feed data')."</option>
+                               <option value=\"facRescore\">".__('Rescore articles')."</option>
+                               <option value=\"facUnsubscribe\">".__('Unsubscribe')."</option>";
+
+                       print "</optgroup>";
 
                                if (get_pref($link, 'ENABLE_FEED_CATS')) {
 
-                                       print "<option disabled>--------</option>
-                                       <option style=\"color : #5050aa\" disabled>".__('Other:')."</option>
-                                       <option value=\"facEditCats\">&nbsp;&nbsp;".__('Edit categories')."
-                                       </option>";
+                                       print "<optgroup label=\"".__('Other:')."\">
+                                               <option value=\"facEditCats\">".__('Edit categories')."
+                                                       </option>
+                                       </optgroup>";
+
                                }
 
                        print "</select>";
+               } else {
+
+                       print "<p>";
+
+                       if (!$feed_search) { 
+                               print_warning(__("You don't have any subscribed feeds."));
+                       } else {
+                               print_warning(__('No matching feeds found.'));
+                       }
+                       print "</p>";
+
                }
 
                print "<h3>".__('OPML')."</h3>