From 9104a3e65afdb884dd2a6289ac62161d8176c555 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 20 Apr 2011 14:11:15 +0400 Subject: [PATCH] implement instance edit & save --- modules/backend-rpc.php | 7 +++++ modules/pref-instances.php | 64 +++++++++++++++++++++++++++++++++++++- prefs.js | 24 ++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 8b4fb04c..2ff9a631 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -866,6 +866,13 @@ return; } + if ($subop == "genHash") { + $hash = sha1(uniqid(rand(), true)); + + print json_encode(array("hash" => $hash)); + return; + } + print json_encode(array("error" => array("code" => 7, "message" => "Unknown method: $subop"))); } diff --git a/modules/pref-instances.php b/modules/pref-instances.php index 0671944d..c57b46f3 100644 --- a/modules/pref-instances.php +++ b/modules/pref-instances.php @@ -5,8 +5,70 @@ if ($subop == "edit") { - print "TODO: function not implemented."; + $id = db_escape_string($_REQUEST["id"]); + $result = db_query($link, "SELECT * FROM ttrss_linked_instances WHERE + id = '$id'"); + + print ""; + print ""; + print ""; + + print "
".__("Instance")."
"; + + print "
"; + + /* URL */ + + $access_url = htmlspecialchars(db_fetch_result($result, 0, "access_url")); + + print __("URL:") . " "; + + print ""; + + print "
"; + + $access_key = htmlspecialchars(db_fetch_result($result, 0, "access_key")); + + /* Access key */ + + print __("Access key:") . " "; + + print ""; + + print "
"; + + print "
+
+ +
+ +
"; + + return; + } + + if ($subop == "editSave") { + $id = db_escape_string($_REQUEST["id"]); + $access_url = db_escape_string($_REQUEST["access_url"]); + $access_key = db_escape_string($_REQUEST["access_key"]); + + db_query($link, "UPDATE ttrss_linked_instances SET + access_key = '$access_key', access_url = '$access_url' + WHERE id = '$id'"); return; } diff --git a/prefs.js b/prefs.js index c13f0e0d..5c7131d2 100644 --- a/prefs.js +++ b/prefs.js @@ -1810,6 +1810,30 @@ function editInstance(id, event) { id: "instanceEditDlg", title: __("Edit Instance"), style: "width: 600px", + regenKey: function() { + new Ajax.Request("backend.php", { + parameters: "?op=rpc&subop=genHash", + onComplete: function(transport) { + var reply = JSON.parse(transport.responseText); + if (reply) + dijit.byId('instance_edit_key').attr('value', reply.hash); + + } }); + }, + execute: function() { + if (this.validate()) { +// console.warn(dojo.objectToQuery(this.attr('value'))); + + notify_progress('Saving data...', true); + new Ajax.Request("backend.php", { + parameters: dojo.objectToQuery(this.attr('value')), + onComplete: function(transport) { + dialog.hide(); + notify(''); + updateInstanceList(); + } }); + } + }, href: query, }); -- 2.39.2