forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserBasicInfo.php
354 lines (332 loc) · 14.1 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
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
<style>
.file-caption{
padding: 6px 12px !important;
}
.file-preview-frame,.krajee-default.file-preview-frame .kv-file-content {
width: 95%;
height: auto;
}
</style>
<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) {
avideoAlert("<?php echo __("Sorry!"); ?>", response.msg, "error");
} else {
avideoAlert("<?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">
<?php
getInputPassword("inputPassword", 'class="form-control" autocomplete="off"', __("New Password"));
?>
</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">
<?php
getInputPassword("inputPasswordConfirm", 'class="form-control" autocomplete="off"', __("Confirm New Password"));
?>
</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="row">
<div class="col-sm-3">
<div class="panel panel-default">
<div class="panel-heading"><?php echo __("Profile Photo"); ?><br><small><?php echo __("You must click save to confirm"); ?></small></div>
<div class="panel-body">
<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 class="alert alert-info">
<?php echo __("Make sure you click on the Save button after change the photo"); ?>
</div>
</div>
<input type="file" id="upload" value="Choose a file" accept="image/*" style="display: none;" />
</div>
</div>
</div>
</div>
<div class="col-sm-9">
<div class="panel panel-default">
<div class="panel-heading"><?php echo __("Channel Art"); ?><br>
<small><?php echo __("For the best results, please Use this image as a guide to create your Channel Art"); ?></small>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-7">
<input id="input-jpg" type="file" class="file-loading" accept="image/*">
</div>
<div class="col-sm-5">
<img src="<?php echo $global['webSiteRootURL']; ?>view/img/sampleGuide.png" class="img img-responsive">
<hr>
<b><?php echo __("minImageWidth"); ?>:</b> 2048px<br>
<b><?php echo __("minImageHeight"); ?>:</b> 1152px<br>
<b><?php echo __("maxImageWidth"); ?>:</b> 2560px<br>
<b><?php echo __("maxImageHeight"); ?>:</b> 1440px<br>
</div>
</div>
</div>
</div>
</div>
</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 {
avideoAlert("Sorry - you're browser doesn't support the FileReader API");
}
}
function updateUserFormSubmit() {
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>objects/userUpdate.json.php?do_not_login=1',
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("SavePersonal");
modal.hidePleaseWait();
<?php if (empty($advancedCustomUser->disablePersonalInfo)) { ?>
savePersonalInfo();
<?php } ?>
}
});
});
} else if (response.error) {
avideoAlert("<?php echo __("Sorry!"); ?>", response.error, "error");
modal.hidePleaseWait();
} else {
avideoAlert("<?php echo __("Sorry!"); ?>", "<?php echo __("Your user has NOT been updated!"); ?>", "error");
modal.hidePleaseWait();
}
}
});
}
$(document).ready(function () {
$("#input-jpg").fileinput({
uploadUrl: "<?php echo $global['webSiteRootURL']; ?>objects/uploadChannelArt.php",
autoReplace: true,
overwriteInitial: true,
showUploadedThumbs: false,
showPreview: true,
maxFileCount: 1,
initialPreview: [
"<img class='img img-responsive' src='<?php echo $global['webSiteRootURL'], User::getBackgroundURLFromUserID(User::getId()); ?>'>",
],
initialCaption: 'channelArt.jpg',
initialPreviewShowDelete: false,
showRemove: false,
showClose: false,
layoutTemplates: {actionDelete: ''}, // disable thumbnail deletion
allowedFileExtensions: ["jpg", "jpeg", "png"],
//minImageWidth: 2048,
//minImageHeight: 1152,
//maxImageWidth: 2560,
//maxImageHeight: 1440
});
$('#upload').on('change', function () {
readFile(this, uploadCrop);
});
$('#upload-btn').on('click', function (ev) {
$('#upload').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
}
});
$('#updateUserForm').submit(function (evt) {
evt.preventDefault();
if (!isAnalytics()) {
avideoAlert("<?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();
avideoAlert("<?php echo __("Sorry!"); ?>", "<?php echo __("Your password does not match!"); ?>", "error");
return false;
} else {
setTimeout(function () {
updateUserFormSubmit();
}, 1000);
return false;
}
});
});
</script>