forked from svivian/q2a-user-activity-plus
-
Notifications
You must be signed in to change notification settings - Fork 3
/
qa-history-admin.php
548 lines (460 loc) · 13.3 KB
/
qa-history-admin.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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
<?php
class history_admin {
function allow_template($template)
{
return ($template!='admin');
}
function option_default($option) {
$idx = 0;
switch($option) {
/*
'u_login':
'u_logout':
*/
case 'user_act_list_tab':
return 'History';
case 'user_act_list_title':
return 'Recent History';
case 'user_act_list_new_text':
return '# new notification1/notifications';
case 'user_act_list_age':
return 30;
case 'user_act_list_max':
return 0;
case 'user_act_list_hide':
return 'in_u_block
in_u_edit
in_u_unblock';
case 'user_act_list_show':
return 'q_post
a_post
c_post';
case 'user_act_list_css':
return '.qa-history-item-table{
width:100%;
min-width:500px;
}
.qa-history-item-type-cell{
width:35%;
}
.qa-history-item-title-cell{
width:45%;
}
.qa-history-item-points-cell{
width:20%;
}
.qa-history-item-date {
background-color: #EEEEEE;
color: #999999;
float: left;
font: bold 10px Verdana,Sans-Serif;
letter-spacing: 0;
padding: 6px 10px;
text-align: center;
white-space: normal;
width: 45px;
}
.qa-history-item-date-new {
background-color: #FF0 !important;
}
.qa-history-item-date-no {
font-size:150%;
}
.qa-history-item-type {
font-weight: bold;
padding: 3px;
}
.qa-history-item-title a{
color: #555555 !important;
font-weight: bold;
}
.qa-history-item-points {
font-weight: bold;
font-family: sans-serif;
padding: 10px;
}
.qa-history-item-points-neg {
color: Maroon;
}
.qa-history-item-points-pos {
color: Green;
}
.qa-history-new-event-count {
background-color: yellow;
border: 1px solid #EEEE00;
border-radius: 4px 4px 4px 4px;
cursor: pointer;
font-size: 75%;
font-weight: bold;
padding: 1px 3px;
vertical-align: top;
}
';
// descriptions
case 'user_act_list_q_post':
return 'posted a question';
case 'user_act_list_a_post':
return 'posted an answer';
case 'user_act_list_c_post':
return 'posted a comment';
case 'user_act_list_q_edit':
return 'edited a question';
case 'user_act_list_a_edit':
return 'edited an answer';
case 'user_act_list_c_edit':
return 'edited a comment';
case 'user_act_list_q_hide':
return 'hid a question';
case 'user_act_list_a_hide':
return 'hid an answer';
case 'user_act_list_c_hide':
return 'hid a comment';
case 'user_act_list_q_reshow':
return 'reshowed a question';
case 'user_act_list_a_reshow':
return 'reshowed an answer';
case 'user_act_list_c_reshow':
return 'reshowed a comment';
case 'user_act_list_q_delete':
return 'deleted a question';
case 'user_act_list_a_delete':
return 'deleted an answer';
case 'user_act_list_c_delete':
return 'deleted a comment';
case 'user_act_list_q_move':
return 'moved a question';
case 'user_act_list_a_to_c':
return 'converted answer to comment';
case 'user_act_list_c_claim':
return 'claimed a comment';
case 'user_act_list_q_claim':
return 'claimed a question';
case 'user_act_list_a_claim':
return 'claimed an answer';
case 'user_act_list_c_claim':
return 'claimed a comment';
case 'user_act_list_q_flag':
return 'flagged a question';
case 'user_act_list_a_flag':
return 'flagged an answer';
case 'user_act_list_c_flag':
return 'flagged a comment';
case 'user_act_list_q_unflag':
return 'unflagged a question';
case 'user_act_list_a_unflag':
return 'unflagged an answer';
case 'user_act_list_c_unflag':
return 'unflagged a comment';
case 'user_act_list_in_q_flag':
return 'question flagged';
case 'user_act_list_in_a_flag':
return 'answer flagged';
case 'user_act_list_in_c_flag':
return 'comment flagged';
case 'user_act_list_in_q_unflag':
return 'question unflagged';
case 'user_act_list_in_a_unflag':
return 'answer unflagged';
case 'user_act_list_in_c_unflag':
return 'comment unflagged';
case 'user_act_list_a_select':
return 'selected a best answer';
case 'user_act_list_a_unselect':
return 'deselected best answer';
case 'user_act_list_in_a_select':
return 'answer selected as best';
case 'user_act_list_in_a_unselect':
return 'answer deselected as best';
case 'user_act_list_in_q_vote_up':
return 'question voted up';
case 'user_act_list_in_q_vote_down':
return 'question voted down';
case 'user_act_list_in_a_vote_up':
return 'answer voted up';
case 'user_act_list_in_a_vote_down':
return 'answer voted down';
case 'user_act_list_q_vote_up':
return 'voted up a question';
case 'user_act_list_q_vote_down':
return 'voted down a question';
case 'user_act_list_a_vote_up':
return 'voted up an answer';
case 'user_act_list_a_vote_down':
return 'voted down an answer';
case 'user_act_list_q_vote_nil':
return 'unvoted a question';
case 'user_act_list_a_vote_nil':
return 'unvoted an answer';
case 'user_act_list_in_q_vote_nil':
return 'question unvoted';
case 'user_act_list_in_a_vote_nil':
return 'answer unvoted';
// special
case 'user_act_list_in_a_question':
return 'question answered';
case 'user_act_list_in_c_question':
return 'question commented on';
case 'user_act_list_in_c_answer':
return 'answer commented on';
case 'user_act_list_u_password':
return 'set password';
case 'user_act_list_u_reset':
return 'reset password';
case 'user_act_list_u_save':
return 'edited profile';
case 'user_act_list_u_confirmed':
return 'confirmed email';
case 'user_act_list_u_edit':
return 'edited profile of';
case 'user_act_list_u_level':
return 'changed level of';
case 'user_act_list_u_block':
return 'blocked user';
case 'user_act_list_u_unblock':
return 'unblocked user';
case 'user_act_list_in_u_edit':
return 'profile edited';
case 'user_act_list_in_u_level':
return 'level changed to:';
case 'user_act_list_in_u_block':
return 'blocked';
case 'user_act_list_in_u_unblock':
return 'unblocked';
case 'user_act_list_feedback':
return 'sent feedback';
case 'user_act_list_search':
return 'searched for:';
case 'user_act_list_u_register':
return 'registered';
default:
return null;
}
}
function admin_form(&$qa_content)
{
$field_names = array(
'q_post',
'a_post',
'c_post',
'q_edit',
'a_edit',
'c_edit',
'q_hide',
'a_hide',
'c_hide',
'q_reshow',
'a_reshow',
'c_reshow',
'q_delete',
'a_delete',
'c_delete',
'q_move',
'a_to_c',
'c_claim',
'q_claim',
'a_claim',
'c_claim',
'q_flag',
'a_flag',
'c_flag',
'q_unflag',
'a_unflag',
'c_unflag',
'in_q_flag',
'in_a_flag',
'in_c_flag',
'in_q_unflag',
'in_a_unflag',
'in_c_unflag',
'a_select',
'a_unselect',
'in_a_select',
'in_a_unselect',
'q_vote_up',
'q_vote_down',
'a_vote_up',
'a_vote_down',
'q_vote_nil',
'a_vote_nil',
'in_q_vote_up',
'in_q_vote_down',
'in_a_vote_up',
'in_a_vote_down',
'in_q_vote_nil',
'in_a_vote_nil',
'u_password',
'u_reset',
'u_save',
'u_confirmed',
'u_edit',
'u_level',
'u_block',
'u_unblock',
'in_u_edit',
'in_u_level',
'in_u_block',
'in_u_unblock',
'feedback',
'search',
'u_register',
);
// Process form input
$ok = null;
$error = null;
if (qa_clicked('user_act_list_save')) {
if((bool)qa_post_text('user_act_list_active') && !qa_opt('event_logger_to_database')) {
$error = 'Activity List requires activation of event logging to database via Event Logging plugin. Please select "Log events to qa_eventlog database table" via that plugin and try again.';
qa_opt('user_act_list_active',false);
}
else {
$table_exists = qa_db_read_one_value(qa_db_query_sub("SHOW TABLES LIKE '^usermeta'"),true);
if(!$table_exists) {
qa_db_query_sub(
'CREATE TABLE IF NOT EXISTS ^usermeta (
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
user_id bigint(20) unsigned NOT NULL,
meta_key varchar(255) DEFAULT NULL,
meta_value longtext,
PRIMARY KEY (meta_id),
UNIQUE (user_id,meta_key)
) ENGINE=MyISAM DEFAULT CHARSET=utf8'
);
}
qa_opt('user_act_list_active',(bool)qa_post_text('user_act_list_active'));
qa_opt('user_act_list_replace',(bool)qa_post_text('user_act_list_replace'));
qa_opt('user_act_list_new',(bool)qa_post_text('user_act_list_new'));
qa_opt('user_act_list_title',qa_post_text('user_act_list_title'));
qa_opt('user_act_list_tab',qa_post_text('user_act_list_tab'));
qa_opt('user_act_list_age',(int)qa_post_text('user_act_list_age'));
qa_opt('user_act_list_max',(int)qa_post_text('user_act_list_max'));
qa_opt('user_act_list_css',qa_post_text('user_act_list_css'));
qa_opt('user_act_list_shading',(bool)qa_post_text('user_act_list_shading'));
qa_opt('user_act_list_show',qa_post_text('user_act_list_show'));
qa_opt('user_act_list_hide',qa_post_text('user_act_list_hide'));
foreach($field_names as $field) {
qa_opt('user_act_list_'.$field,qa_post_text('user_act_list_'.$field));
}
$ok = qa_lang('admin/options_saved');
}
}
else if (qa_clicked('user_act_list_reset')) {
foreach($_POST as $i => $v) {
$def = $this->option_default($i);
if($def !== null) qa_opt($i,$def);
}
$ok = qa_lang('admin/options_reset');
}
// Create the form for display
$fields = array();
$fields[] = array(
'label' => 'Show user activity list',
'tags' => 'NAME="user_act_list_active"',
'value' => qa_opt('user_act_list_active'),
'type' => 'checkbox',
'error' => $error,
);
$fields[] = array(
'label' => 'Replace ordinary activity list',
'tags' => 'NAME="user_act_list_replace"',
'value' => qa_opt('user_act_list_replace'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Title for history list',
'tags' => 'NAME="user_act_list_title"',
'value' => qa_opt('user_act_list_title'),
);
$fields[] = array(
'label' => 'Title for history tab',
'tags' => 'NAME="user_act_list_tab"',
'value' => qa_opt('user_act_list_tab'),
);
$fields[] = array(
'label' => 'Age in days of oldest activity to show',
'tags' => 'NAME="user_act_list_age"',
'value' => qa_opt('user_act_list_age'),
'type' => 'number',
);
$fields[] = array(
'label' => 'Maximum number of entries to show',
'tags' => 'NAME="user_act_list_max"',
'value' => qa_opt('user_act_list_max'),
'type' => 'number',
);
$fields[] = array(
'label' => 'Activity types to hide from profile owner',
'tags' => 'NAME="user_act_list_hide"',
'value' => qa_opt('user_act_list_hide'),
'type' => 'textarea',
'note' => 'one per line, use event names (q_post, etc.) below',
'rows' => 10
);
$fields[] = array(
'label' => 'Activity types to show to public',
'tags' => 'NAME="user_act_list_show"',
'value' => qa_opt('user_act_list_show'),
'type' => 'textarea',
'note' => 'one per line, use event names (q_post, etc.) below',
'rows' => 10
);
$fields[] = array(
'type' => 'blank',
);
$fields[] = array(
'label' => 'Show new incoming events notification',
'tags' => 'NAME="user_act_list_new"',
'value' => qa_opt('user_act_list_new'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Tooltip text for new event notification bubble',
'tags' => 'NAME="user_act_list_new_text"',
'value' => qa_opt('user_act_list_new_text'),
'note' => '# will be replaced by event number, word1/word2/word is for singular/dual/plural, etc. (number signifies max number for use - last word is default)',
);
$fields[] = array(
'type' => 'blank',
);
$fields[] = array(
'label' => 'Activity list custom css',
'tags' => 'NAME="user_act_list_css"',
'value' => qa_opt('user_act_list_css'),
'type' => 'textarea',
'rows' => 20
);
$fields[] = array(
'label' => 'Use date shading based on age?',
'tags' => 'NAME="user_act_list_shading"',
'value' => qa_opt('user_act_list_shading'),
'type' => 'checkbox',
);
$fields[] = array(
'type' => 'blank',
);
$fields[] = array(
'type' => 'static',
'label' => '<input type="button" value="edit event descriptions" onclick="jQuery(\'#user_act_values\').toggle()"><table style="display:none" id="user_act_values"><tr><td>',
);
foreach($field_names as $field) {
$fields[] = array('label'=>$field,'tags'=>'NAME="user_act_list_'.$field.'"','value'=>qa_opt('user_act_list_'.$field));
}
$fields[] = array(
'type' => 'static',
'label' => '</td></tr></table>',
);
return array(
'ok' => ($ok && !isset($error)) ? $ok : null,
'fields' => $fields,
'buttons' => array(
array(
'label' => qa_lang_html('main/save_button'),
'tags' => 'NAME="user_act_list_save"',
),
array(
'label' => qa_lang_html('admin/reset_options_button'),
'tags' => 'NAME="user_act_list_reset"',
),
),
);
}
}