/** * Uživatelský účet * * Knihovna pro práci s uživatelským ůčtem * * @category Knihovny funkcí * @copyright Copyright (c) 2016 Foxtrot Technologies s.r.o. (www.foxtrot.cz) * @version 3.1, 2017-05-12 * * Instalace * ========= * * 1) Link na CSS a JS v tomto adresáři * 2) Modul modalAlert (pgwModal) * 3) Include userAccount/UAExternalScripts.inc.php v hlavičce načítání * 4) Získat Google project ID * a) https://console.developers.google.com/projectselector/apis/library - dát vytvořit nový projekt a odeslat * b) Vlevo vybrat Credentials => tab OAuth consent screen => vyplnit (je potřeba ikona 120 x 120) => save * c) Vlevo vybrat Credentials => tab Credentials => Create credential => OAuth client ID => Web Apllication => vyplnit; Do JS origins napsat http://localhost a pak všechny domény na kterých aplikace běží => Create * d) Z dialogu opsat client ID a dát jej do google.cfg * 5) Získat ID u FB * a) https://developers.facebook.com/apps - vytvořit novou aplikaci => přidělené ID napsat do fb.cfg * b) V přehledu aplikací https://developers.facebook.com/apps vybrat tuto aplikaci * i) vyplnit detaily a dát zveřejnit (je třeba ikona 1024 x 1024 a 16 x 16) * ii) Nastavení => zabezpečení dát IP adresy * iii) Nastavení => Client OAuth Settings dát redirect URIs (webové adresy) * 6) Získat ID od Microsoftu * a) https://account.live.com/developers/applications/index => Create application (logo 50 x 50 je třeba) * b) Zapsat Client ID do ms.cfg * 7) Upravit text souboru UARegMail.txt a UAReactMail.txt (HTML text), má-li být zasílán registrační email (viz nastavení v dalším bodě) a UALostPsswdMail.txt pro zapomenuté heslo * 8) Provést případnou úpravu nastavení v UA.cfg * 9) Je-li třeba, nadefinovat userPostLogin a userPostLogout funkce * 10) Na hlavní stránce ošetřit zpracování výsledku aktivace (vložením userAccount/UAHandleActivationRes.inc.php) do $(document).ready - hlášku v dokumentu je třeba upravit * 11) Zkopírovat sekci userAccount do locales souborů * * Hooky do aplikace * ================= * * 1) userSpecialUserPostLogin() * 2) userPostLogout() * 3) userPostLogin() * 4) specialUserSaved(id) * 5) userPostInit() * 6) userPostProfileUpdated() * 7) userPostLoginExists() * 8) userPostEmailExists() * 9) userAttribReceived() * 10) userAttribSaved() */ var user = null; $(document).ready(function() { user = new _User(); if(typeof userPostInit === "function" && userPostInit !== null) userPostInit(); }); function _User() { // main object var User = {}; User.appConfig = { registrationCont: null, regCloseRegistrationFunc: null, profileCont: null, profCloseProfileFunc: null, regLoginCtrl: null, regPsswdCtrl: null, regCheckPsswdCtrl: null, regEmailCtrl: null, regPhoneCtrl: null, regNameCtrl: null, regBornCtrl: null, regAddressCtrl: null, regPromoCtrl: null, regGoogleButton: null, regFBButton: null, regMsButton: null, regGoogleButtonIcon: null, regFBButtonIcon: null, regMsButtonIcon: null, regPictureCtrl: null, regPictureTempIdCtrl: null, regPictureFileCtrl: null, regMandCtrls: null, loginCtrl: null, psswdCtrl: null, profileLoginCtrl: null, profilePsswdCtrl: null, profileCheckPsswdCtrl: null, profileEmailCtrl: null, profilePhoneCtrl: null, profileNameCtrl: null, profileBornCtrl: null, profileAddressCtrl: null, profileGoogleButton: null, profileFBButton: null, profileMsButton: null, profileGoogleButtonIcon: null, profileFBButtonIcon: null, profileMsButtonIcon: null, profilePictureCtrl: null, profilePictureTempIdCtrl: null, profilePictureFileCtrl: null, reqActivation: true } User.setAppConfig = function(regCont, regCloseFunc, regLoginCtrl, regPsswdCtrl, regCheckPsswdCtrl, regEmailCtrl, regPhoneCtrl, regNameCtrl, regAddressCtrl, regPromoCtrl, regGoogleButton, regFBButton, regMsButton, regGoogleButtonIcon, regFBButtonIcon, regMsButtonIcon, regPicture, regMandCtrlsArray, loginCtrl, psswdCtrl, regPictureFileCtrl, regPictureTempIdCtrl, profCont, profCloseFunc,profilePictureFileCtrl, profilePictureTempIdCtrl, profileLoginCtrl, profilePsswdCtrl, profileCheckPsswdCtrl, profileEmailCtrl, profilePhoneCtrl, profileNameCtrl, profileAddressCtrl, profileGoogleButton, profileFBButton, profileMsButton, profileGoogleButtonIcon, profileFBButtonIcon, profileMsButtonIcon, profilePicture, profileMandCtrlsArray, regBornCtrl, profileBornCtrl) { User.appConfig = { registrationCont: isVarNonempty(regCont)?regCont:($("#registration_modal_cont").length > 0?"registration_modal_cont":null), regCloseRegistrationFunc: isVarNonempty(regCloseFunc)?regCloseFunc:"user.closeRegistration", profileCont: isVarNonempty(profCont)?profCont:($("#profile_modal_cont").length > 0?"profile_modal_cont":null), profCloseProfileFunc: isVarNonempty(profCloseFunc)?profCloseFunc:"user.closeProfile", regLoginCtrl: isVarNonempty(regLoginCtrl)?regLoginCtrl:($("#registration_login").length > 0?"registration_login":null), regPsswdCtrl: isVarNonempty(regPsswdCtrl)?regPsswdCtrl:($("#registration_psswd").length > 0?"registration_psswd":null), regCheckPsswdCtrl: isVarNonempty(regCheckPsswdCtrl)?regCheckPsswdCtrl:($("#registration_psswd_check").length > 0?"registration_psswd_check":null), regEmailCtrl: isVarNonempty(regEmailCtrl)?regEmailCtrl:($("#registration_email").length > 0?"registration_email":null), regPhoneCtrl: isVarNonempty(regPhoneCtrl)?regPhoneCtrl:($("#registration_phone").length > 0?"registration_phone":null), regNameCtrl: isVarNonempty(regNameCtrl)?regNameCtrl:($("#registration_name").length > 0?"registration_name":null), regBornCtrl: isVarNonempty(regBornCtrl)?regBornCtrl:($("#registration_born").length > 0?"registration_born":null), regAddressCtrl: isVarNonempty(regAddressCtrl)?regAddressCtrl:($("#registration_address").length > 0?"registration_address":null), regPromoCtrl: isVarNonempty(regPromoCtrl)?regPromoCtrl:($("#registration_promo").length > 0?"registration_promo":null), regGoogleButton: isVarNonempty(regGoogleButton)?regGoogleButton:($("#UA_reg_button_google").length > 0?"UA_reg_button_google":null), regMsButton: isVarNonempty(regMsButton)?regMsButton:($("#UA_reg_button_ms").length > 0?"UA_reg_button_ms":null), regFBButton: isVarNonempty(regFBButton)?regFBButton:($("#UA_reg_button_fb").length > 0?"UA_reg_button_fb":null), regGoogleButtonIcon: isVarNonempty(regGoogleButtonIcon)?regGoogleButtonIcon:($("#UA_reg_button_google_icon").length > 0?"UA_reg_button_google_icon":null), regMsButtonIcon: isVarNonempty(regMsButtonIcon)?regMsButtonIcon:($("#UA_reg_button_ms_icon").length > 0?"UA_reg_button_ms_icon":null), regFBButtonIcon: isVarNonempty(regFBButtonIcon)?regFBButtonIcon:($("#UA_reg_button_fb_icon").length > 0?"UA_reg_button_fb_icon":null), regPictureCtrl: isVarNonempty(regPicture)?regPicture:($("#registration_picture").length > 0?"registration_picture":null), regPictureFileCtrl: isVarNonempty(regPictureFileCtrl)?regPictureFileCtrl:($("#registration_pic_file").length > 0?"registration_pic_file":null), regPictureTempIdCtrl: isVarNonempty(regPictureTempIdCtrl)?regPictureTempIdCtrl:($("#registration_picture_temp_id").length > 0?"registration_picture_temp_id":null), loginCtrl: isVarNonempty(loginCtrl)?loginCtrl:($("#login").length > 0?"login":null), psswdCtrl: isVarNonempty(psswdCtrl)?psswdCtrl:($("#psswd").length > 0?"psswd":null), profileLoginCtrl: isVarNonempty(profileLoginCtrl)?profileLoginCtrl:($("#profile_login").length > 0?"profile_login":null), profilePsswdCtrl: isVarNonempty(profilePsswdCtrl)?profilePsswdCtrl:($("#profile_psswd").length > 0?"profile_psswd":null), profileCheckPsswdCtrl: isVarNonempty(profileCheckPsswdCtrl)?profileCheckPsswdCtrl:($("#profile_psswd_check").length > 0?"profile_psswd_check":null), profileEmailCtrl: isVarNonempty(profileEmailCtrl)?profileEmailCtrl:($("#profile_email").length > 0?"profile_email":null), profilePhoneCtrl: isVarNonempty(profilePhoneCtrl)?profilePhoneCtrl:($("#profile_phone").length > 0?"profile_phone":null), profileNameCtrl: isVarNonempty(profileNameCtrl)?profileNameCtrl:($("#profile_name").length > 0?"profile_name":null), profileBornCtrl: isVarNonempty(profileBornCtrl)?profileBornCtrl:($("#profile_born").length > 0?"profile_born":null), profileAddressCtrl: isVarNonempty(profileAddressCtrl)?profileAddressCtrl:($("#profile_address").length > 0?"profile_address":null), profileGoogleButton: isVarNonempty(profileGoogleButton)?profileGoogleButton:($("#UA_profile_button_google").length > 0?"UA_profile_button_google":null), profileMsButton: isVarNonempty(profileMsButton)?profileMsButton:($("#UA_profile_button_ms").length > 0?"UA_profile_button_ms":null), profileFBButton: isVarNonempty(profileFBButton)?profileFBButton:($("#UA_profile_button_fb").length > 0?"UA_profile_button_fb":null), profileGoogleButtonIcon: isVarNonempty(profileGoogleButtonIcon)?profileGoogleButtonIcon:($("#UA_profile_button_google_icon").length > 0?"UA_profile_button_google_icon":null), profileMsButtonIcon: isVarNonempty(profileMsButtonIcon)?profileMsButtonIcon:($("#UA_profile_button_ms_icon").length > 0?"UA_profile_button_ms_icon":null), profileFBButtonIcon: isVarNonempty(profileFBButtonIcon)?profileFBButtonIcon:($("#UA_profile_button_fb_icon").length > 0?"UA_profile_button_fb_icon":null), profilePictureCtrl: isVarNonempty(profilePicture)?profilePicture:($("#profile_picture").length > 0?"profile_picture":null), profilePictureFileCtrl: isVarNonempty(profilePictureFileCtrl)?profilePictureFileCtrl:($("#profile_pic_file").length > 0?"profile_pic_file":null), profilePictureTempIdCtrl: isVarNonempty(profilePictureTempIdCtrl)?profilePictureTempIdCtrl:($("#profile_picture_temp_id").length > 0?"profile_picture_temp_id":null), regMandCtrls: isVarNonempty(regMandCtrlsArray)?regMandCtrlsArray:null, profileMandCtrls: isVarNonempty(profileMandCtrlsArray)?profileMandCtrlsArray:null, reqActivation: true } if(User.appConfig.regMandCtrls == null) { User.appConfig.regMandCtrls = []; if(isVarNonempty(User.appConfig.regLoginCtrl)) User.appConfig.regMandCtrls.push(User.appConfig.regLoginCtrl); if(isVarNonempty(User.appConfig.regPsswdCtrl)) User.appConfig.regMandCtrls.push(User.appConfig.regPsswdCtrl); if(isVarNonempty(User.appConfig.regCheckPsswdCtrl)) User.appConfig.regMandCtrls.push(User.appConfig.regCheckPsswdCtrl); if(isVarNonempty(User.appConfig.regEmailCtrl)) User.appConfig.regMandCtrls.push(User.appConfig.regEmailCtrl); } if(User.appConfig.profileMandCtrls == null) { User.appConfig.profileMandCtrls = []; if(isVarNonempty(User.appConfig.profileLoginCtrl)) User.appConfig.profileMandCtrls.push(User.appConfig.profileLoginCtrl); if(isVarNonempty(User.appConfig.profilePsswdCtrl)) User.appConfig.profileMandCtrls.push(User.appConfig.profilePsswdCtrl); if(isVarNonempty(User.appConfig.profileCheckPsswdCtrl)) User.appConfig.profileMandCtrls.push(User.appConfig.profileCheckPsswdCtrl); if(isVarNonempty(User.appConfig.profileEmailCtrl)) User.appConfig.profileMandCtrls.push(User.appConfig.profileEmailCtrl); } } /** * Uživatelský účet * * Knihovna pro práci s uživatelským ůčtem * * @category Knihovny funkcí * @copyright Copyright (c) 2016 Foxtrot Technologies s.r.o. (www.foxtrot.cz) * @version 1.0, 2017-05-12 */ // vars and constants User.name = ""; User.appID = ""; User.appEmail = ""; User.profileURL = ""; User.loginWay = ""; User.gmail = ""; User.gID = ""; User.gName = ""; User.gPictureURL = ""; User.gToken = ""; User.FBtoken = ""; User.FBID = ""; User.FBemail = ""; User.FBName = ""; User.FBPictureURL = ""; User.MStoken = ""; User.MSID = ""; User.MSemail = ""; User.MSname = ""; User.MSPictureURL = ""; User.MSAddress = ""; User.login = ""; User.name = ""; User.psswd = ""; User.rank = ""; User.su_id = ""; User.su_link_id = ""; User.phone = ""; User.address = ""; User.born = ""; User.rights = {}; // methods User.cleanProfile = function() { User.name = ""; User.appID = ""; User.appEmail = ""; User.profileURL = ""; User.loginWay = ""; User.gmail = ""; User.gID = ""; User.gPictureURL = ""; User.gName = ""; User.gToken = ""; User.FBtoken = ""; User.FBID = ""; User.FBemail = ""; User.FBName = ""; User.FBPictureURL = ""; User.MStoken = ""; User.MSID = ""; User.MSemail = ""; User.MSname = ""; User.MSPictureURL = ""; User.MSAddress = ""; User.login = ""; User.name = ""; User.psswd = ""; User.rank = ""; User.su_id = ""; User.su_link_id = ""; User.born = ""; User.rights = {}; } User.showRegistration = function() { if(User.appConfig.registrationCont !== null) $("#" + User.appConfig.registrationCont).attr("class","UA_modal_dialog_cont"); } User.closeRegistration = function() { if(User.appConfig.registrationCont !== null) $("#" + User.appConfig.registrationCont).attr("class","UA_hidden"); } User.showProfile = function() { if(User.appConfig.profileCont !== null) $("#" + User.appConfig.profileCont).attr("class","UA_modal_dialog_cont"); } User.closeProfile = function() { if(User.appConfig.profileCont !== null) $("#" + User.appConfig.profileCont).attr("class","UA_hidden"); } User.cleanLogin = function() { if(isVarNonempty(User.appConfig.loginCtrl)) $("#" + User.appConfig.loginCtrl).val(""); if(isVarNonempty(User.appConfig.psswdCtrl)) $("#" + User.appConfig.psswdCtrl).val(""); } User.cleanRegistrationForm = function() { if(isVarNonempty(User.appConfig.regLoginCtrl)) $("#" + User.appConfig.regLoginCtrl).val(""); if(isVarNonempty(User.appConfig.regPsswdCtrl)) $("#" + User.appConfig.regPsswdCtrl).val(""); if(isVarNonempty(User.appConfig.regCheckPsswdCtrl)) $("#" + User.appConfig.regCheckPsswdCtrl).val(""); if(isVarNonempty(User.appConfig.regEmailCtrl)) $("#" + User.appConfig.regEmailCtrl).val(""); if(isVarNonempty(User.appConfig.regPhoneCtrl)) $("#" + User.appConfig.regPhoneCtrl).val(""); if(isVarNonempty(User.appConfig.regNameCtrl)) $("#" + User.appConfig.regNameCtrl).val(""); if(isVarNonempty(User.appConfig.regBornCtrl)) $("#" + User.appConfig.regBornCtrl).val(""); if(isVarNonempty(User.appConfig.regAddressCtrl)) $("#" + User.appConfig.regAddressCtrl).val(""); if(isVarNonempty(User.appConfig.regPromoCtrl)) $("#" + User.appConfig.regPromoCtrl).val(""); if(isVarNonempty(User.appConfig.regPictureCtrl)) $("#" + User.appConfig.regPictureCtrl).attr("src","userAccount/images/no_avatar_user.png"); if(isVarNonempty(User.appConfig.regGoogleButton) && $("#"+User.appConfig.regGoogleButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.regGoogleButton).removeClass("UA_linked_button"); $("#"+User.appConfig.regGoogleButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.regFBButton) && $("#"+User.appConfig.regFBButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.regFBButton).removeClass("UA_linked_button"); $("#"+User.appConfig.regFBButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.regMsButton) && $("#"+User.appConfig.regMsButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.regMsButton).removeClass("UA_linked_button"); $("#"+User.appConfig.regMsButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.regGoogleButtonIcon)) $("#"+User.appConfig.regGoogleButtonIcon).attr("src",$("#"+User.appConfig.regGoogleButtonIcon).attr("src").replace("_green","_red")); if(isVarNonempty(User.appConfig.regFBButtonIcon)) $("#"+User.appConfig.regFBButtonIcon).attr("src",$("#"+User.appConfig.regFBButtonIcon).attr("src").replace("_green","_red")); if(isVarNonempty(User.appConfig.regMsButtonIcon)) $("#"+User.appConfig.regMsButtonIcon).attr("src",$("#"+User.appConfig.regMsButtonIcon).attr("src").replace("_green","_red")); } User.cleanProfileForm = function() { if(isVarNonempty(User.appConfig.profileLoginCtrl)) $("#" + User.appConfig.profileLoginCtrl).val(""); if(isVarNonempty(User.appConfig.profilePsswdCtrl)) $("#" + User.appConfig.profilePsswdCtrl).val(""); if(isVarNonempty(User.appConfig.profileCheckPsswdCtrl)) $("#" + User.appConfig.profileCheckPsswdCtrl).val(""); if(isVarNonempty(User.appConfig.profileEmailCtrl)) $("#" + User.appConfig.profileEmailCtrl).val(""); if(isVarNonempty(User.appConfig.profilePhoneCtrl)) $("#" + User.appConfig.profilePhoneCtrl).val(""); if(isVarNonempty(User.appConfig.profileNameCtrl)) $("#" + User.appConfig.profileNameCtrl).val(""); if(isVarNonempty(User.appConfig.profileBornCtrl)) $("#" + User.appConfig.profileBornCtrl).val(""); if(isVarNonempty(User.appConfig.profileAddressCtrl)) $("#" + User.appConfig.profileAddressCtrl).val(""); if(isVarNonempty(User.appConfig.profilePictureCtrl)) $("#" + User.appConfig.profilePictureCtrl).attr("src","userAccount/images/no_avatar_user.png"); if(isVarNonempty(User.appConfig.profileGoogleButton) && $("#"+User.appConfig.profileGoogleButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.profileGoogleButton).removeClass("UA_linked_button"); $("#"+User.appConfig.profileGoogleButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.profileFBButton) && $("#"+User.appConfig.profileFBButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.profileFBButton).removeClass("UA_linked_button"); $("#"+User.appConfig.profileFBButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.profileMsButton) && $("#"+User.appConfig.profileMsButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.profileMsButton).removeClass("UA_linked_button"); $("#"+User.appConfig.profileMsButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.profileGoogleButtonIcon)) $("#"+User.appConfig.profileGoogleButtonIcon).attr("src",$("#"+User.appConfig.profileGoogleButtonIcon).attr("src").replace("_green","_red")); if(isVarNonempty(User.appConfig.profileFBButtonIcon)) $("#"+User.appConfig.profileFBButtonIcon).attr("src",$("#"+User.appConfig.profileFBButtonIcon).attr("src").replace("_green","_red")); if(isVarNonempty(User.appConfig.profileMsButtonIcon)) $("#"+User.appConfig.profileMsButtonIcon).attr("src",$("#"+User.appConfig.profileMsButtonIcon).attr("src").replace("_green","_red")); } User.fillProfileForm = function() { if(isVarNonempty(User.appConfig.profileLoginCtrl)) $("#" + User.appConfig.profileLoginCtrl).val(User.login); if(isVarNonempty(User.appConfig.profileEmailCtrl)) $("#" + User.appConfig.profileEmailCtrl).val(User.email); if(isVarNonempty(User.appConfig.profilePhoneCtrl)) $("#" + User.appConfig.profilePhoneCtrl).val(User.phone); if(isVarNonempty(User.appConfig.profileNameCtrl)) $("#" + User.appConfig.profileNameCtrl).val(User.name); if(isVarNonempty(User.appConfig.profileBornCtrl)) $("#" + User.appConfig.profileBornCtrl).val(User.born); if(isVarNonempty(User.appConfig.profileAddressCtrl)) $("#" + User.appConfig.profileAddressCtrl).val(User.address); if(isVarNonempty(User.appConfig.profilePictureCtrl)) $("#" + User.appConfig.profilePictureCtrl).attr("src",User.profileURL); if(isVarNonempty(User.appConfig.profileGoogleButton) && isVarNonempty(User.gID)) { $("#"+User.appConfig.profileGoogleButton).removeClass("UA_not_linked_button"); $("#"+User.appConfig.profileGoogleButton).addClass("UA_linked_button"); if(isVarNonempty(User.appConfig.profileGoogleButtonIcon)) $("#"+User.appConfig.profileGoogleButtonIcon).attr("src",$("#"+User.appConfig.profileGoogleButtonIcon).attr("src").replace("_red","_green")); } if(isVarNonempty(User.appConfig.profileFBButton) && isVarNonempty(User.FBID)) { $("#"+User.appConfig.profileFBButton).removeClass("UA_not_linked_button"); $("#"+User.appConfig.profileFBButton).addClass("UA_linked_button"); if(isVarNonempty(User.appConfig.profileFBButtonIcon)) $("#"+User.appConfig.profileFBButtonIcon).attr("src",$("#"+User.appConfig.profileFBButtonIcon).attr("src").replace("_red","_green")); } if(isVarNonempty(User.appConfig.profileMsButton) && isVarNonempty(User.MSID)) { $("#"+User.appConfig.profileMsButton).removeClass("UA_not_linked_button"); $("#"+User.appConfig.profileMsButton).addClass("UA_linked_button"); if(isVarNonempty(User.appConfig.profileMsButtonIcon)) $("#"+User.appConfig.profileMsButtonIcon).attr("src",$("#"+User.appConfig.profileMsButtonIcon).attr("src").replace("_red","_green")); } } User.confirmCloseRegistration = function() { $.pgwModal({ content: "Opravdu zrušit registraci?", title: "Registrace", style: 'yesno', yescallback: User.appConfig.regCloseRegistrationFunc }); } User.confirmCloseProfile = function() { $.pgwModal({ content: "Opravdu zavřít profil?", title: "Profil", style: 'yesno', yescallback: User.appConfig.profCloseProfileFunc }); } User.checkRegLoginUnique = function() { if(!isVarNonempty(User.appConfig.regLoginCtrl) || $("#"+User.appConfig.regLoginCtrl).length == 0) { console.log("Registration login control is not defined"); return; } User.checkLoginUnique($("#"+User.appConfig.regLoginCtrl), true); } User.checkProfileLoginUnique = function() { if(!isVarNonempty(User.appConfig.profileLoginCtrl) || $("#"+User.appConfig.profileLoginCtrl).length == 0) { console.log("Profile login control is not defined"); return; } User.checkLoginUnique($("#"+User.appConfig.profileLoginCtrl), false); } User.checkLoginUnique = function(ctrl, skip_uid) { if(!isVarNonempty(ctrl) || ctrl.length == 0) { console.log("Login control is not defined"); return; } if(ctrl.val().trim() != "") { showWait(true); setTimeout(function() { var params = { login: ctrl.val().trim(), uid: isVarNonempty(skip_uid) && skip_uid?"":user.appID, ctrlID: ctrl.attr("id") }; loadXMLDoc("userAccount/UAIsLoginUnique.php", params); },1); } } User.loginCheckResp = function(is_unique, ctrlID) { showWait(false); if(!is_unique) { $.pgwModal({ content: "Zadané přihlašovací jméno je již registrováno", title: "Přihlašovací jméno", closeFocus: ctrlID, style: 'error' }); if(typeof userPostLoginExists === "function" && userPostLoginExists !== null) userPostLoginExists(); } } User.checkRegEmailUnique = function() { if(!isVarNonempty(User.appConfig.regEmailCtrl) || $("#"+User.appConfig.regEmailCtrl).length == 0) { console.log("Registration email control is not defined"); return; } User.checkEmailUnique($("#"+User.appConfig.regEmailCtrl), true); } User.checkProfileEmailUnique = function() { if(!isVarNonempty(User.appConfig.profileEmailCtrl) || $("#"+User.appConfig.profileEmailCtrl).length == 0) { console.log("Profile email control is not defined"); return; } User.checkEmailUnique($("#"+User.appConfig.profileEmailCtrl), false); } User.checkEmailUnique = function(ctrl, skip_uid) { if(!isVarNonempty(ctrl) || ctrl.length == 0) { console.log("Email control is not defined"); return; } if(ctrl.val().trim() != "") { if(isEmailCorrect(ctrl.val().trim())) { showWait(true); setTimeout(function() { var params = { email: ctrl.val().trim(), uid: isVarNonempty(skip_uid) && skip_uid?"":user.appID, ctrlID: ctrl.attr("id") }; loadXMLDoc("userAccount/UAIsEmailUnique.php", params); },1); } else { $.pgwModal({ content: "Zadaný email není platný", title: "Chybný email", closeFocus: ctrl.attr("id"), style: 'error' }); } } } User.emailCheckResp = function(is_unique, ctrlID) { showWait(false); if(!is_unique) { $.pgwModal({ content: "Zadaný email je již registrován u jiného účtu", title: "Chybný email", closeFocus: ctrlID, style: 'error' }); if(typeof userPostEmailExists === "function" && userPostEmailExists !== null) userPostEmailExists(); } } User.toggleRegGoogleAccount = function() { User.toggleGoogleAccount(User.regGoogleLinked); } User.toggleProfileGoogleAccount = function() { User.toggleGoogleAccount(User.profileGoogleLinked); } User.toggleRegFBAccount = function() { User.toggleFBAccount(User.regFBLinked); } User.toggleProfileFBAccount = function() { User.toggleFBAccount(User.profileFBLinked); } User.toggleRegMsAccount = function() { User.toggleMsAccount(User.regMsLinked); } User.toggleProfileMsAccount = function() { User.toggleMsAccount(User.profileMsLinked); } User.regGoogleLinked = function(linked, googleUser) { if(!isVarNonempty(User.appConfig.regGoogleButton) || $("#"+User.appConfig.regGoogleButton).length == 0) { console.log("Registration Google button is not defined"); return; } showWait(false); if(linked) { User.gID = googleUser.getBasicProfile().getId(); User.gPictureURL = googleUser.getBasicProfile().getImageUrl(); User.gName = googleUser.getBasicProfile().getName(); User.gmail = googleUser.getBasicProfile().getEmail() User.gToken = googleUser.getAuthResponse().id_token; if(isVarNonempty(User.appConfig.regNameCtrl) && !isVarNonempty($("#" + User.appConfig.regNameCtrl).val())) $("#" + User.appConfig.regNameCtrl).val(User.gName); if(isVarNonempty(User.appConfig.regEmailCtrl) && !isVarNonempty($("#" + User.appConfig.regEmailCtrl).val())) $("#" + User.appConfig.regEmailCtrl).val(User.gmail); if(isVarNonempty(User.appConfig.regPictureCtrl) && $("#" + User.appConfig.regPictureCtrl).attr("src").indexOf("no_avatar_user.png")>=0 && User.gPictureURL != "") $("#" + User.appConfig.regPictureCtrl).attr("src",User.gPictureURL); if($("#"+User.appConfig.regGoogleButton).hasClass("UA_not_linked_button")) { $("#"+User.appConfig.regGoogleButton).removeClass("UA_not_linked_button"); $("#"+User.appConfig.regGoogleButton).addClass("UA_linked_button"); } if(isVarNonempty(User.appConfig.regGoogleButtonIcon)) $("#"+User.appConfig.regGoogleButtonIcon).attr("src",$("#"+User.appConfig.regGoogleButtonIcon).attr("src").replace("_red","_green")); $("#"+User.appConfig.regGoogleButton).prop("title","Účet navázán"); } else { User.gID = ""; User.gmail = ""; User.gPictureURL = ""; User.gName = ""; User.gToken = ""; if($("#"+User.appConfig.regGoogleButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.regGoogleButton).removeClass("UA_linked_button"); $("#"+User.appConfig.regGoogleButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.regGoogleButtonIcon)) $("#"+User.appConfig.regGoogleButtonIcon).attr("src",$("#"+User.appConfig.regGoogleButtonIcon).attr("src").replace("_green","_red")); $("#"+User.appConfig.regGoogleButton).prop("title","Účet nenavázán"); } } User.profileGoogleLinked = function(linked, googleUser) { if(!isVarNonempty(User.appConfig.profileGoogleButton) || $("#"+User.appConfig.profileGoogleButton).length == 0) { console.log("Profile Google button is not defined"); return; } if((linked && !isVarNonempty(User.gID)) || (!linked && isVarNonempty(User.gID))) { showWait(true); if(linked) { User.gID = googleUser.getBasicProfile().getId(); User.gPictureURL = googleUser.getBasicProfile().getImageUrl(); User.gName = googleUser.getBasicProfile().getName(); User.gmail = googleUser.getBasicProfile().getEmail() User.gToken = googleUser.getAuthResponse().id_token; if($("#"+User.appConfig.profileGoogleButton).hasClass("UA_not_linked_button")) { $("#"+User.appConfig.profileGoogleButton).removeClass("UA_not_linked_button"); $("#"+User.appConfig.profileGoogleButton).addClass("UA_linked_button"); } if(isVarNonempty(User.appConfig.profileGoogleButtonIcon)) $("#"+User.appConfig.profileGoogleButtonIcon).attr("src",$("#"+User.appConfig.profileGoogleButtonIcon).attr("src").replace("_red","_green")); $("#"+User.appConfig.profileGoogleButton).prop("title","Účet navázán"); } else { User.gID = ""; User.gmail = ""; User.gPictureURL = ""; User.gName = ""; User.gToken = ""; if($("#"+User.appConfig.profileGoogleButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.profileGoogleButton).removeClass("UA_linked_button"); $("#"+User.appConfig.profileGoogleButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.profileGoogleButtonIcon)) $("#"+User.appConfig.profileGoogleButtonIcon).attr("src",$("#"+User.appConfig.profileGoogleButtonIcon).attr("src").replace("_green","_red")); $("#"+User.appConfig.profileGoogleButton).prop("title","Účet nenavázán"); } User.updateExternalSystemsLinks(); } } User.updateExternalSystemsLinks = function() { setTimeout(function() { var params = { uid: user.appID, gid: User.gID, fid: User.FBID, mid: User.MSID, gmail: User.gmail, fmail: User.FBemail, mmail: User.MSemail, gname: User.gName, fname: User.FBName, mname: User.MSname, gpic: User.gPictureURL, fpic: User.FBPictureURL, mpic: User.MSPictureURL, maddress: User.MSAddress }; loadXMLDoc("userAccount/UAUpdateExternalSystemsLinks.php", params); },1); } User.regFBLinked = function(linked, response) { if(!isVarNonempty(User.appConfig.regFBButton) || $("#"+User.appConfig.regFBButton).length == 0) { console.log("Registration Facebook button is not defined"); return; } showWait(false); if(linked) { User.FBtoken = response.authResponse.accessToken; User.FBID = response.authResponse.userID; FB.api('/'+User.FBID+'/picture?type=square&height=32&width=32', function (response) { if(typeof response !== "undefined" && response !== null && typeof response.data !== "undefined" && response.data !== null && typeof response.data.url !== "undefined" && response.data.url !== null) User.FBPictureURL = response.data.url; else User.FBPictureURL = ""; if(isVarNonempty(User.appConfig.regPictureCtrl) && $("#" + User.appConfig.regPictureCtrl).attr("src").indexOf("no_avatar_user.png")>=0 && User.FBPictureURL != "") $("#" + User.appConfig.regPictureCtrl).attr("src",User.FBPictureURL); FB.api('/me?field=name,email', function (response) { if(typeof response !== "undefined" && response !== null) { if(typeof response.name !== "undefined" && response.name !== null) User.FBName = response.name; else User.FBName = ""; if(typeof response.email !== "undefined" && response.email !== null) User.FBemail = response.email; else User.FBemail = ""; if(isVarNonempty(User.appConfig.regNameCtrl) && !isVarNonempty($("#" + User.appConfig.regNameCtrl).val())) $("#" + User.appConfig.regNameCtrl).val(User.FBName); if(isVarNonempty(User.appConfig.regEmailCtrl) && !isVarNonempty($("#" + User.appConfig.regEmailCtrl).val())) $("#" + User.appConfig.regEmailCtrl).val(User.FBemail); } }); }); if($("#"+User.appConfig.regFBButton).hasClass("UA_not_linked_button")) { $("#"+User.appConfig.regFBButton).removeClass("UA_not_linked_button"); $("#"+User.appConfig.regFBButton).addClass("UA_linked_button"); } if(isVarNonempty(User.appConfig.regFBButtonIcon)) $("#"+User.appConfig.regFBButtonIcon).attr("src",$("#"+User.appConfig.regFBButtonIcon).attr("src").replace("_red","_green")); $("#"+User.appConfig.regFBButton).prop("title","Účet navázán"); } else { User.FBtoken = ""; User.FBID = ""; User.FBName = ""; User.FBPictureURL = ""; User.FBemail = ""; if($("#"+User.appConfig.regFBButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.regFBButton).removeClass("UA_linked_button"); $("#"+User.appConfig.regFBButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.regFBButtonIcon)) $("#"+User.appConfig.regFBButtonIcon).attr("src",$("#"+User.appConfig.regFBButtonIcon).attr("src").replace("_green","_red")); $("#"+User.appConfig.regFBButton).prop("title","Účet nenavázán"); } } User.profileFBLinked = function(linked, response) { if(!isVarNonempty(User.appConfig.profileFBButton) || $("#"+User.appConfig.profileFBButton).length == 0) { console.log("Profile Facebook button is not defined"); return; } if((linked && !isVarNonempty(User.FBID)) || (!linked && isVarNonempty(User.FBID))) { showWait(true); if(linked) { User.FBtoken = response.authResponse.accessToken; User.FBID = response.authResponse.userID; FB.api('/'+User.FBID+'/picture?type=square&height=32&width=32', function (response) { if(typeof response !== "undefined" && response !== null && typeof response.data !== "undefined" && response.data !== null && typeof response.data.url !== "undefined" && response.data.url !== null) User.FBPictureURL = response.data.url; else User.FBPictureURL = ""; if(isVarNonempty(User.appConfig.regPictureCtrl) && $("#" + User.appConfig.regPictureCtrl).attr("src").indexOf("no_avatar_user.png")>=0 && User.FBPictureURL != "") $("#" + User.appConfig.regPictureCtrl).attr("src",User.FBPictureURL); FB.api('/me?field=name,email', function (response) { if(typeof response !== "undefined" && response !== null) { if(typeof response.name !== "undefined" && response.name !== null) User.FBName = response.name; else User.FBName = ""; if(typeof response.email !== "undefined" && response.email !== null) User.FBemail = response.email; else User.FBemail = ""; User.updateExternalSystemsLinks(); } }); }); if($("#"+User.appConfig.profileFBButton).hasClass("UA_not_linked_button")) { $("#"+User.appConfig.profileFBButton).removeClass("UA_not_linked_button"); $("#"+User.appConfig.profileFBButton).addClass("UA_linked_button"); } if(isVarNonempty(User.appConfig.profileFBButtonIcon)) $("#"+User.appConfig.profileFBButtonIcon).attr("src",$("#"+User.appConfig.profileFBButtonIcon).attr("src").replace("_red","_green")); $("#"+User.appConfig.profileFBButton).prop("title","Účet navázán"); } else { User.FBtoken = ""; User.FBID = ""; User.FBName = ""; User.FBPictureURL = ""; User.FBemail = ""; if($("#"+User.appConfig.profileFBButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.profileFBButton).removeClass("UA_linked_button"); $("#"+User.appConfig.profileFBButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.profileFBButtonIcon)) $("#"+User.appConfig.profileFBButtonIcon).attr("src",$("#"+User.appConfig.profileFBButtonIcon).attr("src").replace("_green","_red")); $("#"+User.appConfig.profileFBButton).prop("title","Účet nenavázán"); User.updateExternalSystemsLinks(); } } } User.regMsLinked = function(linked, response) { if(!isVarNonempty(User.appConfig.regMsButton) || $("#"+User.appConfig.regMsButton).length == 0) { console.log("Registration Microsoft button is not defined"); return; } showWait(true); if(linked) { WL.api({ path: "/me", method: "GET" }).then( function (response) { User.MStoken = WL.getSession().access_token; User.MSID = response.id; User.MSemail = isVarNonempty(response.emails.preferred)?response.emails.preferred:(isVarNonempty(response.emails.account)?response.emails.account:""); User.MSname = response.name; User.MSPictureURL = "https://apis.live.net/v5.0/"+response.id+"/picture"; User.MSAddress = isVarNonempty(response.addresses.personal) && getObjectLength(response.addresses.personal)>0 && (response.addresses.street !== "" || response.addresses.street2 !== "" || response.addresses.city !== "")?response.addresses.street+"\r\n"+response.addresses.street2+"\r\n"+response.addresses.postal_code+" "+response.addresses.city+"\r\n":""; User.MSAddress = User.MSAddress.trim(); if(isVarNonempty(User.appConfig.regNameCtrl) && !isVarNonempty($("#" + User.appConfig.regNameCtrl).val())) $("#" + User.appConfig.regNameCtrl).val(User.MSname); if(isVarNonempty(User.appConfig.regEmailCtrl) && !isVarNonempty($("#" + User.appConfig.regEmailCtrl).val())) $("#" + User.appConfig.regEmailCtrl).val(User.MSemail); if(isVarNonempty(User.appConfig.regAddressCtrl) && !isVarNonempty($("#" + User.appConfig.regAddressCtrl).val())) $("#" + User.appConfig.regAddressCtrl).val(User.MSAddress); if(isVarNonempty(User.appConfig.regPictureCtrl) && $("#" + User.appConfig.regPictureCtrl).attr("src").indexOf("no_avatar_user.png")>=0 && User.MSPictureURL != "") $("#" + User.appConfig.regPictureCtrl).attr("src",User.MSPictureURL); if($("#"+User.appConfig.regMsButton).hasClass("UA_not_linked_button")) { $("#"+User.appConfig.regMsButton).removeClass("UA_not_linked_button"); $("#"+User.appConfig.regMsButton).addClass("UA_linked_button"); } if(isVarNonempty(User.appConfig.regMsButtonIcon)) $("#"+User.appConfig.regMsButtonIcon).attr("src",$("#"+User.appConfig.regMsButtonIcon).attr("src").replace("_red","_green")); $("#"+User.appConfig.regMsButton).prop("title","Účet navázán"); showWait(false); }, function (response) { console.log("API call failed: " + JSON.stringify(response.error).replace(/,/g, "\n")); User.MStoken = ""; User.MSID = ""; User.MSemail = ""; User.MSname = ""; User.MSPictureURL = ""; User.MSAddress = ""; if($("#"+User.appConfig.regMsButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.regMsButton).removeClass("UA_linked_button"); $("#"+User.appConfig.regMsButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.regMsButtonIcon)) $("#"+User.appConfig.regMsButtonIcon).attr("src",$("#"+User.appConfig.regMsButtonIcon).attr("src").replace("_green","_red")); $("#"+User.appConfig.regMsButton).prop("title","Účet nenavázán"); showWait(false); } ); } else { User.MStoken = ""; User.MSID = ""; User.MSemail = ""; User.MSname = ""; User.MSPictureURL = ""; User.MSAddress = ""; if($("#"+User.appConfig.regMsButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.regMsButton).removeClass("UA_linked_button"); $("#"+User.appConfig.regMsButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.regMsButtonIcon)) $("#"+User.appConfig.regMsButtonIcon).attr("src",$("#"+User.appConfig.regMsButtonIcon).attr("src").replace("_green","_red")); $("#"+User.appConfig.regMsButton).prop("title","Účet nenavázán"); showWait(false); } } User.profileMsLinked = function(linked, response) { if(!isVarNonempty(User.appConfig.profileMsButton) || $("#"+User.appConfig.profileMsButton).length == 0) { console.log("Profile Microsoft button is not defined"); return; } showWait(true); if((linked && !isVarNonempty(User.MSID)) || (!linked && isVarNonempty(User.MSID))) { showWait(true); if(linked) { WL.api({ path: "/me", method: "GET" }).then( function (response) { User.MStoken = WL.getSession().access_token; User.MSID = response.id; User.MSemail = isVarNonempty(response.emails.preferred)?response.emails.preferred:(isVarNonempty(response.emails.account)?response.emails.account:""); User.MSname = response.name; User.MSPictureURL = "https://apis.live.net/v5.0/"+response.id+"/picture"; User.MSAddress = isVarNonempty(response.addresses.personal) && getObjectLength(response.addresses.personal)>0 && (response.addresses.street !== "" || response.addresses.street2 !== "" || response.addresses.city !== "")?response.addresses.street+"\r\n"+response.addresses.street2+"\r\n"+response.addresses.postal_code+" "+response.addresses.city+"\r\n":""; User.MSAddress = User.MSAddress.trim(); if($("#"+User.appConfig.profileMsButton).hasClass("UA_not_linked_button")) { $("#"+User.appConfig.profileMsButton).removeClass("UA_not_linked_button"); $("#"+User.appConfig.profileMsButton).addClass("UA_linked_button"); } if(isVarNonempty(User.appConfig.profileMsButtonIcon)) $("#"+User.appConfig.profileMsButtonIcon).attr("src",$("#"+User.appConfig.profileMsButtonIcon).attr("src").replace("_red","_green")); $("#"+User.appConfig.profileMsButton).prop("title","Účet navázán"); User.updateExternalSystemsLinks(); }, function (response) { console.log("API call failed: " + JSON.stringify(response.error).replace(/,/g, "\n")); User.MStoken = ""; User.MSID = ""; User.MSemail = ""; User.MSname = ""; User.MSPictureURL = ""; User.MSAddress = ""; if($("#"+User.appConfig.profileMsButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.profileMsButton).removeClass("UA_linked_button"); $("#"+User.appConfig.profileMsButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.profileMsButtonIcon)) $("#"+User.appConfig.profileMsButtonIcon).attr("src",$("#"+User.appConfig.profileMsButtonIcon).attr("src").replace("_green","_red")); $("#"+User.appConfig.profileMsButton).prop("title","Účet nenavázán"); User.updateExternalSystemsLinks(); } ); } else { User.MStoken = ""; User.MSID = ""; User.MSemail = ""; User.MSname = ""; User.MSPictureURL = ""; User.MSAddress = ""; if($("#"+User.appConfig.profileMsButton).hasClass("UA_linked_button")) { $("#"+User.appConfig.profileMsButton).removeClass("UA_linked_button"); $("#"+User.appConfig.profileMsButton).addClass("UA_not_linked_button"); } if(isVarNonempty(User.appConfig.profileMsButtonIcon)) $("#"+User.appConfig.profileMsButtonIcon).attr("src",$("#"+User.appConfig.profileMsButtonIcon).attr("src").replace("_green","_red")); $("#"+User.appConfig.profileMsButton).prop("title","Účet nenavázán"); User.updateExternalSystemsLinks(); } } } User.toggleGoogleAccount = function(callback) { if(User.gID == "") User.linkGoogleAccount(callback); else { callback(false); } } User.toggleFBAccount = function(callback) { if(User.FBID == "") User.linkFBAccount(callback); else { callback(false); } } User.toggleMsAccount = function(callback) { if(User.MSID == "") User.linkMsAccount(callback); else { callback(false); } } User.linkGoogleAccount = function(callback) { if(typeof googleAuth === "undefined" || googleAuth === null) { $.pgwModal({ content: "Přihlášení Google není nyní dostupné, zkus to prosím později.", title: "Chyba Google", style: 'error' }); callback(false); return; } var isSignedIn = googleAuth.isSignedIn.get(); if(!isSignedIn) { showWait(true); googleAuth.signIn().then(function (authResult) { callback(true,authResult); },function (authResult) { callback(false); }); } else { var usr = googleAuth.currentUser.get(); callback(true, usr); } } User.linkFBAccount = function(callback) { showWait(true); FB.getLoginStatus(function(response) { if (response.status === 'connected') callback(true, response); else FB.login(function(response) { if (response.authResponse) callback(true,response); else callback(false);}, {scope: 'public_profile, email'}); }); } User.linkMsAccount = function(callback) { showWait(true); var session = WL.getSession(); if (session) { callback(true, session); } else { WL.login().then(function(response) {callback(true,response);},function() {callback(false);}); } } User.getRegistrationFormData = function() { var ret_val = {}; if(isVarNonempty(User.appConfig.regLoginCtrl)) ret_val.login = $("#" + User.appConfig.regLoginCtrl).val().trim(); if(isVarNonempty(User.appConfig.regPsswdCtrl)) ret_val.psswd = $("#" + User.appConfig.regPsswdCtrl).val().trim(); if(isVarNonempty(User.appConfig.regCheckPsswdCtrl)) ret_val.checkPsswd = $("#" + User.appConfig.regCheckPsswdCtrl).val().trim(); if(isVarNonempty(User.appConfig.regEmailCtrl)) ret_val.email = $("#" + User.appConfig.regEmailCtrl).val().trim(); if(isVarNonempty(User.appConfig.regPhoneCtrl)) ret_val.phone = $("#" + User.appConfig.regPhoneCtrl).val().trim(); if(isVarNonempty(User.appConfig.regNameCtrl)) ret_val.name = $("#" + User.appConfig.regNameCtrl).val().trim(); if(isVarNonempty(User.appConfig.regBornCtrl)) ret_val.born = $("#" + User.appConfig.regBornCtrl).val().trim(); if(isVarNonempty(User.appConfig.regAddressCtrl)) ret_val.address = $("#" + User.appConfig.regAddressCtrl).val().trim(); if(isVarNonempty(User.appConfig.regPromoCtrl)) ret_val.promo = $("#" + User.appConfig.regPromoCtrl).val().trim(); if(isVarNonempty(User.appConfig.regPictureCtrl)) ret_val.picture = $("#" + User.appConfig.regPictureCtrl).attr("src"); return ret_val; } User.getProfileFormData = function() { var ret_val = {}; if(isVarNonempty(User.appConfig.profileLoginCtrl)) ret_val.login = $("#" + User.appConfig.profileLoginCtrl).val().trim(); if(isVarNonempty(User.appConfig.profilePsswdCtrl)) ret_val.psswd = $("#" + User.appConfig.profilePsswdCtrl).val().trim(); if(isVarNonempty(User.appConfig.profileCheckPsswdCtrl)) ret_val.checkPsswd = $("#" + User.appConfig.profileCheckPsswdCtrl).val().trim(); if(isVarNonempty(User.appConfig.profileEmailCtrl)) ret_val.email = $("#" + User.appConfig.profileEmailCtrl).val().trim(); if(isVarNonempty(User.appConfig.profilePhoneCtrl)) ret_val.phone = $("#" + User.appConfig.profilePhoneCtrl).val().trim(); if(isVarNonempty(User.appConfig.profileNameCtrl)) ret_val.name = $("#" + User.appConfig.profileNameCtrl).val().trim(); if(isVarNonempty(User.appConfig.profileBornCtrl)) ret_val.born = $("#" + User.appConfig.profileBornCtrl).val().trim(); if(isVarNonempty(User.appConfig.profileAddressCtrl)) ret_val.address = $("#" + User.appConfig.profileAddressCtrl).val().trim(); if(isVarNonempty(User.appConfig.profilePictureCtrl)) ret_val.picture = $("#" + User.appConfig.profilePictureCtrl).attr("src"); return ret_val; } User.saveProfile = function() { var params = User.getProfileFormData(); // console.log("Params: " + JSON.stringify(params).replace(/,/g, "\n")); if(varExists(params.login)) { if(params.login === "" && User.appConfig.profileMandCtrls !== null && User.appConfig.profileMandCtrls.indexOf(User.appConfig.profileLoginCtrl)>=0) { $.pgwModal({ content: "Není zadáno přihlašovací jméno", title: "Chyba profilu", style: 'error', closeFocus: User.appConfig.profileLoginCtrl }); return; } } else params.login = ""; if((isVarNonempty(params.psswd) && !isVarNonempty(params.checkPsswd)) || (!isVarNonempty(params.psswd) && isVarNonempty(params.checkPsswd)) || (!isVarNonempty(params.psswd) && !isVarNonempty(params.checkPsswd) && params.psswd !== params.checkPsswd)) { $.pgwModal({ content: "Zadaná hesla nejsou stejná", title: "Chyba profilu", style: 'error', closeFocus: User.appConfig.profileCheckPsswdCtrl }); return; } else params.psswd = ""; if(varExists(params.email)) { if(params.email === "" && User.appConfig.profileMandCtrls !== null && User.appConfig.profileMandCtrls.indexOf(User.appConfig.profileEmailCtrl)>=0) { $.pgwModal({ content: "Není zadán email", title: "Chyba profilu", style: 'error', closeFocus: User.appConfig.profileEmailCtrl }); return; } if(params.email !== "" && !isEmailCorrect(params.email)) { $.pgwModal({ content: "Zadaný email není platný", title: "Chybný email", closeFocus: User.appConfig.profileEmailCtrl, style: 'error' }); } } else params.email = ""; if(varExists(params.phone)) { if(params.phone === "" && User.appConfig.profileMandCtrls !== null && User.appConfig.profileMandCtrls.indexOf(User.appConfig.profilePhoneCtrl)>=0) { $.pgwModal({ content: "Není zadán telefon", title: "Chyba profilu", style: 'error', closeFocus: User.appConfig.profilePhoneCtrl }); return; } } else params.phone = ""; if(varExists(params.name)) { if(params.name === "" && User.appConfig.profileMandCtrls !== null && User.appConfig.profileMandCtrls.indexOf(User.appConfig.profileNameCtrl)>=0) { $.pgwModal({ content: "Není zadáno jméno", title: "Chyba profilu", style: 'error', closeFocus: User.appConfig.profileNameCtrl }); return; } } else params.name = ""; if(varExists(params.born)) { if(params.born === "" && User.appConfig.profileMandCtrls !== null && User.appConfig.profileMandCtrls.indexOf(User.appConfig.profileBornCtrl)>=0) { $.pgwModal({ content: "Není zadáno datum narození", title: "Chyba profilu", style: 'error', closeFocus: User.appConfig.profileBornCtrl }); return; } if(params.born !== "" && !isDateCorrect(params.born,true)) { $.pgwModal({ content: "Zadané datum narození není platné", title: "Chybné datum narození", closeFocus: User.appConfig.profileBornCtrl, style: 'error' }); } } else params.born = ""; if(varExists(params.address)) { if(params.address === "" && User.appConfig.profileMandCtrls !== null && User.appConfig.profileMandCtrls.indexOf(User.appConfig.profileAddressCtrl)>=0) { $.pgwModal({ content: "Není zadána adresa", title: "Chyba profilu", style: 'error', closeFocus: User.appConfig.profileAddressCtrl }); return; } } else params.address = ""; if(varExists(params.picture)) { if(params.picture === "" && User.appConfig.profileMandCtrls !== null && User.appConfig.profileMandCtrls.indexOf(User.appConfig.profilePictureCtrl)>=0) { $.pgwModal({ content: "Není zadán profilový obrázek", title: "Chyba profilu", style: 'error', closeFocus: User.appConfig.profilePictureCtrl }); return; } } else params.picture = ""; if(User.email != params.email && User.appConfig.reqActivation) { $.pgwModal({ content: "Změnil jsi registrační email. Tvůj účet bude dočasně deaktivován, než jej opět aktivuješ pomocí nového aktivačního emailu. Přeješ si opravdu pokračovat?", title: "Deaktivace účtu", style: 'yesno', yescallback: User.finishUserSave }); } else User.finishUserSave(); } User.finishUserSave = function() { var params = User.getProfileFormData(); if(!varExists(params.login)) params.login = ""; if(!varExists(params.psswd)) params.psswd = ""; if(!varExists(params.email)) params.email = ""; if(!varExists(params.phone)) params.phone = ""; if(!varExists(params.name)) params.name = ""; if(!varExists(params.address)) params.address = ""; if(!varExists(params.picture)) params.picture = ""; params.uid = User.appID; showWait(true); setTimeout(function() { loadXMLDoc("userAccount/UASaveUser.php",params); },1); } User.sendRegistration = function() { var params = User.getRegistrationFormData(); // console.log("Params: " + JSON.stringify(params).replace(/,/g, "\n")); if(varExists(params.login)) { if(params.login === "" && User.appConfig.regMandCtrls !== null && User.appConfig.regMandCtrls.indexOf(User.appConfig.regLoginCtrl)>=0) { $.pgwModal({ content: "Není zadáno přihlašovací jméno", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regLoginCtrl }); return; } } else params.login = ""; if(varExists(params.psswd)) { if(params.psswd === "" && User.appConfig.regMandCtrls !== null && User.appConfig.regMandCtrls.indexOf(User.appConfig.regPsswdCtrl)>=0) { $.pgwModal({ content: "Není zadáno heslo", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regPsswdCtrl }); return; } if(varExists(params.checkPsswd)) { if(params.checkPsswd === "" && User.appConfig.regMandCtrls !== null && User.appConfig.regMandCtrls.indexOf(User.appConfig.regCheckPsswdCtrl)>=0) { $.pgwModal({ content: "Není zadáno kontrolní heslo", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regCheckPsswdCtrl }); return; } if(params.psswd !== params.checkPsswd) { $.pgwModal({ content: "Zadaná hesla nejsou stejná", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regCheckPsswdCtrl }); return; } } } else params.psswd = ""; if(varExists(params.email)) { if(params.email === "" && User.appConfig.regMandCtrls !== null && User.appConfig.regMandCtrls.indexOf(User.appConfig.regEmailCtrl)>=0) { $.pgwModal({ content: "Není zadán email", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regEmailCtrl }); return; } if(params.email !== "" && !isEmailCorrect(params.email)) { $.pgwModal({ content: "Zadaný email není platný", title: "Chybný email", closeFocus: User.appConfig.regEmailCtrl, style: 'error' }); } } else params.email = ""; if(varExists(params.phone)) { if(params.phone === "" && User.appConfig.regMandCtrls !== null && User.appConfig.regMandCtrls.indexOf(User.appConfig.regPhoneCtrl)>=0) { $.pgwModal({ content: "Není zadán telefon", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regPhoneCtrl }); return; } } else params.phone = ""; if(varExists(params.name)) { if(params.name === "" && User.appConfig.regMandCtrls !== null && User.appConfig.regMandCtrls.indexOf(User.appConfig.regNameCtrl)>=0) { $.pgwModal({ content: "Není zadáno jméno", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regNameCtrl }); return; } } else params.name = ""; if(varExists(params.born)) { if(params.born === "" && User.appConfig.regMandCtrls !== null && User.appConfig.regMandCtrls.indexOf(User.appConfig.regBornCtrl)>=0) { $.pgwModal({ content: "Není zadáno datum narození", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regNameCtrl }); return; } if(params.born !== "" && !isDateCorrect(params.born,true)) { $.pgwModal({ content: "Zadané datum narození není platné", title: "Chybné datum narození", closeFocus: User.appConfig.regBornCtrl, style: 'error' }); } } else params.name = ""; if(varExists(params.address)) { if(params.address === "" && User.appConfig.regMandCtrls !== null && User.appConfig.regMandCtrls.indexOf(User.appConfig.regAddressCtrl)>=0) { $.pgwModal({ content: "Není zadána adresa", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regAddressCtrl }); return; } } else params.address = ""; if(varExists(params.picture)) { if(params.picture === "" && User.appConfig.regMandCtrls !== null && User.appConfig.regMandCtrls.indexOf(User.appConfig.regPictureCtrl)>=0) { $.pgwModal({ content: "Není zadán profilový obrázek", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regPictureCtrl }); return; } } else params.picture = ""; if(varExists(params.promo)) { if(params.promo === "" && User.appConfig.regMandCtrls !== null && User.appConfig.regMandCtrls.indexOf(User.appConfig.regPromoCtrl)>=0) { $.pgwModal({ content: "Není zadán promo kód", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regPromoCtrl }); return; } } else params.promo = ""; if(varExists(params.born)) { if(params.born === "" && User.appConfig.regMandCtrls !== null && User.appConfig.regMandCtrls.indexOf(User.appConfig.regBornCtrl)>=0) { $.pgwModal({ content: "Není zadáno datum narození", title: "Chyba registrace", style: 'error', closeFocus: User.appConfig.regBornCtrl }); return; } } else params.born = ""; params.uid = User.appID; params.gid = User.gID; params.fid = User.FBID; params.mid = User.MSID; params.gmail = User.gmail; params.fmail = User.FBemail; params.mmail = User.MSemail; params.gname = User.gName; params.fname = User.FBName; params.mname = User.MSname; params.gpic = User.gPictureURL; params.fpic = User.FBPictureURL; params.mpic = User.MSPictureURL; params.maddress = User.MSAddress; showWait(true); setTimeout(function() { loadXMLDoc("userAccount/UARegisterUser.php",params); },1); } User.registrationOK = function() { showWait(false); User.cleanRegistrationForm(); User.closeRegistration(); $.pgwModal({ content: "Tvůj účet je založen, ale je v tomto okamžiku neaktivní (nemůžeš jej zatím používat). Pro jeho akcivaci se řiď pokyny ve zprávě, kterou jsme zaslali na zadanou emailovou adresu.", title: "Registrace", style: 'info' }); } User.saveOK = function(react) { showWait(false); if(isVarNonempty(react)) { $.pgwModal({ content: "Tvůj účet je uložen, ale je v tomto okamžiku neaktivní (nemůžeš jej zatím používat). Pro jeho aktivaci se řiď pokyny ve zprávě, kterou jsme zaslali na zadanou emailovou adresu.", title: "Reaktivace účtu", style: 'info', closeAction: User.logoutOK }); } } User.externalLinksUpdateOK = function() { showWait(false); } User.registrationFail = function(err_code) { showWait(false); var err_msg = ""; switch(err_code) { case 1: err_msg = "Nepodařilo se uložit základní data. Zkus to prosím za chvíli znovu nebo nás kontaktuj pro vyřešení problému."; break; case 2: err_msg = "Nepodařilo se uložit doplňková data. Zkus to prosím za chvíli znovu nebo nás kontaktuj pro vyřešení problému."; break; case 3: err_msg = "Zadané přihlašovací jméno je již použito jiným uživatelem."; break; case 4: err_msg = "Zadaný email je již použit jiným uživatelem."; break; case 5: err_msg = "Zadaný promo kód byl již použit."; break; case 6: err_msg = "Účet byl založen, ale nepodařilo se odeslat aktivační email. Prosím, kontaktuj nás pro vyřešení problému."; break; case 8: err_msg = "Nepodařilo se uložit zadaný promo kód. Zkus to prosím za chvíli znovu nebo nás kontaktuj pro vyřešení problému."; break; case 9: err_msg = "Tento Google uživatel je již v systému registrován"; break; case 10: err_msg = "Tento Facebook uživatel je již v systému registrován"; break; case 11: err_msg = "Tento Microsoft uživatel je již v systému registrován"; break; default: err_msg = "Registrace se nezdařila. Zkus to prosím za chvíli znovu nebo nás kontaktuj pro vyřešení problému." } $.pgwModal({ content: err_msg, title: "Chyba registrace", style: 'error' }); } User.saveFail = function(err_code) { showWait(false); var err_msg = ""; switch(err_code) { case 1: err_msg = "Nepodařilo se uložit základní data. Zkus to prosím za chvíli znovu nebo nás kontaktuj pro vyřešení problému."; break; case 2: err_msg = "Nepodařilo se uložit doplňková data. Zkus to prosím za chvíli znovu nebo nás kontaktuj pro vyřešení problému."; break; case 3: err_msg = "Zadané přihlašovací jméno je již použito jiným uživatelem."; break; case 4: err_msg = "Zadaný email je již použit jiným uživatelem."; break; case 6: err_msg = "Účet byl založen, ale nepodařilo se odeslat aktivační email. Prosím, kontaktuj nás pro vyřešení problému."; break; default: err_msg = "Uložení dat se nezdařilo. Zkus to prosím za chvíli znovu nebo nás kontaktuj pro vyřešení problému." } $.pgwModal({ content: err_msg, title: "Chyba uložení dat", style: 'error' }); } User.externalLinksUpdateFail = function(err_code) { showWait(false); var err_msg = ""; switch(err_code) { case 9: err_msg = "Tento Google uživatel je již v systému registrován"; break; case 10: err_msg = "Tento Facebook uživatel je již v systému registrován"; break; case 11: err_msg = "Tento Microsoft uživatel je již v systému registrován"; break; default: err_msg = "Aktualizace vazby na externí systémy se nezdařila. Zkus to prosím za chvíli znovu nebo nás kontaktuj pro vyřešení problému." } $.pgwModal({ content: err_msg, title: "Chyba aktualitace dat", style: 'error' }); } User.updateLoginInfo = function() { loadXMLDoc("userAccount/UAUpdateLoginInfo.php",null,false,15000,true,"",User.profileData,false,true); } User.logoutUser = function() { showWait(true); loadXMLDoc("userAccount/UALogoutUser.php"); } User.logoutOK = function() { User.cleanProfile(); if(typeof userPostLogout === "function" && userPostLogout !== null) userPostLogout(); } User.loginAppUser = function(checkSpecialUsers) { if(!isVarNonempty(User.appConfig.loginCtrl)) { console.log("No login control specified"); return; } if(!isVarNonempty(User.appConfig.psswdCtrl)) { console.log("No password control specified"); return; } var login = $("#"+User.appConfig.loginCtrl).val(); var psswd = $("#"+User.appConfig.psswdCtrl).val(); if(login == "") { $.pgwModal({ content: typeof i18n === "object"? i18n.t("userAccount.nologin_msg") : "Není zadáno přihlašovací jméno", title: typeof i18n === "object"? i18n.t("userAccount.nologin_title") : "Chyba přihlášení", style: 'error', closeFocus: User.appConfig.loginCtrl }); return; } if(psswd == "") { $.pgwModal({ content: typeof i18n === "object"? i18n.t("userAccount.nopsswd_msg") : "Není zadáno heslo", title: typeof i18n === "object"? i18n.t("userAccount.nopsswd_title") : "Chyba přihlášení", style: 'error', closeFocus: User.appConfig.psswdCtrl }); return; } showWait(true); var params = { login: login, psswd: psswd, special: (isVarNonempty(checkSpecialUsers) && checkSpecialUsers?"1":"0") }; loadXMLDoc("userAccount/UAAppLogin.php", params); } User.loginForeign = function(user_id, type) { if(isVarNonempty(user_id) && isVarNonempty(type)) { var params = { uid: user_id, type: type }; loadXMLDoc("userAccount/UAForeignLogin.php",params); } } User.loginMsUser = function() { showWait(true); var session = WL.getSession(); if (session) { WL.api({ path: "/me", method: "GET" }).then( function (response) { User.loginForeign(response.id,"ms"); }, function (response) { showWait(false); } ); } else { WL.login().then(function(response) { WL.api({ path: "/me", method: "GET" }).then( function (response) { User.loginForeign(response.id,"ms"); }, function (response) { showWait(false); } ); },function() {showWait(false);}); } } User.loginFBUser = function() { showWait(true); FB.getLoginStatus(function(response) { showWait(true); if (response.status === 'connected') User.loginForeign(response.authResponse.userID,"fb"); else FB.login(function(response) { if (response.authResponse) User.loginForeign(response.authResponse.userID,"fb"); else showWait(false);}, {scope: 'public_profile, email'}); }); } User.loginGoogleUser = function() { if(typeof googleAuth === "undefined" || googleAuth === null) { $.pgwModal({ content: "Přihlášení Google není nyní dostupné, zkus to prosím později.", title: "Chyba Google", style: 'error' }); return; } var isSignedIn = googleAuth.isSignedIn.get(); if(!isSignedIn) { showWait(true); googleAuth.signIn().then(function (authResult) { User.loginForeign(authResult.getBasicProfile().getId(),"g"); },function (authResult) { showWait(false); }); } else User.loginForeign(googleAuth.currentUser.get().getBasicProfile().getId(),"g"); } User.loginOK = function(uid, name, email, has_pic, google_id, fb_id, m_id, rank_id, way) { showWait(false); User.cleanProfile(); User.name = name; User.appID = uid; User.email = email; User.loginWay = way; User.login = $("#"+User.appConfig.loginCtrl).val(); User.gID = google_id; User.FBID = fb_id; User.MSID = m_id; User.rank = rank_id; if(has_pic) user.profileURL = "userAccount/UAGetUserProfilePic.php?id=" + uid; User.cleanLogin(); if(typeof userPostLogin === "function" && userPostLogin !== null) userPostLogin(); } User.profileData = function(data) { showWait(false); User.cleanProfile(); if(isVarNonempty(data)) User = jQuery.extend(User,JSON.parse(data)); if(typeof userPostProfileUpdated === "function" && userPostProfileUpdated !== null) userPostProfileUpdated(); } User.notActiveLoginAttempt = function() { showWait(false); $.pgwModal({ content: typeof i18n === "object"? i18n.t("userAccount.notactive_msg") : "Ještě jsi si neaktivoval účet a proto se nemůžeš přihlásit. Prosím, řiď se instrukcemi, co jsi obdržel(a) v aktivační zprávě do emailu nebo nás kontaktuj.", title: typeof i18n === "object" ? i18n.t("userAccount.notactive_title") : "Chyba přihlášení", style: 'warning' }); } User.newUserLoginAttempt = function() { showWait(false); $.pgwModal({ content: typeof i18n === "object"? i18n.t("userAccount.newuser_msg") : "Tento uživatel není v systému evidován. Chceš se registrovat?", title: typeof i18n === "object"? i18n.t("userAccount.newuser_title") : "Chyba přihlášení", style: 'yesno', yescallback: "user.showRegistration" }); } User.badPasswordLoginAttempt = function() { showWait(false); $.pgwModal({ content: typeof i18n === "object" ? i18n.t("userAccount.badpsswd_msg") : "Zadané heslo není správné, chceš zaslat na registrační email nové?", title: typeof i18n === "object" ? i18n.t("userAccount.badpsswd_title") : "Chyba přihlášení", style: 'yesno', yescallback: "user.sendLostPassword", nocallback: "user.logoutOK", closeAction: "user.logoutOK" }); } User.sendLostPassword = function() { var login = $("#"+User.appConfig.loginCtrl).val(); showWait(true); var params = { login: login }; loadXMLDoc("userAccount/UASendLostPsswd.php", params); } User.lostPasswordOK = function() { showWait(false); $.pgwModal({ content: "Na Tvůj registrační email byla zaslána zpráva s novým heslem.", title: "Zapomenuté heslo", style: 'info' }); } User.lostPasswordFail = function(err_code) { var err_msg = ""; switch(err_code) { case 1: err_msg = "Zadané přihlašovací jméno nebylo nalezeno v naší databázi. Kontaktuj nás, pokud jsi si jist(a), že je správné." break; case 2: err_msg = "Pro vytvoření Tvého hesla nemáme dostatek údajů. Prosím, kontaktuj nás, abychom situaci vyřešili." break; case 3: err_msg = "Bohužel, nové heslo se nepodařilo uložit. Zkus to prosím později nebo nás kontaktuj." break; case 4: err_msg = "Bohužel, emailovou zprávu se nepodařilo odeslat. Zkus to prosím později nebo nás kontaktuj." break; default: err_msg = "Bohužel, heslo se nepodařilo zaslat. Zkus to prosím později nebo nás kontaktuj." } $.pgwModal({ content: err_msg, title: "Zapomenuté heslo", style: 'error' }); showWait(false); } User.profilePictureChanged = function() { if(!isVarNonempty(User.appConfig.regPictureFileCtrl) || $("#"+User.appConfig.regPictureFileCtrl).length == 0) { console.log("Registration picture file control is not defined"); return; } if(!isVarNonempty(User.appConfig.regPictureCtrl) || $("#"+User.appConfig.regPictureCtrl).length == 0) { console.log("Registration picture control is not defined"); return; } if(!isVarNonempty(User.appConfig.regPictureTempIdCtrl) || $("#"+User.appConfig.regPictureTempIdCtrl).length == 0) { console.log("Registration picture temp ID control is not defined"); return; } showWait(true); setTimeout(function() {User.profilePictureChangedExec();},1); } User.profilePictureChangedExec = function() { var file = $("#"+User.appConfig.regPictureFileCtrl).prop("files")[0]; uploadFile(file,"userAccount/UAUploadProfilePicture.php",{temporary: "1", tempID: "842vfthrscdrebdvjs1b7h6p05"}); } User.tempProfPictureUploadFailed = function() { $.pgwModal({ content: "Bohužel, obrázek se nepodařilo nahrát. Zkus to prosím později nebo nás kontaktuj.", title: "Profilový obrázek", style: 'error' }); } User.tempProfPictureUploaded = function(fle_id) { $("#"+User.appConfig.regPictureCtrl).attr("src","userAccount/UAGetUserTempProfPic.php?id=" + fle_id); $("#"+User.appConfig.regPictureTempIdCtrl).val(fle_id); } User.UASUSaveFail = function(err_code,su_id) { var err_msg = ""; switch(err_code) { case 1: err_msg = "Zadané přihlašovací jméno již existuje." break; default: err_msg = "Bohužel, přihlašovací údaje se nepodařilo uložit. Zkus to prosím později nebo nás kontaktuj." } $.pgwModal({ content: err_msg, title: "Uložení dat", style: 'error' }); showWait(false); } User.UASUSaveOK = function(id,su_id) { showWait(false); if(typeof specialUserSaved === "function" && specialUserSaved !== null) specialUserSaved(id,su_id); } User.specialUserLoginOK = function(uid, name, su_id, su_link) { showWait(false); User.cleanProfile(); User.cleanLogin(); User.name = name; User.appID = uid; User.su_id = su_id; User.su_link_id = su_link; if(typeof userSpecialUserPostLogin === "function" && userSpecialUserPostLogin !== null) userSpecialUserPostLogin(); } User.specialUserLoginFail = function() { $.pgwModal({ content: 'Zadané heslo není správné.', title: 'Nepřihlášený uživatel', style: 'error' }); } User.getRightLevel = function(type) { if(isVarNonempty(User.rights) && isVarNonempty(User.rights[type])) return parseInt(User.rights[type]); else return 0; } User.setUserAttrib = function(att_id, val) { if(isVarNonempty(att_id) && att_id > 0) { showWait(true); setTimeout(function() { var params = { uid: user.appID, attID: att_id, val: val }; loadXMLDoc("userAccount/UASetAttrib.php", params); },1); } } User.getUserAttrib = function(att_id) { if(isVarNonempty(att_id) && att_id > 0) { showWait(true); setTimeout(function() { var params = { uid: user.appID, attID: att_id }; loadXMLDoc("userAccount/UAGetAttrib.php", params); },1); } } User.attribData = function(att_id, val) { if(typeof userAttribReceived === "function" && userAttribReceived !== null) userAttribReceived(att_id, val); } User.attribSaveOK = function(att_id) { if(typeof userAttribSaved === "function" && userAttribSaved !== null) userAttribSaved(att_id); } User.attribSaveFail = function(att_id) { $.pgwModal({ content: "Data se nepodařilo uložit. Zkus to prosím později nebo nás kontaktuj.", title: "Uložení dat", style: 'error' }); } User.takeIdentity = function(id) { showWait(true); setTimeout(function() { var params = { id: id }; loadXMLDoc("userAccount/UATakeIdentity.php", params); },1); } User.returnIdentity = function() { showWait(true); setTimeout(function() { loadXMLDoc("userAccount/UAReturnIdentity.php"); },1); } User.identityChanged = function() { location.reload(); } User.getAge = function() { var userAge = 0; if(isVarNonempty(User.born)) { var born_dt = newDateFromString(reformatDate(User.born)); userAge = ((new Date().getTime()) - born_dt.getTime()) / 31536000; } return userAge; } // constructor User.setAppConfig(); if(typeof gapi !== "undefined" && gapi !== null) { gapi.load('auth2', function(){ auth2 = gapi.auth2.init({ client_id: '696096454908-flk3ia3p3a50affgr4eehca1bv2uddm1.apps.googleusercontent.com', cookiepolicy: 'single_host_origin', }); auth2.then(function() { googleAuth = gapi.auth2.getAuthInstance(); }) }); } window.fbAsyncInit = function() { FB.init({ appId : '1003677323035381', xfbml : true, version : 'v2.6' }); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); WL.init({ client_id: '000000004819672C', redirect_uri: "http://www.aerojunior.cz/hlavni.php?1714002063", scope: ["wl.signin","wl.emails","wl.basic","wl.postal_addresses"], response_type: "token"}); // return main object return User; }