diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 8b4fb04c7..2ff9a6312 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 0671944d3..c57b46f35 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 c13f0e0d4..5c7131d2f 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, });