From 48efad70de1a2f0d4e29f0a8896278b82d70bc2e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 29 Nov 2010 16:26:09 +0300 Subject: [PATCH] rpc/sendEmail: use JSON --- modules/backend-rpc.php | 18 +++++++----------- viewfeed.js | 6 ++++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index fe4b6d30..d494cab4 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -668,23 +668,20 @@ } if ($subop == "catchupFeed") { - $feed_id = db_escape_string($_REQUEST['feed_id']); $is_cat = db_escape_string($_REQUEST['is_cat']); - print ""; - catchup_feed($link, $feed_id, $is_cat); - print ""; - return; } if ($subop == "sendEmail") { + header("Content-Type: text/plain"); + $secretkey = $_REQUEST['secretkey']; - print ""; + $reply = array(); if (DIGEST_ENABLE && $_SESSION['email_secretkey'] && $secretkey == $_SESSION['email_secretkey']) { @@ -724,18 +721,17 @@ $rc = $mail->Send(); if (!$rc) { - print "ErrorInfo . "]]>"; + $reply['error'] = $mail->ErrorInfo; } else { save_email_address($link, db_escape_string($destination)); - print "UPDATE_COUNTERS"; + $reply['message'] = "UPDATE_COUNTERS"; } } else { - print "Not authorized."; + $reply['error'] = "Not authorized."; } - print ""; - + print json_encode($reply); return; } diff --git a/viewfeed.js b/viewfeed.js index 7919fe35..0823ed32 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -1842,11 +1842,13 @@ function emailArticle(id) { new Ajax.Request("backend.php", { parameters: dojo.objectToQuery(this.attr('value')), onComplete: function(transport) { + + var reply = JSON.parse(transport.responseText); - var error = transport.responseXML.getElementsByTagName('error')[0]; + var error = reply['error']; if (error) { - alert(__('Error sending email:') + ' ' + error.firstChild.nodeValue); + alert(__('Error sending email:') + ' ' + error); } else { notify_info('Your message has been sent.'); dialog.hide(); -- 2.39.5