-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathmanage_mysettings.php
376 lines (300 loc) · 11.8 KB
/
manage_mysettings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<?php include "php/inc/header.inc.php" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?=$language;?>" lang="<?=$language;?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $Text['global_title'] . " - " . $Text['head_ti_manage'] . " " . $Text['head_ti_manage_uf'] ;?></title>
<link rel="stylesheet" type="text/css" media="screen" href="css/aixada_main.css" />
<link rel="stylesheet" type="text/css" media="screen" href="js/fgmenu/fg.menu.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-themes/<?=$default_theme;?>/jqueryui.css"/>
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="js/jqueryui/jqueryui.js"></script>
<?php echo aixada_js_src(); ?>
<script type="text/javascript">
$(function(){
$.ajaxSetup({ cache: false });
//loading Spinner
$('.loadSpinner').attr('src', "img/ajax-loader-<?=$default_theme;?>.gif").hide();
//decide what to do in which section
var what = $.getUrlVar('what');
//preorder tab is only available for ordering
if (what == "pwd") {
$('.changePwdElements').show();
$('.editMemberElements').hide();
} else {
$('.changePwdElements').hide();
$('.editMemberElements').show();
}
$('#btn_pwd_save')
.button({
icons: {
primary: "ui-icon-check"}
})
.click(function(){
//$('#change_pwd').submit();
});
$('#btn_pwd_cancel')
.button({icons: {primary: "ui-icon-close"}});
//remove all eventual error styles on input fields.
$('input')
.live('focus', function(e){
$(this).removeClass('ui-state-error');
});
/*******************************************
* EDIT MY SETTINGS
*******************************************/
//init the uf member listing
$('#edit_my_settings').xml2html('init',{
url : 'php/ctrl/UserAndUf.php',
params: "oper=getMemberInfo&member_id="+<?php echo get_session_member_id();?>,
loadOnInit:true,
complete: function(){
constructSelects();
//set the checkboxes
$('.tblForms input:checkbox').each(function(){
var bool = $(this).val();
if (bool == "1") $(this).attr('checked',true);
});
//each member gets an edit button
$('.btn_save_edit_member').button({
icons: {primary: "ui-icon-disk"}
}).live('click', function(e){
submitMember('update','#detail_member_'+$(this).attr('memberid'));
return false;
});
}
});
/**
* submits the create/edit member data
* urlStr : either updateMember or createNewMember
* mi: is the selector string of the layer that contains the whole member form and info
*/
function submitMember(action, mi){
var urlStr = 'php/ctrl/UserAndUf.php?oper=updateMember';
var isValid = true;
var isValidItem = true;
var err_msg = '';
//run some local checks
if (action == 'pwd'){
urlStr = "php/ctrl/UserAndUf.php?oper=changePassword";
isValidItem = $.checkFormLength($(mi +' input[name=login]'),3,50);
if (!isValidItem){
isValid = false;
err_msg += "<?=$Text['msg_err_usershort'];?>" + "<br/><br/>";
}
isValidItem = $.checkFormLength($(mi+' input[name=password]'),4,15);
if (!isValidItem){
isValid = false;
err_msg += "<?=$Text['msg_err_passshort'];?>" + "<br/><br/>";
}
isValidItem = $.checkPassword($(mi+' input[name=password]'), $('input[name=password_ctrl]'));
if (!isValidItem){
isValid = false;
err_msg += "<?=$Text['msg_err_pwdctrl']; ?>"+ "<br/><br/>";
}
}
isValidItem = $.checkFormLength($(mi+' input[name="name"]'),2,150);
if (!isValidItem){
isValid = false;
err_msg += "<?php echo $Text['msg_err_namelength']; ?>"+ "<br/><br/>";
}
isValidItem = $.checkRegexp($(mi+' input[name="phone1"]'),/^([0-9\s\+])+$/);
if (!isValidItem){
isValid = false;
err_msg += "<?php echo $Text['phone1'] . $Text['msg_err_only_num']; ?>"+ "<br/><br/>";
}
isValidItem = $.checkRegexp($(mi+' input[name="email"]'),/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
if (!isValidItem){
isValid = false;
err_msg += "<?=$Text['msg_err_email'] ?>"+ "<br/><br/>";
}
if (isValid){
var sdata = $(mi + ' form').serialize();
$.ajax({
url: urlStr,
data: sdata,
beforeSend: function(){
//$('button',mi).button('disable');
//myButton.button('disable');
//$('#uf_listing .loadAnim').show();
},
success: function(msg){
$.showMsg({
msg: "<?=$Text['msg_edit_success'];?>",
type: 'success'});
},
error : function(XMLHttpRequest, textStatus, errorThrown){
$.showMsg({
msg: XMLHttpRequest.responseText,
type: 'error'});
},
complete : function(msg){
//$('button',mi).button('enable');
//myButton.button('enable');
//$('#uf_listing .loadAnim').hide();
}
}); //end ajax
//form is not valid
} else {
$.showMsg({
msg:err_msg,
type: 'error'});
}
}
/**
* construct and set language and theme select
*/
function constructSelects(){
//load available languages
$("#languageSelect")
.xml2html("init", {
url: "php/ctrl/SmallQ.php",
params : "oper=getExistingLanguages",
rowName : "language",
loadOnInit: true,
complete : function(s){
//copy the language select with the right option selected
var selectedLang = $('.memberLanguageSelect').prev().text();
var langSelect = $('#languageSelect').clone();
$(langSelect).val(selectedLang).attr('selected','selected');
$('.memberLanguageSelect').append(langSelect);
}
});
//load available themes
$("#themeSelect")
.xml2html("init", {
url: "php/ctrl/SmallQ.php",
params : "oper=getExistingThemes",
rowName : "theme",
loadOnInit: true,
complete : function(s){
//copy the theme select with the right option selected
var selectedTheme = $('.memberThemeSelect').prev().text();
var themeSelect = $('#themeSelect').clone();
$(themeSelect).val(selectedTheme).attr('selected','selected');
$('.memberThemeSelect').append(themeSelect);
}
});
}
/*******************************************
* PASSWORD CHANGE
*******************************************/
//send pwd edit form
$('#change_pwd').submit(function(){
var dataSerial = $(this).serialize();
var isValid = true;
var err_msg = '';
var mi = '#change_pwd';
isValid = isValid && $.checkFormLength($(mi+' input[name=password]'),4,15);
if (!isValid){
err_msg += "<?=$Text['msg_err_passshort'];?><br/><br/>" ;
}
isValid = isValid && $.checkPassword($(mi+' input[name=password]'), $('input[name=password_ctrl]'));
if (!isValid){
err_msg += "<?=$Text['msg_err_pwdctrl']; ?>";
}
if (isValid){
$.ajax({
type: "POST",
url: "php/ctrl/UserAndUf.php?oper=changePassword",
data: dataSerial,
beforeSend: function(){
$('#pwdWrap .loadAnim').show();
},
success: function(msg){
$.showMsg({
msg: "<?=$Text['msg_pwd_changed_success'];?>",
type: 'success'});
},
error : function(XMLHttpRequest, textStatus, errorThrown){
$.showMsg({
msg: XMLHttpRequest.responseText,
type: 'error'});
},
complete : function(msg){
$('#pwdWrap .loadAnim').hide();
}
});
} else {
$.showMsg({
msg:err_msg,
type: 'error'});
}
return false;
});//end submit
}); //close document ready
</script>
</head>
<body>
<div id="wrap">
<div id="headwrap">
<?php include "php/inc/menu.inc.php" ?>
</div>
<!-- end of headwrap -->
<div id="stagewrap" class="<?= negative_balances_stagewrap_class() ?>">
<div id="titlewrap" class="ui-widget">
<div id="titleLeftCol">
<h1><?=$Text['ti_my_account']; ?></h1>
</div>
</div>
<div id="pwdWrap" class="ui-widget changePwdElements">
<div class="ui-widget-content ui-corner-all">
<h3 class="ui-widget-header ui-corner-all"><?php echo $Text['nav_changepwd'];?> <span class="loadAnim floatRight hidden"><img src="img/ajax-loader.gif"/></span></h3>
<form id="change_pwd" class="padding15x10">
<table>
<tr>
<td><label class="formLabel" for="old_password"><?=$Text['old_pwd'];?>:</label></td>
<td><input type="password" class="ui-widget-content ui-corner-all" name="old_password" id="old_password"></td>
</tr>
<tr>
<td> </td>
<td></td>
</tr>
<tr>
<td><label class="formLabel" for="reg_password"><?=$Text['pwd'];?>:</label></td>
<td><input type="password" class="ui-widget-content ui-corner-all" name="password" id="reg_password"></td>
</tr>
<tr>
<td><label class="formLabel" for="reg_password_ctrl"><?=$Text['retype_pwd'];?>:</label></td>
<td><input type="password" class="ui-widget-content ui-corner-all " name="password_ctrl" id="reg_password_ctrl"></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><p class="floatRight"><button id="btn_pwd_cancel" type="reset"><?php echo $Text['btn_cancel'];?></button> <button id="btn_pwd_save" type="submit"><?php echo $Text['btn_save'];?></button></p></td>
</tr>
</table>
</form>
</div>
</div>
<div id="edit_my_settings" class="ui-widget editMemberElements">
<div class="ui-widget-content ui-corner-all member-info" id="detail_member_{id}">
<h3 class="ui-widget-header ui-corner-all">
<span style="float:right; margin-top:-2px; margin-right:4px;"><img class="loadSpinner" src="img/ajax-loader.gif"/></span>
</h3>
<p> </p>
<form id="frm_save_member_{id}">
<input type="hidden" name="member_id" value="{id}"/>
<input type="hidden" name="user_id" value="{user_id}"/>
<input type="hidden" name="uf_id" value="{uf_id}"/>
<?php include('php/inc/memberuf.inc.php');?>
</form>
</div><!-- end edit member -->
</div>
<!-- end of stage wrap -->
</div>
<!-- end of wrap -->
<div id="loadLanguageSelect" class="hidden">
<select id="languageSelect" name="language">
<option value="{id}"> {description}</option>
</select>
</div>
<div id="loadThemeSelect" class="hidden">
<select id="themeSelect" name="gui_theme">
<option value="{name}"> {name}</option>
</select>
</div>
<!-- / END -->
</body>
</html>