diff --git a/html/ajax_misc.php b/html/ajax_misc.php index ca892230b..3e5d09b57 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -49,6 +49,20 @@ require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php'; require_once NOALYSS_INCLUDE.'/lib/progress_bar.class.php'; $http=new HttpInput(); +/* we ask a dg box for disconnecting */ +if ($http->request('op',"string","") == 'disconnect') { + ajax_disconnected("reconnect_bx"); + return ; +} + +/** + * if not connected, session is expired then exit with a message NOCONX + */ +if ( ! isset($_SESSION[SESSION_KEY."g_user"])) { + echo "NOCONX"; + die(); +} + mb_internal_encoding("UTF-8"); $var = array( 'op'); @@ -71,7 +85,7 @@ if ( ! isset($_REQUEST['gDossier'])) { if ($cont != 0) exit(); extract($_REQUEST, EXTR_SKIP ); -if ( isset($div)) ajax_disconnected($div); + global $g_user, $cn, $g_parameter; // // If database id == 0 then we are not connected to a folder diff --git a/html/fid.php b/html/fid.php index 471a08de9..6dc6ae940 100644 --- a/html/fid.php +++ b/html/fid.php @@ -38,6 +38,14 @@ require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE.'/lib/user_common.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; +/** + * if not connected, session is expired then exit with a message NOCONX + */ +if ( ! isset($_SESSION[SESSION_KEY."g_user"])) { + echo "NOCONX"; + die(); +} + $gDossier=dossier::id(); require_once('class/user.class.php'); diff --git a/html/fid_card.php b/html/fid_card.php index 0e16ef732..57f783535 100644 --- a/html/fid_card.php +++ b/html/fid_card.php @@ -40,6 +40,13 @@ require_once '../include/constant.php'; require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; +/** + * if not connected, session is expired then exit with a message NOCONX + */ +if ( ! isset($_SESSION[SESSION_KEY."g_user"])) { + echo "NOCONX"; + die(); +} $http=new HttpInput(); diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 0c68c4e2f..42d5f9ca5 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -932,6 +932,7 @@ function modifyOperation(p_value, dossier) parameters: querystring, onFailure: error_box, onSuccess: function (xml, txt) { + if ( xml.responseText === 'NOCONX') { reconnect();return;} var popup = {'id': id_div, 'cssclass': 'inner_box' , 'html': "", 'drag': false}; remove_waiting_box(); diff --git a/html/js/ajax_fiche.js b/html/js/ajax_fiche.js index e20f84921..b9b7f7c4e 100644 --- a/html/js/ajax_fiche.js +++ b/html/js/ajax_fiche.js @@ -151,6 +151,8 @@ function ajaxFid(p_ctl) */ function successFid(request,json) { + if (request.responseText === 'NOCONX') { reconnect();return;} + var answer=request.responseText.evalJSON(true); var flabel=answer.flabel; if ( answer.answer=='nok' ) @@ -226,14 +228,14 @@ function ajax_success_saldo(request,json) * \param ctl : id of the div to show * \param page */ -function _saajax_card(p_dossier,f_id,p_operation,ctl,page) -{ - $(ctl).show(); - var queryString="gDossier="+p_dossier+"&f_id="+f_id+"&op="+p_operation+"&p="+page+'&ctl='+ctl; - var action = new Ajax.Request( - "ajax_card.php" , { method:'get', parameters:queryString,onFailure:ajax_get_failure,onSuccess:ajax_get_success} - ); -} +//function _saajax_card(p_dossier,f_id,p_operation,ctl,page) +//{ +// $(ctl).show(); +// var queryString="gDossier="+p_dossier+"&f_id="+f_id+"&op="+p_operation+"&p="+page+'&ctl='+ctl; +// var action = new Ajax.Request( +// "ajax_card.php" , { method:'get', parameters:queryString,onFailure:ajax_get_failure,onSuccess:ajax_get_success} +// ); +//} /*!\brief callback function for ajax_get when successuf */ function ajax_get_success(request,json) diff --git a/html/js/card.js b/html/js/card.js index 735f45367..7142cff65 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -41,6 +41,9 @@ function boxsearch_card(p_dossier) onFailure:ajax_misc_failure, onSuccess:function(req){ remove_waiting_box(); + if (req.responseText == 'NOCONX') { + reconnect(); + } var y=posY+15; var div_style="left:10%;width:80%;"+";top:"+y+"px"; add_div({id:'boxsearch_card_div',cssclass:'inner_box',html:loading(),style:div_style,drag:true}); @@ -433,6 +436,7 @@ function result_card_search(req) { remove_waiting_box(); + if ( req.responseText == 'NOCONX') { reconnect();return;} var answer=req.responseXML; var a=answer.getElementsByTagName('ctl'); if ( a.length == 0 ) @@ -648,6 +652,7 @@ function successFill_ipopcard(req,json) { try { + if (req.responseText=='NOCONX') { reconnect();return; } var answer=req.responseXML; var a=answer.getElementsByTagName('ctl'); var html=answer.getElementsByTagName('code'); @@ -704,9 +709,9 @@ function select_card_type(obj) var str_style="top:"+sx+"px;height:auto"; waiting_box(); - var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':"",'drag':false}; + var popup={'id': "content",'cssclass':'inner_box','style':str_style,'html':"",'drag':false}; - add_div(popup); + var queryString='gDossier='+dossier; queryString+='&ctl='+content; @@ -746,6 +751,8 @@ function select_card_type(obj) parameters:queryString, onFailure:errorFid, onSuccess:function(req) { + if (req.responseText=='NOCONX') { reconnect(); return;} + add_div(popup); // Get all the category, var answer=req.responseXML.getElementsByTagName("fiche_cat_item"); if (answer.length == 0) { diff --git a/html/js/gestion.js b/html/js/gestion.js index d25a6e4ff..835657097 100644 --- a/html/js/gestion.js +++ b/html/js/gestion.js @@ -309,6 +309,7 @@ function action_add(p_dossier) { method:'get', parameters : {gDossier:p_dossier,'op':'action_add'}, onSuccess : function(p_xml, p_text) { + if (p_xml.responseText === 'NOCONX') { reconnect();return;} remove_waiting_box(); add_div({id: 'action_add_div', style:"top:1%;width:80%;left:10%" , diff --git a/html/js/managetable.js b/html/js/managetable.js index 902816ebe..75ddacfa8 100644 --- a/html/js/managetable.js +++ b/html/js/managetable.js @@ -192,6 +192,7 @@ var ManageTable = function (p_table_name) */ this.parseXML = function (req) { try { + if (req.responseText==='NOCONX') { reconnect();throw new Error("NOCONX") ;} var xml = req.responseXML; var status = xml.getElementsByTagName("status"); var ctl = xml.getElementsByTagName("ctl"); diff --git a/html/js/noalyss_script.js b/html/js/noalyss_script.js index a4dc33daf..1a8cfc22f 100644 --- a/html/js/noalyss_script.js +++ b/html/js/noalyss_script.js @@ -895,6 +895,7 @@ function show_ledger_choice(json_obj) onFailure: ajax_misc_failure, onSuccess: function (req, json) { try { + if ( req.responseText === 'NOCONX') { reconnect();return;} var obj = { id: json_obj.div + 'jrn_search', cssclass: 'inner_box', @@ -1214,7 +1215,7 @@ function save_periode(obj) function fill_box(req) { try { - + if (req.responseText=='NOCONX') { reconnect(); return;} remove_waiting_box(); var answer = req.responseXML; @@ -2118,6 +2119,7 @@ function view_action(ag_id, dossier, modify) onFailure: error_box, onSuccess: function (req) { try { + if (req.responseText === 'NOCONX') { reconnect();return;} remove_waiting_box(); var answer = req.responseXML; var ctl = answer.getElementsByTagName('ctl'); @@ -2879,6 +2881,7 @@ function calendar_zoom(obj) parameters: {"notitle": notitle, "op": 'calendar_zoom', 'from': from, 'gDossier': obj.gDossier, 'in': per_periode, 'out': obj.outdiv, 'distype': obj.distype}, onFailure: ajax_misc_failure, onSuccess: function (req, j) { + if (req.responseText === 'NOCONX') { reconnect();return;} var answer = req.responseXML; var html = answer.getElementsByTagName('html'); if (html.length === 0) @@ -4070,3 +4073,23 @@ function pausecomp(millis) do { curDate = new Date(); } while(curDate-date < millis); } +/** + * @brief propose to reconnect + * @returns {undefined} + */ +function reconnect(){ + remove_waiting_box(); + new Ajax.Request('ajax_misc.php',{ + method:'get', + parameters:{op:"disconnect"}, + onSuccess:function (req) { + var pos="position:fixed;top:0px;width:95%;height:95%"; + var div= add_div({ + 'id':"reconnect_bx", + cssclass:"inner_box", + style:pos + }); + div.innerHTML=req.responseText; + } + }); +} \ No newline at end of file diff --git a/html/js/todo_list.js b/html/js/todo_list.js index f5fdaca5d..c22eb30ea 100644 --- a/html/js/todo_list.js +++ b/html/js/todo_list.js @@ -45,6 +45,7 @@ function todo_list_show(p_id) onFailure: todo_list_show_error, onSuccess: function (req) { + if ( req.responseText === 'NOCONX') { reconnect();return;} try { var todo_div=create_div({id:'todo_list_div'+p_id,cssclass:'add_todo_list'}); diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php index d4acd9d93..57c0d64ed 100644 --- a/include/ajax/ajax_card.php +++ b/include/ajax/ajax_card.php @@ -83,10 +83,7 @@ extract($_REQUEST, EXTR_SKIP ); if ( $cont != 0 ) exit(); set_language(); -/* - *echo a warning if disconnected - */ -ajax_disconnected($_REQUEST['ctl']); + $http=new HttpInput(); $cn=Dossier::connect(); global $g_user; diff --git a/include/ajax/ajax_todo_list.php b/include/ajax/ajax_todo_list.php index 0805569dc..7a8c980b2 100644 --- a/include/ajax/ajax_todo_list.php +++ b/include/ajax/ajax_todo_list.php @@ -48,7 +48,7 @@ $g_user=new User($cn); $g_user->check(true); $g_user->check_dossier(Dossier::id(),true); set_language(); -ajax_disconnected('add_todo_list'); + //////////////////////////////////////////////////////////////////////////////// // Display the note //////////////////////////////////////////////////////////////////////////////// diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index d51b0cb3b..046810162 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -896,46 +896,25 @@ function format_date($p_date, $p_from_format = 'YYYY-MM-DD',$p_to_format='DD.MM. * Should a dialog box when you are disconnected from an ajax call * propose to reload or to connect in another tab */ -function ajax_disconnected($div) +function ajax_disconnected($p_div) { - /** - * if $_SESSION[SESSION_KEY.'g_user'] is not set : echo a warning - */ - if (!isset($_SESSION[SESSION_KEY.'g_user'])) - { - $script = 'var a=$("' . $div . '");a.style.height="70%";a.style.width="60%";'; - $script.='a.style.top=posY-20+offsetY;a.style.left=posX+offsetX;'; - $script = create_script($script); - $html = $script; - $html.=Icon_Action::close($div); - $html.='
'; - $html.=h2(_('Données non disponibles'), 'class="title" style="width:auto"'); - $html.=h2(_('Veuillez vous reconnecter soit dans une autre fenêtre soit ' - . ' en cliquant sur le lien'), 'class="error"'); - // Reload button - $reload=new IButton("reload"); - $reload->value=_("Se reconnecter pour revenir ici"); - $reload->class="button"; - $reload->javascript='window.location.reload()'; - // Link to log in another tab - $html.='

'; - $html.=''. - _('Cliquez ici pour vous reconnecter dans une autre page'). - ''; - $html.=$reload->input(); - $html.=HtmlInput::button_close($div); - $html.='

'; - $html = escape_xml($html); - header('Content-type: text/xml; charset=UTF-8'); - echo << - -$div -$html - -EOF; - exit(); - } + + echo HtmlInput::title_box(_("Déconnecté"), $p_div); + echo h2(_('Données non disponibles'), 'class="error" '); + echo h2(_('Veuillez vous reconnecter soit dans une autre fenêtre soit ' + . ' en cliquant sur le lien'), 'class="error"'); + // Reload button + $reload=new IButton("reload"); + $reload->value=_("Se connecter"); + $reload->class="button"; + $reload->javascript='window.location.reload()'; + // Link to log in another tab + echo '

'; + echo $reload->input(); + echo HtmlInput::button_close($p_div); + echo '

'; + + } /**