batch feed editor: more work

This commit is contained in:
Andrew Dolgov 2008-09-11 07:36:41 +01:00
parent 758e1c4ad9
commit b0f015a2ea
3 changed files with 113 additions and 28 deletions

View File

@ -141,8 +141,8 @@ print T_js_decl("Rescoring articles...");
print T_js_decl("Reset category order?"); print T_js_decl("Reset category order?");
print T_js_decl("Category reordering enabled"); print T_js_decl("Category reordering enabled");
print T_js_decl("Category reordering disabled"); print T_js_decl("Category reordering disabled");
#print T_js_decl( print T_js_decl("Save changes to selected feeds?");
#print T_js_decl( print T_js_decl("Saving feeds...");
#print T_js_decl( #print T_js_decl(
#print T_js_decl( #print T_js_decl(
#print T_js_decl( #print T_js_decl(

View File

@ -387,12 +387,10 @@
$feed_ids = db_escape_string($_REQUEST["ids"]); $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 "<div class=\"infoBoxContents\">";
print "[$feed_ids]<br/>";
print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">"; print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">";
print "<input type=\"hidden\" name=\"ids\" value=\"$feed_ids\">"; print "<input type=\"hidden\" name=\"ids\" value=\"$feed_ids\">";
@ -536,13 +534,14 @@
return; return;
} }
if ($subop == "editSave") { if ($subop == "editSave" || $subop == "batchEditSave") {
$feed_title = db_escape_string(trim($_POST["title"])); $feed_title = db_escape_string(trim($_POST["title"]));
$feed_link = db_escape_string(trim($_POST["feed_url"])); $feed_link = db_escape_string(trim($_POST["feed_url"]));
$upd_intl = db_escape_string($_POST["update_interval"]); $upd_intl = db_escape_string($_POST["update_interval"]);
$purge_intl = db_escape_string($_POST["purge_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"]); $cat_id = db_escape_string($_POST["cat_id"]);
$auth_login = db_escape_string(trim($_POST["auth_login"])); $auth_login = db_escape_string(trim($_POST["auth_login"]));
$auth_pass = db_escape_string(trim($_POST["auth_pass"])); $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
@ -581,27 +580,101 @@
$cache_images_qpart = ""; $cache_images_qpart = "";
} }
$result = db_query($link, "UPDATE ttrss_feeds SET if ($subop == "editSave") {
$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 (get_pref($link, 'ENABLE_FEED_CATS')) {
# update linked feed categories
$result = db_query($link, "UPDATE ttrss_feeds SET $result = db_query($link, "UPDATE ttrss_feeds SET
$category_qpart_nocomma WHERE parent_feed = '$feed_id' AND $category_qpart $parent_qpart,
owner_uid = " . $_SESSION["uid"]); 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"]);
}
} 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") { if ($subop == "remove") {

View File

@ -2250,9 +2250,21 @@ function feedsEditSave() {
return 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; return false;
} catch (e) { } catch (e) {