window.Connexion={getHashKey: websFunc('getHashKey'),login: websFunc('login'),loginRPX: websFunc('loginRPX'),getConnected: websFunc('getConnected'),getData: websFunc('getData'),logout: websFunc('logout'),root: null,serviceUrl: "connexion"};/* Module used to load informations about the connected user */ (function() { function updateData(ok, data, errMessage) { try { if(ok) { if(!window.sCredentials || data[0]!=window.sCredentials[0]) { window.sCredentials = data; lastId=null; lastPassword=null; sessionStorage.setItem("sCredentials",JSON.stringify(data)); raiseCustomEvent('connectedUserChanged',{}); } } else { switch(data) { case 1102: // Licence Dialogs.showMessage("Ceci est votre première connexion sur le site web. Vous devez accepter la licence avant de continuer. Vous allez être redirigé vers le site ShareSpace après fermeture de cette boite de dialogue.","Première connexion",function(){ location.href = "http://sharespace.saint-boni.be"; }); return; case 1105: // Messages var message = errMessage.split("|") // [id, "nom", "date", "sujet", "message"] message[0] = message[0].split(";")[1]; Dialogs.open('Message important', [ {type:'x-text',value:'Veuillez lire ce message important avant de continuer:'}, //{type:'x-html',value:'De: '+unescape(message[1])+'
Le: '+unescape(message[2])+'
SUJET: '+unescape(message[3])+'
'}, //{type:'x-text',value:'Le: '+unescape(message[2])}, //{type:'x-text',value:'SUJET: '+unescape(message[3])}, {type:'x-html',value:'
'+unescape(message[1])+', le '+unescape(message[2])+'
Concerne: '+unescape(message[3])+'
'+unescape(message[4])+'
'} ],[ {type:'button',value:'Annuler',onclick:function(){Dialogs.close();}}, {type:'button',value:'Continuer',onclick:function(){Connexion.login(lastId,SHA_ENCODE(lastPassword),parseInt(message[0]),updateData); Dialogs.close();}} ]); return; case 1104: // special check for session revival if(cookies.getItem("PHPSESSID")!=lastSessID) { login(lastId,lastPassword); return; } default: Dialogs.showMessage(errMessage+" (Erreur "+data+")", "Connexion impossible"); return; } } } catch (ex) {} } function fetchData() { Connexion.getData(updateData); } var lastId, lastPassword, lastSessID; function login(id, password) { lastId=id; lastPassword=password; lastSessID=cookies.getItem("PHPSESSID"); Connexion.login(lastId,SHA_ENCODE(lastPassword),updateData); } function logout() { lastId=null; lastPassword=null; Connexion.logout(); updateData(true,window.sCredentialsManager.defaultValue); } window.sCredentialsManager = { update: fetchData, // () login: login, // (id,password) logout: logout, // () defaultValue: [null,null,null,0] }; window.sCredentials = window.sCredentialsManager.defaultValue; // if cache is empty if(!sessionStorage.getItem("sCredentials")) { // fetch from server using XMLHTTPRequest fetchData(); } else { // else, read data from cache (which takes less time) try { window.sCredentials = JSON.parse(sessionStorage.getItem("sCredentials")); raiseCustomEvent('connectedUserChanged',{}); if(!cookies.getItem("PHPSESSID")) { fetchData(); } } catch (ex) { fetchData(); } } // Regulary update connection status (keep session on server) setInterval(fetchData, 30000); })();