]> git.wh0rd.org Git - tt-rss.git/commitdiff
rpc/sendEmail: use JSON
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 29 Nov 2010 13:26:09 +0000 (16:26 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 29 Nov 2010 13:26:09 +0000 (16:26 +0300)
modules/backend-rpc.php
viewfeed.js

index fe4b6d302ad71b7a1d9be7ab84800edbabd78af9..d494cab415b235989f14babef2d4165a87e1d0c7 100644 (file)
                }
 
                if ($subop == "catchupFeed") {
-
                        $feed_id = db_escape_string($_REQUEST['feed_id']);
                        $is_cat = db_escape_string($_REQUEST['is_cat']);
 
-                       print "<rpc-reply>";
-
                        catchup_feed($link, $feed_id, $is_cat);
 
-                       print "</rpc-reply>";
-
                        return;
                }
 
                if ($subop == "sendEmail") {
+                       header("Content-Type: text/plain");
+
                        $secretkey = $_REQUEST['secretkey'];
 
-                       print "<rpc-reply>";
+                       $reply = array();
 
                        if (DIGEST_ENABLE && $_SESSION['email_secretkey'] && 
                                                $secretkey == $_SESSION['email_secretkey']) {
                                $rc = $mail->Send();
 
                                if (!$rc) {
-                                       print "<error><![CDATA[" . $mail->ErrorInfo . "]]></error>";
+                                       $reply['error'] =  $mail->ErrorInfo;
                                } else {
                                        save_email_address($link, db_escape_string($destination));
-                                       print "<message>UPDATE_COUNTERS</message>";
+                                       $reply['message'] = "UPDATE_COUNTERS";
                                }
 
                        } else {
-                               print "<error>Not authorized.</error>";
+                               $reply['error'] = "Not authorized.";
                        }
 
-                       print "</rpc-reply>";
-
+                       print json_encode($reply);
                        return;
                }
 
index 7919fe35624a13499a9988c807cec1914aa07c89..0823ed321956ce46d417b05d7be2b33bc68e4c85 100644 (file)
@@ -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();