forked from Code4SierraLeone/MembaO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.php
408 lines (405 loc) · 17 KB
/
users.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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
<?php
/**
* Users
*
* @package Visible Polls
* @author Alan Kawamara
* @copyright 2016
*/
if (!defined("_VALID_PHP"))
die('Direct access to this location is not allowed.');
?>
<?php switch(Filter::$action): case "edit": ?>
<?php $row = Core::getRowById(Users::uTable, Filter::$id);?>
<div class="corporato form segment">
<div class="corporato top right attached label"><?php echo Lang::$word->USR_SUB;?> / <?php echo $row->username;?></div>
<form id="corporato_form" name="corporato_form" method="post">
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->USERNAME;?></label>
<label class="input state-disabled"> <i class="icon-append icon asterisk"></i>
<input type="text" disabled="disabled" name="username" readonly value="<?php echo $row->username;?>">
</label>
</div>
<div class="field">
<label><?php echo Lang::$word->PASSWORD;?></label>
<label class="input"> <i class="icon-prepend icon-lock"></i>
<input type="text" name="password">
</label>
</div>
</div>
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->FNAME;?></label>
<label class="input"> <i class="icon-append icon asterisk"></i>
<input type="text" name="fname" value="<?php echo $row->fname;?>" >
</label>
</div>
<div class="field">
<label><?php echo Lang::$word->LNAME;?></label>
<label class="input"> <i class="icon-append icon asterisk"></i>
<input type="text" name="lname" value="<?php echo $row->lname;?>">
</label>
</div>
</div>
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->EMAIL;?></label>
<label class="input"><i class="icon-append icon asterisk"></i>
<input type="text" value="<?php echo $row->email;?>" name="email">
</label>
</div>
<div class="field">
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->USR_AVATAR;?></label>
<label class="input">
<input type="file" name="avatar" class="filefield">
</label>
</div>
<div class="field">
<label><?php echo Lang::$word->USR_AVATAR;?></label>
<div class="corporato avatar image">
<?php if($row->avatar):?>
<img src="<?php echo UPLOADURL;?>avatars/<?php echo $row->avatar;?>" alt="<?php echo $row->username;?>">
<?php else:?>
<img src="<?php echo UPLOADURL;?>avatars/blank.jpg" alt="<?php echo $row->username;?>">
<?php endif;?>
</div>
</div>
</div>
</div>
</div>
<div class="corporato divider"></div>
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->USR_LEVEL;?></label>
<div class="inline-group">
<label class="radio">
<input type="radio" name="userlevel" value="9" <?php getChecked($row->userlevel, 9); ?>>
<i></i><?php echo Lang::$word->USR_ADMIN;?></label>
<label class="radio">
<input type="radio" name="userlevel" value="1" <?php getChecked($row->userlevel, 1); ?>>
<i></i><?php echo Lang::$word->USER;?></label>
</div>
</div>
<div class="field">
<label><?php echo Lang::$word->USR_STATUS;?></label>
<div class="inline-group">
<label class="radio">
<input type="radio" name="active" value="y" <?php getChecked($row->active, "y"); ?>>
<i></i><?php echo Lang::$word->ACTIVE;?></label>
<label class="radio">
<input type="radio" name="active" value="n" <?php getChecked($row->active, "n"); ?>>
<i></i><?php echo Lang::$word->INACTIVE;?></label>
<label class="radio">
<input type="radio" name="active" value="b" <?php getChecked($row->active, "b"); ?>>
<i></i><?php echo Lang::$word->BANNED;?></label>
<label class="radio">
<input type="radio" name="active" value="t" <?php getChecked($row->active, "t"); ?>>
<i></i><?php echo Lang::$word->PENDING;?></label>
</div>
</div>
</div>
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->USR_REGDATE;?></label>
<input type="text" value="<?php echo Filter::dodate("long_date", $row->created);?>" name="created" disabled="disabled">
</div>
<div class="field">
<label><?php echo Lang::$word->USR_NEWS;?></label>
<div class="inline-group">
<label class="radio">
<input name="newsletter" type="radio" value="1" <?php echo getChecked($row->newsletter, 1);?>>
<i></i><?php echo Lang::$word->YES;?></label>
<label class="radio">
<input name="newsletter" type="radio" value="0" <?php echo getChecked($row->newsletter, 0);?>>
<i></i><?php echo Lang::$word->NO;?></label>
</div>
</div>
</div>
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->USR_BIO;?></label>
<textarea name="info"><?php echo $row->info;?></textarea>
</div>
<div class="field">
<label><?php echo Lang::$word->USR_NOTES;?></label>
<textarea name="notes"><?php echo $row->notes;?></textarea>
</div>
</div>
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->USR_LASTLOGIN;?></label>
<input type="text" value="<?php echo Filter::dodate("long_date", $row->lastlogin);?>" name="lastlogin" disabled="disabled">
</div>
<div class="field">
<label><?php echo Lang::$word->USR_LASTIP;?></label>
<input type="text" value="<?php echo $row->lastip;?>" name="lastip" disabled="disabled">
</div>
</div>
<div class="corporato fitted divider"></div>
<button type="button" name="dosubmit" class="corporato positive button"><i class="positive checkmark icon"></i>update user</button>
<a href="index.php?do=users" class="corporato danger button"><i class="remove icon"></i>cancel</a>
<input name="processUser" type="hidden" value="1">
<input name="username" type="hidden" value="<?php echo $row->username;?>" />
<input name="id" type="hidden" value="<?php echo Filter::$id;?>" />
</form>
</div>
<div id="msgholder"></div>
<?php break;?>
<?php case"add": ?>
<div class="corporato form segment">
<div class="corporato top right attached label"><?php echo Lang::$word->USR_SUB1;?></div>
<form id="corporato_form" name="corporato_form" method="post">
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->USERNAME;?></label>
<label class="input"><i class="icon-append icon asterisk"></i>
<input type="text" placeholder="<?php echo Lang::$word->USERNAME;?>" name="username">
</label>
</div>
<div class="field">
<label><?php echo Lang::$word->PASSWORD;?></label>
<input type="text" placeholder="<?php echo Lang::$word->PASSWORD;?>" name="password">
</div>
</div>
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->FNAME;?></label>
<label class="input"><i class="icon-append icon asterisk"></i>
<input type="text" placeholder="<?php echo Lang::$word->FNAME;?>" name="fname">
</label>
</div>
<div class="field">
<label><?php echo Lang::$word->LNAME;?></label>
<label class="input"><i class="icon-append icon asterisk"></i>
<input type="text" placeholder="<?php echo Lang::$word->LNAME;?>" name="lname">
</label>
</div>
</div>
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->EMAIL;?></label>
<label class="input"><i class="icon-append icon asterisk"></i>
<input type="text" placeholder="<?php echo Lang::$word->EMAIL;?>" name="email">
</label>
</div>
<div class="field">
<label><?php echo Lang::$word->USR_AVATAR;?></label>
<label class="input">
<input type="file" name="avatar" class="filefield">
</label>
</div>
</div>
<div class="corporato fitted divider"></div>
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->USR_LEVEL;?></label>
<div class="inline-group">
<label class="radio">
<input name="userlevel" type="radio" value="9" >
<i></i><?php echo Lang::$word->USR_ADMIN;?></label>
<label class="radio">
<input type="radio" name="userlevel" value="1" checked="checked">
<i></i><?php echo Lang::$word->USER;?></label>
</div>
</div>
<div class="field">
<label><?php echo Lang::$word->USR_STATUS;?></label>
<div class="inline-group">
<label class="radio">
<input name="active" type="radio" value="y" checked="checked" >
<i></i><?php echo Lang::$word->ACTIVE;?></label>
<label class="radio">
<input type="radio" name="active" value="n" >
<i></i><?php echo Lang::$word->INACTIVE;?></label>
<label class="radio">
<input type="radio" name="active" value="b" >
<i></i><?php echo Lang::$word->BANNED;?></label>
<label class="radio">
<input type="radio" name="active" value="t">
<i></i><?php echo Lang::$word->PENDING;?></label>
</div>
</div>
</div>
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->USR_BIO;?></label>
<textarea placeholder="<?php echo Lang::$word->USR_BIO;?>" name="info"></textarea>
</div>
<div class="field">
<label><?php echo Lang::$word->USR_NOTES;?></label>
<textarea placeholder="<?php echo Lang::$word->USR_NOTES;?>" name="notes"></textarea>
</div>
</div>
<div class="two fields">
<div class="field">
<label><?php echo Lang::$word->USR_NEWS;?></label>
<div class="inline-group">
<label class="radio">
<input name="newsletter" type="radio" value="1">
<i></i><?php echo Lang::$word->YES;?></label>
<label class="radio">
<input name="newsletter" type="radio" value="0" checked="checked">
<i></i><?php echo Lang::$word->NO;?></label>
</div>
</div>
<div class="field">
<label><?php echo Lang::$word->USR_NOTIFY;?></label>
<div class="inline-group">
<label class="checkbox">
<input name="notify" type="checkbox" value="1">
<i></i><?php echo Lang::$word->YES;?></label>
</div>
</div>
</div>
<div class="corporato fitted divider"></div>
<button type="button" name="dosubmit" class="corporato positive button"><i class="positive checkmark icon"></i>add user</button>
<a href="index.php?do=users" class="corporato danger button"><i class="remove icon"></i>cancel</a>
<input name="processUser" type="hidden" value="1">
</form>
</div>
<div id="msgholder"></div>
<?php break;?>
<?php default:?>
<?php $userrow = $user->getUsers();?>
<div class="corporato basic segment">
<div class="header"><a class="corporato button push-right" href="index.php?do=users&action=add"><i class="icon add"></i> <?php echo Lang::$word->USR_ADD;?></a><span><?php echo Lang::$word->USR_SUB2;?></span> </div>
<div class="corporato small segment form">
<form method="post" id="corporato_form" name="corporato_form">
<div class="four fields">
<div class="field">
<div class="corporato input"> <i class="icon-prepend icon calendar"></i>
<input name="fromdate" type="text" data-datepicker="true" placeholder="<?php echo Lang::$word->FROM;?>" id="fromdate" />
</div>
</div>
<div class="field">
<div class="corporato action input"> <i class="icon-prepend icon calendar"></i>
<input name="enddate" type="text" data-datepicker="true" placeholder="<?php echo Lang::$word->TO;?>" id="enddate" />
<a id="doDates" class="corporato icon button"><?php echo Lang::$word->FIND;?></a> </div>
</div>
<div class="field">
<div class="corporato icon input">
<input type="text" name="usersearchfield" placeholder="<?php echo Lang::$word->USR_SEARCHU;?>" id="searchfield" />
<i class="search icon"></i>
<div id="suggestions"> </div>
</div>
</div>
<div class="field">
<div class="two fields">
<div class="field"> <?php echo $pager->items_per_page();?> </div>
<div class="field"> <?php echo $pager->jump_menu();?> </div>
</div>
</div>
</div>
</form>
<div class="content-center"> <?php echo alphaBits('index.php?do=users', "letter");?> </div>
</div>
<table class="corporato basic sortable table">
<thead>
<tr>
<th data-sort="string"><?php echo Lang::$word->USERNAME;?></th>
<th data-sort="string"><?php echo Lang::$word->USR_FULLNAME;?></th>
<th data-sort="string"><?php echo Lang::$word->STATUS;?></th>
<th class="disabled push-right"><?php echo Lang::$word->ACTIONS;?></th>
</tr>
</thead>
<tbody>
<?php if(!$userrow):?>
<tr>
<td colspan="5"><?php echo Filter::msgSingleAlert(Lang::$word->USR_NOUSER);?></td>
</tr>
<?php else:?>
<?php foreach ($userrow as $row):?>
<tr>
<td><?php if($row->avatar):?>
<img src="<?php echo UPLOADURL;?>avatars/<?php echo $row->avatar;?>" alt="<?php echo $row->username;?>" class="corporato image avatar"/>
<?php else:?>
<img src="<?php echo UPLOADURL;?>avatars/blank.jpg" alt="<?php echo $row->username;?>" class="corporato image avatar"/>
<?php endif;?>
<a href="index.php?do=newsletter&emailid=<?php echo urlencode($row->email);?>"><?php echo $row->username;?></a></td>
<td><?php echo $row->name;?></td>
<td><?php echo userStatus($row->active, $row->id);?></td>
<td class="push-right"><a class="corporato purple button" href="index.php?do=users&action=edit&id=<?php echo $row->id;?>"><i class="purple icon pencil"></i>edit</a>
<?php if($row->id == 1):?>
<a class="delete corporato danger button"><i class="black remove icon"></i>delete</a>
<?php else:?>
<a class="delete corporato danger button" data-title="<?php echo Lang::$word->USR_DELUSER;?>" data-option="deleteUser" data-id="<?php echo $row->id;?>" data-name="<?php echo $row->username;?>"><i class="danger inverted remove icon"></i>delete</a>
<?php endif;?></td>
</tr>
<?php endforeach;?>
<?php unset($row);?>
<?php endif;?>
</tbody>
</table>
</div>
<div class="corporato divider"></div>
<div class="two columns">
<div class="row"> <span class="corporato label"><?php echo Lang::$word->TOTAL . ': ' . $pager->items_total;?> / <?php echo Lang::$word->CURPAGE . ': ' . $pager->current_page . ' ' . Lang::$word->OF . ' ' . $pager->num_pages;?></span> </div>
<div class="row">
<div class="push-right"><?php echo $pager->display_pages();?></div>
</div>
</div>
<script type="text/javascript">
// <![CDATA[
$(document).ready(function () {
/* == User Search == */
$("#searchfield").on('keyup', function () {
var srch_string = $(this).val();
var data_string = 'userSearch=' + srch_string;
if (srch_string.length > 4) {
$.ajax({
type: "post",
url: "controller.php",
data: data_string,
beforeSend: function () {
},
success: function (res) {
$('#suggestions').html(res).show();
$("input").blur(function () {
$('#suggestions').fadeOut();
});
}
});
}
return false;
});
$('a.activate').on('click', function () {
var uid = $(this).data('id')
var text = "<div class=\"messi-warning\"><i class=\"massive icon warn warning sign\"></i></p><p><?php echo Lang::$word->USR_ACCT1;?><br /><strong><?php echo Lang::$word->USR_ACCT2;?></strong></p></div>";
new Messi(text, {
title: "<?php echo Lang::$word->USR_ACCT;?>",
modal: true,
closeButton: true,
buttons: [{
id: 0,
label: "<?php echo Lang::$word->ACTIVATE;?>",
val: 'Y',
class: 'positive'
}],
callback: function (val) {
$.ajax({
type: 'post',
ataType: 'json',
url: "controller.php",
data: {
activateAccount: 1,
id: uid,
},
cache: false,
success: function (json) {
$.sticky(decodeURIComponent(json.message), {
type: json.type,
title: json.title
});
}
});
}
});
});
});
// ]]>
</script>
<?php break;?>
<?php endswitch;?>