rpc/sendEmail: use JSON
This commit is contained in:
parent
0fe841efb9
commit
48efad70de
2 changed files with 11 additions and 13 deletions
|
@ -668,23 +668,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subop == "catchupFeed") {
|
if ($subop == "catchupFeed") {
|
||||||
|
|
||||||
$feed_id = db_escape_string($_REQUEST['feed_id']);
|
$feed_id = db_escape_string($_REQUEST['feed_id']);
|
||||||
$is_cat = db_escape_string($_REQUEST['is_cat']);
|
$is_cat = db_escape_string($_REQUEST['is_cat']);
|
||||||
|
|
||||||
print "<rpc-reply>";
|
|
||||||
|
|
||||||
catchup_feed($link, $feed_id, $is_cat);
|
catchup_feed($link, $feed_id, $is_cat);
|
||||||
|
|
||||||
print "</rpc-reply>";
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subop == "sendEmail") {
|
if ($subop == "sendEmail") {
|
||||||
|
header("Content-Type: text/plain");
|
||||||
|
|
||||||
$secretkey = $_REQUEST['secretkey'];
|
$secretkey = $_REQUEST['secretkey'];
|
||||||
|
|
||||||
print "<rpc-reply>";
|
$reply = array();
|
||||||
|
|
||||||
if (DIGEST_ENABLE && $_SESSION['email_secretkey'] &&
|
if (DIGEST_ENABLE && $_SESSION['email_secretkey'] &&
|
||||||
$secretkey == $_SESSION['email_secretkey']) {
|
$secretkey == $_SESSION['email_secretkey']) {
|
||||||
|
@ -724,18 +721,17 @@
|
||||||
$rc = $mail->Send();
|
$rc = $mail->Send();
|
||||||
|
|
||||||
if (!$rc) {
|
if (!$rc) {
|
||||||
print "<error><![CDATA[" . $mail->ErrorInfo . "]]></error>";
|
$reply['error'] = $mail->ErrorInfo;
|
||||||
} else {
|
} else {
|
||||||
save_email_address($link, db_escape_string($destination));
|
save_email_address($link, db_escape_string($destination));
|
||||||
print "<message>UPDATE_COUNTERS</message>";
|
$reply['message'] = "UPDATE_COUNTERS";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
print "<error>Not authorized.</error>";
|
$reply['error'] = "Not authorized.";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</rpc-reply>";
|
print json_encode($reply);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1842,11 +1842,13 @@ function emailArticle(id) {
|
||||||
new Ajax.Request("backend.php", {
|
new Ajax.Request("backend.php", {
|
||||||
parameters: dojo.objectToQuery(this.attr('value')),
|
parameters: dojo.objectToQuery(this.attr('value')),
|
||||||
onComplete: function(transport) {
|
onComplete: function(transport) {
|
||||||
|
|
||||||
|
var reply = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
var error = transport.responseXML.getElementsByTagName('error')[0];
|
var error = reply['error'];
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
alert(__('Error sending email:') + ' ' + error.firstChild.nodeValue);
|
alert(__('Error sending email:') + ' ' + error);
|
||||||
} else {
|
} else {
|
||||||
notify_info('Your message has been sent.');
|
notify_info('Your message has been sent.');
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
|
|
Loading…
Reference in a new issue