forked from NoahY/q2a-history
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqa-history-admin.php
398 lines (332 loc) · 8.88 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
<?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;
text-align:center;
}
.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-link {
text-decoration:none;
}
.qa-history-new-event-count {
background-color: yellow;
border: 1px solid #EEEE00;
color:black;
border-radius: 4px 4px 4px 4px;
cursor: pointer;
font-size: 75%;
font-weight: bold;
padding: 1px 3px;
vertical-align: top;
}
';
// descriptions
default:
return qa_lang('history/'.$option);
}
}
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',
'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',
'in_a_question',
'in_c_question',
'in_c_answer',
'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',
'badge_awarded',
);
// 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 {
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_new_text',qa_post_text('user_act_list_new_text'));
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,
'error' => $error,
'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"',
),
),
);
}
}