Commit c4aab63b by pupi1985

Mailing now returns JSON

parent 21d10429
...@@ -86,22 +86,19 @@ function qa_recalc_cleanup(elem) ...@@ -86,22 +86,19 @@ function qa_recalc_cleanup(elem)
function qa_mailing_start(noteid, pauseid) function qa_mailing_start(noteid, pauseid)
{ {
qa_ajax_post('mailing', {}, qa_ajax_post(
function(lines) { 'mailing',
if (lines[0] == '1') { {},
document.getElementById(noteid).innerHTML = lines[1]; function (response) {
window.setTimeout(function() { document.getElementById(noteid).innerHTML = response.message;
if (response.continue) {
window.setTimeout(function () {
qa_mailing_start(noteid, pauseid); qa_mailing_start(noteid, pauseid);
}, 1); // don't recurse }, 1); // don't recurse
} else if (lines[0] == '0') {
document.getElementById(noteid).innerHTML = lines[1];
document.getElementById(pauseid).style.display = 'none';
} else { } 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) { ...@@ -30,18 +30,24 @@ if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
qa_mailing_perform_step(); qa_mailing_perform_step();
if ($starttime == time()) if ($starttime == time()) {
sleep(1); // make sure at least one second has passed sleep(1); // make sure at least one second has passed
}
$message = qa_mailing_progress_message(); $message = qa_mailing_progress_message();
if (isset($message)) if (isset($message)) {
$continue = true; $continue = true;
else } else {
$message = qa_lang('admin/mailing_complete'); $message = qa_lang('admin/mailing_complete');
}
} else } else {
$message = qa_lang('admin/no_privileges'); $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