86 * Performs the AJAX request to get an encryption key and from there spawns the login form. |
86 * Performs the AJAX request to get an encryption key and from there spawns the login form. |
87 * @param function The function that will be called once authentication completes successfully. |
87 * @param function The function that will be called once authentication completes successfully. |
88 * @param int The security level to authenticate at - see http://docs.enanocms.org/Help:Appendix_B |
88 * @param int The security level to authenticate at - see http://docs.enanocms.org/Help:Appendix_B |
89 */ |
89 */ |
90 |
90 |
91 function ajaxLoginInit(call_on_finish, user_level) |
91 window.ajaxLoginInit = function(call_on_finish, user_level) |
92 { |
92 { |
|
93 load_component('messagebox'); |
|
94 load_component('flyin'); |
|
95 load_component('SpryEffects'); |
|
96 load_component('l10n'); |
|
97 load_component('crypto'); |
|
98 |
93 logindata = {}; |
99 logindata = {}; |
94 |
100 |
95 var title = ( user_level > USER_LEVEL_MEMBER ) ? $lang.get('user_login_ajax_prompt_title_elev') : $lang.get('user_login_ajax_prompt_title'); |
101 var title = ( user_level > USER_LEVEL_MEMBER ) ? $lang.get('user_login_ajax_prompt_title_elev') : $lang.get('user_login_ajax_prompt_title'); |
96 logindata.mb_object = new MessageBox(MB_OKCANCEL | MB_ICONLOCK, title, ''); |
102 logindata.mb_object = new MessageBox(MB_OKCANCEL | MB_ICONLOCK, title, ''); |
97 |
103 |
141 |
147 |
142 /** |
148 /** |
143 * For compatibility only. |
149 * For compatibility only. |
144 */ |
150 */ |
145 |
151 |
146 function ajaxLogonInit(call_on_finish, user_level) |
152 window.ajaxLogonInit = function(call_on_finish, user_level) |
147 { |
153 { |
148 return ajaxLoginInit(call_on_finish, user_level); |
154 return ajaxLoginInit(call_on_finish, user_level); |
149 } |
155 } |
150 |
156 |
151 /** |
157 /** |
152 * Sets the contents of the AJAX login window to the appropriate status message. |
158 * Sets the contents of the AJAX login window to the appropriate status message. |
153 * @param int One of AJAX_STATUS_* |
159 * @param int One of AJAX_STATUS_* |
154 */ |
160 */ |
155 |
161 |
156 function ajaxLoginSetStatus(status) |
162 window.ajaxLoginSetStatus = function(status) |
157 { |
163 { |
158 if ( !logindata.mb_inner ) |
164 if ( !logindata.mb_inner ) |
159 return false; |
165 return false; |
160 if ( logindata.showing_status ) |
166 if ( logindata.showing_status ) |
161 { |
167 { |
303 /** |
309 /** |
304 * Performs an AJAX logon request to the server and calls ajaxLoginProcessResponse() on the result. |
310 * Performs an AJAX logon request to the server and calls ajaxLoginProcessResponse() on the result. |
305 * @param object JSON packet to send |
311 * @param object JSON packet to send |
306 */ |
312 */ |
307 |
313 |
308 function ajaxLoginPerformRequest(json) |
314 window.ajaxLoginPerformRequest = function(json) |
309 { |
315 { |
310 json = toJSONString(json); |
316 json = toJSONString(json); |
311 json = ajaxEscape(json); |
317 json = ajaxEscape(json); |
312 ajaxPost(makeUrlNS('Special', 'Login/action.json'), 'r=' + json, function() |
318 ajaxPost(makeUrlNS('Special', 'Login/action.json'), 'r=' + json, function() |
313 { |
319 { |
401 /** |
407 /** |
402 * Builds the login form. |
408 * Builds the login form. |
403 * @param object Metadata to build off of |
409 * @param object Metadata to build off of |
404 */ |
410 */ |
405 |
411 |
406 function ajaxLoginBuildForm(data) |
412 window.ajaxLoginBuildForm = function(data) |
407 { |
413 { |
408 // let's hope this effectively preloads the image... |
414 // let's hope this effectively preloads the image... |
409 var _ = document.createElement('img'); |
415 var _ = document.createElement('img'); |
410 _.src = ( ajax_login_successimg_path ) ? ajax_login_successimg_path : scriptPath + '/images/check.png'; |
416 _.src = ( ajax_login_successimg_path ) ? ajax_login_successimg_path : scriptPath + '/images/check.png'; |
411 |
417 |
866 return base; |
872 return base; |
867 break; |
873 break; |
868 } |
874 } |
869 } |
875 } |
870 |
876 |
|
877 window.ajaxInitLogout = function() |
|
878 { |
|
879 load_component('messagebox'); |
|
880 load_component('l10n'); |
|
881 var mb = new MessageBox(MB_YESNO|MB_ICONQUESTION, $lang.get('user_logout_confirm_title'), $lang.get('user_logout_confirm_body')); |
|
882 mb.onclick['Yes'] = function() |
|
883 { |
|
884 window.location = makeUrlNS('Special', 'Logout/' + csrf_token + '/' + title); |
|
885 } |
|
886 } |
|
887 |
|
888 window.mb_logout = function() |
|
889 { |
|
890 ajaxInitLogout(); |
|
891 } |
|
892 |
|
893 window.ajaxStartLogin = function() |
|
894 { |
|
895 ajaxLogonToMember(); |
|
896 } |
|
897 |
|
898 window.ajaxStartAdminLogin = function() |
|
899 { |
|
900 // IE <6 pseudo-compatibility |
|
901 if ( KILL_SWITCH ) |
|
902 return true; |
|
903 if ( auth_level < USER_LEVEL_ADMIN ) |
|
904 { |
|
905 ajaxLoginInit(function(k) { |
|
906 ENANO_SID = k; |
|
907 auth_level = USER_LEVEL_ADMIN; |
|
908 var loc = makeUrlNS('Special', 'Administration'); |
|
909 if ( (ENANO_SID + ' ').length > 1 ) |
|
910 window.location = loc; |
|
911 }, USER_LEVEL_ADMIN); |
|
912 return false; |
|
913 } |
|
914 var loc = makeUrlNS('Special', 'Administration'); |
|
915 window.location = loc; |
|
916 } |
|
917 |
|
918 window.ajaxAdminPage = function() |
|
919 { |
|
920 // IE <6 pseudo-compatibility |
|
921 if ( KILL_SWITCH ) |
|
922 return true; |
|
923 if ( auth_level < USER_LEVEL_ADMIN ) |
|
924 { |
|
925 ajaxPromptAdminAuth(function(k) { |
|
926 ENANO_SID = k; |
|
927 auth_level = USER_LEVEL_ADMIN; |
|
928 var loc = String(window.location + ''); |
|
929 window.location = append_sid(loc); |
|
930 var loc = makeUrlNS('Special', 'Administration', 'module=' + namespace_list['Admin'] + 'PageManager&source=ajax&page_id=' + ajaxEscape(title)); |
|
931 if ( (ENANO_SID + ' ').length > 1 ) |
|
932 window.location = loc; |
|
933 }, 9); |
|
934 return false; |
|
935 } |
|
936 var loc = makeUrlNS('Special', 'Administration', 'module=' + namespace_list['Admin'] + 'PageManager&source=ajax&page_id=' + ajaxEscape(title)); |
|
937 window.location = loc; |
|
938 } |
|
939 |
|
940 var navto_ns; |
|
941 var navto_pg; |
|
942 var navto_ul; |
|
943 |
|
944 window.ajaxLoginNavTo = function(namespace, page_id, min_level) |
|
945 { |
|
946 // IE <6 pseudo-compatibility |
|
947 if ( KILL_SWITCH ) |
|
948 return true; |
|
949 navto_pg = page_id; |
|
950 navto_ns = namespace; |
|
951 navto_ul = min_level; |
|
952 if ( auth_level < min_level ) |
|
953 { |
|
954 ajaxPromptAdminAuth(function(k) { |
|
955 ENANO_SID = k; |
|
956 auth_level = navto_ul; |
|
957 var loc = makeUrlNS(navto_ns, navto_pg); |
|
958 if ( (ENANO_SID + ' ').length > 1 ) |
|
959 window.location = loc; |
|
960 }, min_level); |
|
961 return false; |
|
962 } |
|
963 var loc = makeUrlNS(navto_ns, navto_pg); |
|
964 window.location = loc; |
|
965 } |
|
966 |
|
967 window.ajaxAdminUser = function(username) |
|
968 { |
|
969 // IE <6 pseudo-compatibility |
|
970 if ( KILL_SWITCH ) |
|
971 return true; |
|
972 if ( auth_level < USER_LEVEL_ADMIN ) |
|
973 { |
|
974 ajaxPromptAdminAuth(function(k) { |
|
975 ENANO_SID = k; |
|
976 auth_level = USER_LEVEL_ADMIN; |
|
977 var loc = String(window.location + ''); |
|
978 window.location = append_sid(loc); |
|
979 var loc = makeUrlNS('Special', 'Administration', 'module=' + namespace_list['Admin'] + 'UserManager&src=get&user=' + ajaxEscape(username)); |
|
980 if ( (ENANO_SID + ' ').length > 1 ) |
|
981 window.location = loc; |
|
982 }, 9); |
|
983 return false; |
|
984 } |
|
985 var loc = makeUrlNS('Special', 'Administration', 'module=' + namespace_list['Admin'] + 'UserManager&src=get&user=' + ajaxEscape(username)); |
|
986 window.location = loc; |
|
987 } |