From 667016673f320d1ff0166dc6dd1788dc5ba92e9a Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Tue, 23 May 2017 14:09:01 +0100 Subject: [PATCH] FIX #5352 sometime mail have status 'BAD' --- apps/maarch_entreprise/js/functions.js | 49 +++++++++++++------------- core/manage_action.php | 9 +++-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/apps/maarch_entreprise/js/functions.js b/apps/maarch_entreprise/js/functions.js index 3b308878609..279c3cdbac4 100755 --- a/apps/maarch_entreprise/js/functions.js +++ b/apps/maarch_entreprise/js/functions.js @@ -1595,28 +1595,30 @@ function action_change_status(path_manage_script, mode_req, res_id_values, table { if(res_id_values != '' && (mode_req == 'mass' || mode_req == 'page') && tablename != '' && id_coll != '') - { - new Ajax.Request(path_manage_script, - { - method:'post', - asynchronous : false, - parameters: { values : res_id_values, - mode : mode_req, - req : 'change_status', - table : tablename, - coll_id : id_coll, - new_status : status - }, - onSuccess: function(answer){ - eval('response='+answer.responseText); - if(response.status == 0 ) { + { + + $j.ajax({ + cache : false, + url : path_manage_script, + type : 'POST', + dataType : 'json', + data: { values : res_id_values, + mode : mode_req, + req : 'change_status', + table : tablename, + coll_id : id_coll, + new_status : status, + }, + success: function(answer) { + + setTimeout(function(){ + if(answer.status == 0 ) { actions_status.values = []; // Status changed } else { try{ - //$('frm_error').updateContent(response.error_txt); // update the error div in the modal form - $('frm_error').innerHTML = response.error_txt; - } + $('frm_error').innerHTML = answer.error_txt; + } catch(e){} } if(page != '' && page != NaN && page && page != null ) { @@ -1648,12 +1650,11 @@ function action_change_status(path_manage_script, mode_req, res_id_values, table } do_nothing = false; - }, - onFailure: function(){ - } - }); - } - return true; + }, 200); + } + }); + } + return true; } /***********************************************************************/ diff --git a/core/manage_action.php b/core/manage_action.php index e91c1180d61..af48fa8dc9b 100644 --- a/core/manage_action.php +++ b/core/manage_action.php @@ -140,8 +140,7 @@ if($_POST['req'] == 'valid_form' && !empty($_POST['action_id']) && isset($_POST[ exit(); } } -elseif(trim($_POST['req']) == 'change_status' && !empty($_POST['values'])&& $_POST['values'] != 'none#' && !empty($_POST['new_status']) && !empty($_POST['table'])) -{ +elseif(trim($_POST['req']) == 'change_status' && !empty($_POST['values']) && !empty($_POST['new_status']) && !empty($_POST['table'])){ $stmt = $db->query("select id from status where id = ?", array($_POST['new_status'])); $lineStatus = $stmt->fetchObject(); if ($lineStatus->id <> '') { @@ -150,7 +149,7 @@ elseif(trim($_POST['req']) == 'change_status' && !empty($_POST['values'])&& $_PO for ($i=0; $i<count($arr_id );$i++) { $arr_id[$i] = str_replace('#', '', $arr_id[$i]); $result .= $arr_id[$i].'#'; - if (trim($_POST['new_status']) <> '') { + if (trim($_POST['new_status']) <> '' && is_numeric($arr_id[$i])) { if ($_POST['table'] == 'folders') { $query_str = "update " . $_POST['table'] . " set status = ? where folders_system_id = ?"; @@ -166,10 +165,10 @@ elseif(trim($_POST['req']) == 'change_status' && !empty($_POST['values'])&& $_PO } } } - echo "{status : 0, error_txt : '".addslashes(_STATUS_UPDATED.' : '.functions::xssafe($_POST['new_status']))."'}"; + echo json_encode(['status' => 0, 'error_txt' => _STATUS_UPDATED.' : '.functions::xssafe($_POST['new_status']) ]); exit(); } else { - echo "{status : 0, error_txt : '".addslashes(_STATUS_NOT_EXISTS.' : '.functions::xssafe($_POST['new_status']))."'}"; + echo json_encode(['status' => 0, 'error_txt' => _STATUS_NOT_EXISTS.' : '.functions::xssafe($_POST['new_status']) ]); exit(); } } -- GitLab