]> git.wh0rd.org Git - tt-rss.git/commitdiff
batch feed editor: more work
authorAndrew Dolgov <fox@madoka.spb.ru>
Thu, 11 Sep 2008 06:36:41 +0000 (07:36 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Thu, 11 Sep 2008 06:36:41 +0000 (07:36 +0100)
localized_js.php
modules/pref-feeds.php
prefs.js

index 23110afd426cddc86bdccf3e7f169d2d6f80b5d7..ee230940ced68f33b72f2a75d83cd3a417d25037 100644 (file)
@@ -141,8 +141,8 @@ print T_js_decl("Rescoring articles...");
 print T_js_decl("Reset category order?");
 print T_js_decl("Category reordering enabled");
 print T_js_decl("Category reordering disabled");
-#print T_js_decl(
-#print T_js_decl(
+print T_js_decl("Save changes to selected feeds?");
+print T_js_decl("Saving feeds...");
 #print T_js_decl(
 #print T_js_decl(
 #print T_js_decl(
index 7a3695da7bf75661004b5d2a00ecf44d03f1d200..5220219177d3aba40316bdf393cf994d6c9359c8 100644 (file)
 
                        $feed_ids = db_escape_string($_REQUEST["ids"]);
 
-                       print "<div id=\"infoBoxTitle\">".__('Batch Feed Editor')."</div>";
+                       print "<div id=\"infoBoxTitle\">".__('Multiple Feed Editor')."</div>";
 
                        print "<div class=\"infoBoxContents\">";
 
-                       print "[$feed_ids]<br/>";
-
                        print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">";   
 
                        print "<input type=\"hidden\" name=\"ids\" value=\"$feed_ids\">";
                        return;
                }
 
-               if ($subop == "editSave") {
+               if ($subop == "editSave" || $subop == "batchEditSave") {
 
                        $feed_title = db_escape_string(trim($_POST["title"]));
                        $feed_link = db_escape_string(trim($_POST["feed_url"]));
                        $upd_intl = db_escape_string($_POST["update_interval"]);
                        $purge_intl = db_escape_string($_POST["purge_interval"]);
-                       $feed_id = db_escape_string($_POST["id"]);
+                       $feed_id = db_escape_string($_POST["id"]); /* editSave */
+                       $feed_ids = db_escape_string($_POST["ids"]); /* batchEditSave */
                        $cat_id = db_escape_string($_POST["cat_id"]);
                        $auth_login = db_escape_string(trim($_POST["auth_login"]));
                        $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
                                $cache_images_qpart = "";
                        }
 
-                       $result = db_query($link, "UPDATE ttrss_feeds SET 
-                               $category_qpart $parent_qpart,
-                               title = '$feed_title', feed_url = '$feed_link',
-                               update_interval = '$upd_intl',
-                               purge_interval = '$purge_intl',
-                               auth_login = '$auth_login',
-                               auth_pass = '$auth_pass',
-                               private = $private,
-                               rtl_content = $rtl_content,
-                               hidden = $hidden,
-                               $cache_images_qpart
-                               include_in_digest = $include_in_digest,
-                               update_method = '$update_method'
-                               WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
+                       if ($subop == "editSave") {
+
+                               $result = db_query($link, "UPDATE ttrss_feeds SET 
+                                       $category_qpart $parent_qpart,
+                                       title = '$feed_title', feed_url = '$feed_link',
+                                       update_interval = '$upd_intl',
+                                       purge_interval = '$purge_intl',
+                                       auth_login = '$auth_login',
+                                       auth_pass = '$auth_pass',
+                                       private = $private,
+                                       rtl_content = $rtl_content,
+                                       hidden = $hidden,
+                                       $cache_images_qpart
+                                       include_in_digest = $include_in_digest,
+                                       update_method = '$update_method'
+                                       WHERE $where_qpart AND owner_uid = " . $_SESSION["uid"]);
 
-                       if (get_pref($link, 'ENABLE_FEED_CATS')) {
-                               # update linked feed categories
-                               $result = db_query($link, "UPDATE ttrss_feeds SET
-                                       $category_qpart_nocomma WHERE parent_feed = '$feed_id' AND
-                                       owner_uid = " . $_SESSION["uid"]);
+                               if (get_pref($link, 'ENABLE_FEED_CATS')) {
+                                       # update linked feed categories
+                                       $result = db_query($link, "UPDATE ttrss_feeds SET
+                                               $category_qpart_nocomma WHERE parent_feed = '$feed_id' AND
+                                               owner_uid = " . $_SESSION["uid"]);
+                               }
+                       } else if ($subop == "batchEditSave") {
+                               $feed_data = array();
+
+                               foreach (array_keys($_POST) as $k) {
+                                       if ($k != "op" && $k != "subop" && $k != "ids") {
+                                               $feed_data[$k] = $_POST[$k];
+                                       }
+                               }
+
+                               db_query($link, "BEGIN");
+
+                               foreach (array_keys($feed_data) as $k) {
+
+                                       $qpart = "";
+
+                                       switch ($k) {
+                                               case "title":                                                   
+                                                       $qpart = "title = '$feed_title'";
+                                                       break;
+
+                                               case "feed_url":
+                                                       $qpart = "feed_url = '$feed_link'";
+                                                       break;
+
+                                               case "update_interval":
+                                                       $qpart = "update_interval = '$upd_intl'";
+                                                       break;
+
+                                               case "purge_interval":
+                                                       $qpart = "purge_interval = '$purge_intl'";
+                                                       break;
+
+                                               case "auth_login":
+                                                       $qpart = "auth_login = '$auth_login'";
+                                                       break;
+
+                                               case "auth_pass":
+                                                       $qpart = "auth_pass = '$auth_pass'";
+                                                       break;
+
+                                               case "private":
+                                                       $qpart = "private = '$private'";
+                                                       break;
+
+                                               case "hidden":
+                                                       $qpart = "hidden = '$hidden'";
+                                                       break;
+
+                                               case "include_in_digest":
+                                                       $qpart = "include_in_digest = '$include_in_digest'";
+                                                       break;
+
+                                               case "update_method":
+                                                       $qpart = "update_method = '$update_method'";
+                                                       break;
+
+                                               case "cat_id":
+                                                       $qpart = $category_qpart_nocomma;
+                                                       break;
+
+                                       }
+
+                                       if ($qpart) {
+                                               print(
+                                                       "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids)
+                                                               AND owner_uid = " . $_SESSION["uid"]);
+                                       }
+                               }
+
+                               db_query($link, "COMMIT");
                        }
+
                }
 
                if ($subop == "remove") {
index b8422391ca8fe9dc3f497d5a2dea33c5cd5d3ddb..72b72fcbac755ecedfd28aa157ca7d754c7d3f9e 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -2250,9 +2250,21 @@ function feedsEditSave() {
                        return
                }
 
-               var query = Form.serialize("batch_edit_feed_form");
+               var ok = confirm(__("Save changes to selected feeds?"));
 
-               alert(query);
+               if (ok) {
+
+                       var query = Form.serialize("batch_edit_feed_form");
+       
+                       closeInfoBox();
+       
+                       notify_progress("Saving feeds...");
+       
+                       xmlhttp.open("POST", "backend.php", true);
+                       xmlhttp.onreadystatechange=feedlist_callback;
+                       xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+                       xmlhttp.send(query);
+               }
 
                return false;
        } catch (e) {