forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
userBasicInfo.php
318 lines (295 loc) · 13.3 KB
/
userBasicInfo.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
<div class="form-group">
<label class="col-md-4 control-label"><?php echo __("Name"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i></span>
<input id="inputName" placeholder="<?php echo __("Name"); ?>" class="form-control" type="text" value="<?php echo $user->getName(); ?>" required >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo __("User"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="inputUser" placeholder="<?php echo !empty($advancedCustomUser->forceLoginToBeTheEmail) ? "[email protected]" : __("User"); ?>" class="form-control" type="<?php echo empty($advancedCustomUser->forceLoginToBeTheEmail)?"text":"email"?>" value="<?php echo $user->getUser(); ?>" required <?php echo (AVideoPlugin::isEnabledByName("LoginLDAP") || empty($advancedCustomUser->userCanChangeUsername))?"readonly":""; ?> >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo __("E-mail"); ?></label>
<div class="col-md-6 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
<input id="inputEmail" placeholder="<?php echo __("E-mail"); ?>" class="form-control" type="email" value="<?php echo $user->getEmail(); ?>" required
<?php if (!empty($advancedCustomUser->forceLoginToBeTheEmail)) {
echo "readonly";
} ?> >
</div>
</div>
<div class="col-md-2">
<?php
if ($user->getEmailVerified()) {
?>
<span class="btn btn-success"><i class="fa fa-check"></i> <?php echo __("E-mail Verified"); ?></span>
<?php
} else {
?>
<button class="btn btn-warning" id="verifyEmail"><i class="fa fa-envelope"></i> <?php echo __("Verify e-mail"); ?></button>
<script>
$(document).ready(function () {
$('#verifyEmail').click(function (e) {
e.preventDefault();
modal.showPleaseWait();
$.ajax({
type: "POST",
url: "<?php echo $global['webSiteRootURL'] ?>objects/userVerifyEmail.php?users_id=<?php echo $user->getBdId(); ?>"
}).done(function (response) {
if (response.error) {
swal("<?php echo __("Sorry!"); ?>", response.msg, "error");
} else {
swal("<?php echo __("Congratulations!"); ?>", "<?php echo __("Verification Sent"); ?>", "success");
}
modal.hidePleaseWait();
});
});
});
</script>
<?php
}
?>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo __("New Password"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="inputPassword" placeholder="<?php echo __("New Password"); ?>" class="form-control" type="password" value="" autocomplete="off" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo __("Confirm New Password"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="inputPasswordConfirm" placeholder="<?php echo __("Confirm New Password"); ?>" class="form-control" type="password" value="" autocomplete="off" >
</div>
</div>
</div>
<div class="form-group <?php if(!empty($advancedCustomUser->doNotShowMyChannelNameOnBasicInfo)){echo " hidden ";} ?>">
<label class="col-md-4 control-label"><?php echo __("Channel Name"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fas fa-play-circle"></i></span>
<input id="channelName" placeholder="<?php echo __("Channel Name"); ?>" class="form-control" type="text" value="<?php echo $user->getChannelName(); ?>" >
</div>
</div>
</div>
<div class="form-group <?php if(empty($advancedCustomUser->allowDonationLink)){echo " hidden ";} ?>">
<label class="col-md-4 control-label"><?php echo __("Donation Link"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fas fa-donate"></i></span>
<input id="donationLink" placeholder="<?php echo __("Donation Link"); ?>" class="form-control" type="url" value="<?php echo $user->getDonationLink(); ?>" >
</div>
</div>
</div>
<div class="form-group <?php if(!empty($advancedCustomUser->doNotShowMyAnalyticsCodeOnBasicInfo)){echo " hidden ";} ?>">
<label class="col-md-4 control-label"><?php echo __("Analytics Code"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fas fa-chart-line"></i></span>
<input id="analyticsCode" placeholder="UA-123456789-1" class="form-control" type="text" value="<?php echo $user->getAnalyticsCode(); ?>" >
</div>
<small><?php echo __("Track your videos with Google analytics"); ?></small>
</div>
</div>
<div class="form-group <?php if(!empty($advancedCustomUser->doNotShowMyAboutOnBasicInfo)){echo " hidden ";} ?> ">
<label class="col-md-4 control-label"><?php echo __("About"); ?></label>
<div class="col-md-8 inputGroupContainer">
<textarea id="textAbout" placeholder="<?php echo __("About"); ?>" class="form-control" ><?php echo $user->getAbout(); ?></textarea>
</div>
</div>
<?php
AVideoPlugin::getMyAccount(User::getId());
?>
<div class="form-group">
<div class="col-md-12 ">
<div id="croppie"></div>
<center>
<a id="upload-btn" class="btn btn-primary"><i class="fa fa-upload"></i> <?php echo __("Upload a Photo"); ?></a>
</center>
</div>
<input type="file" id="upload" value="Choose a file" accept="image/*" style="display: none;" />
</div>
<div class="form-group">
<div class="col-md-12 ">
<div id="croppieBg"></div>
<center>
<a id="upload-btnBg" class="btn btn-success"><i class="fa fa-upload"></i> <?php echo __("Upload a Background"); ?></a>
</center>
</div>
<input type="file" id="uploadBg" value="Choose a file" accept="image/*" style="display: none;" />
</div>
<script>
var uploadCrop;
function isAnalytics() {
return true;
str = $('#analyticsCode').val();
return str === '' || (/^ua-\d{4,9}-\d{1,4}$/i).test(str.toString());
}
function readFile(input, crop) {
console.log(input);
console.log($(input)[0]);
console.log($(input)[0].files);
if ($(input)[0].files && $(input)[0].files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
crop.croppie('bind', {
url: e.target.result
}).then(function () {
console.log('jQuery bind complete');
});
}
reader.readAsDataURL($(input)[0].files[0]);
} else {
swal("Sorry - you're browser doesn't support the FileReader API");
}
}
function updateUserFormSubmit() {
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>objects/userUpdate.json.php',
data: {
"user": $('#inputUser').val(),
"pass": $('#inputPassword').val(),
"email": $('#inputEmail').val(),
"name": $('#inputName').val(),
"about": $('#textAbout').val(),
"channelName": $('#channelName').val(),
"donationLink": $('#donationLink').val(),
"analyticsCode": $('#analyticsCode').val()
},
type: 'post',
success: function (response) {
if (response.status > "0") {
uploadCrop.croppie('result', {
type: 'canvas',
size: 'viewport'
}).then(function (resp) {
console.log("userSavePhoto");
$.ajax({
type: "POST",
url: "<?php echo $global['webSiteRootURL']; ?>objects/userSavePhoto.php",
data: {
imgBase64: resp
},
success: function () {
console.log("userSaveBackground");
uploadCropBg.croppie('result', {
type: 'canvas',
size: 'viewport'
}).then(function (resp) {
$.ajax({
type: "POST",
url: "<?php echo $global['webSiteRootURL']; ?>objects/userSaveBackground.php",
data: {
imgBase64: resp
}, success: function (response) {
console.log("SavePersonal");
modal.hidePleaseWait();
<?php if (empty($advancedCustomUser->disablePersonalInfo)) { ?>
savePersonalInfo();
<?php } ?>
}
});
});
}
});
});
} else if (response.error) {
swal("<?php echo __("Sorry!"); ?>", response.error, "error");
modal.hidePleaseWait();
} else {
swal("<?php echo __("Sorry!"); ?>", "<?php echo __("Your user has NOT been updated!"); ?>", "error");
modal.hidePleaseWait();
}
}
});
}
$(document).ready(function () {
$('#upload').on('change', function () {
readFile(this, uploadCrop);
});
$('#upload-btn').on('click', function (ev) {
$('#upload').trigger("click");
});
$('#uploadBg').on('change', function () {
readFile(this, uploadCropBg);
});
$('#upload-btnBg').on('click', function (ev) {
$('#uploadBg').trigger("click");
});
<?php
if (!empty($advancedCustomUser->forceLoginToBeTheEmail)) {
?>
$('#inputUser').on('keyup', function () {
$('#inputEmail').val($(this).val());
});
<?php
}
?>
uploadCrop = $('#croppie').croppie({
url: '<?php echo $user->getPhoto(); ?>',
enableExif: true,
enforceBoundary: false,
mouseWheelZoom: false,
viewport: {
width: 150,
height: 150
},
boundary: {
width: 150,
height: 150
}
});
uploadCropBg = $('#croppieBg').croppie({
url: '<?php echo $user->getBackgroundURL(); ?>',
enableExif: true,
enforceBoundary: false,
mouseWheelZoom: false,
viewport: {
width: 1250,
height: 250
},
boundary: {
width: 1250,
height: 250
}
});
$('#updateUserForm').submit(function (evt) {
evt.preventDefault();
if (!isAnalytics()) {
swal("<?php echo __("Sorry!"); ?>", "<?php echo __("Your analytics code is wrong"); ?>", "error");
$('#inputAnalyticsCode').focus();
return false;
}
$('#aBasicInfo').tab('show');
modal.showPleaseWait();
var pass1 = $('#inputPassword').val();
var pass2 = $('#inputPasswordConfirm').val();
// password dont match
if (pass1 != '' && pass1 != pass2) {
modal.hidePleaseWait();
swal("<?php echo __("Sorry!"); ?>", "<?php echo __("Your password does not match!"); ?>", "error");
return false;
} else {
setTimeout(function () {
updateUserFormSubmit();
}, 1000);
return false;
}
});
});
</script>