Commit c4aab63b by pupi1985

Mailing now returns JSON

parent 21d10429
......@@ -86,22 +86,19 @@ function qa_recalc_cleanup(elem)
function qa_mailing_start(noteid, pauseid)
{
qa_ajax_post('mailing', {},
function(lines) {
if (lines[0] == '1') {
document.getElementById(noteid).innerHTML = lines[1];
window.setTimeout(function() {
qa_ajax_post(
'mailing',
{},
function (response) {
document.getElementById(noteid).innerHTML = response.message;
if (response.continue) {
window.setTimeout(function () {
qa_mailing_start(noteid, pauseid);
}, 1); // don't recurse
} else if (lines[0] == '0') {
document.getElementById(noteid).innerHTML = lines[1];
document.getElementById(pauseid).style.display = 'none';
} else {
qa_ajax_error();
document.getElementById(pauseid).style.display = 'none';
}
}
}, 1
);
}
......
......@@ -30,18 +30,24 @@ if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
qa_mailing_perform_step();
if ($starttime == time())
if ($starttime == time()) {
sleep(1); // make sure at least one second has passed
}
$message = qa_mailing_progress_message();
if (isset($message))
if (isset($message)) {
$continue = true;
else
} else {
$message = qa_lang('admin/mailing_complete');
} else
}
} else {
$message = qa_lang('admin/no_privileges');
}
$response = array(
'continue' => $continue,
'message' => qa_html($message),
);
echo "QA_AJAX_RESPONSE\n" . (int)$continue . "\n" . qa_html($message);
echo json_encode($response);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment