From: Andrew Dolgov Date: Thu, 11 Sep 2008 06:36:41 +0000 (+0100) Subject: batch feed editor: more work X-Git-Tag: 1.2.27~15 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=b0f015a2eaffbf93e74a9e4f2fd29093d1aee253;p=tt-rss.git batch feed editor: more work --- diff --git a/localized_js.php b/localized_js.php index 23110afd..ee230940 100644 --- a/localized_js.php +++ b/localized_js.php @@ -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( diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index 7a3695da..52202191 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -387,12 +387,10 @@ $feed_ids = db_escape_string($_REQUEST["ids"]); - print "
".__('Batch Feed Editor')."
"; + print "
".__('Multiple Feed Editor')."
"; print "
"; - print "[$feed_ids]
"; - print "
"; print ""; @@ -536,13 +534,14 @@ 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"])); @@ -581,27 +580,101 @@ $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") { diff --git a/prefs.js b/prefs.js index b8422391..72b72fcb 100644 --- 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) {