1
|
|
|
<?php |
2
|
|
|
/************************************************************************** |
3
|
|
|
********** English Wikipedia Account Request Interface ********** |
4
|
|
|
*************************************************************************** |
5
|
|
|
** Wikipedia Account Request Graphic Design by Charles Melbye, ** |
6
|
|
|
** which is licensed under a Creative Commons ** |
7
|
|
|
** Attribution-Noncommercial-Share Alike 3.0 United States License. ** |
8
|
|
|
** ** |
9
|
|
|
** All other code are released under the Public Domain ** |
10
|
|
|
** by the ACC Development Team. ** |
11
|
|
|
** ** |
12
|
|
|
** See CREDITS for the list of developers. ** |
13
|
|
|
***************************************************************************/ |
14
|
|
|
|
15
|
|
|
class StatsTopCreators extends StatisticsPage |
16
|
|
|
{ |
17
|
|
|
protected function execute() |
18
|
|
|
{ |
19
|
|
|
global $smarty; |
20
|
|
|
|
21
|
|
|
$qb = new QueryBrowser(); |
22
|
|
|
$qb->numberedList = true; |
23
|
|
|
$qb->numberedListTitle = "Position"; |
24
|
|
|
|
25
|
|
|
$qb->tableCallbackFunction = "statsTopCreatorsRowCallback"; |
|
|
|
|
26
|
|
|
$qb->overrideTableTitles = array("# Created", "Username"); |
27
|
|
|
|
28
|
|
|
// Retrieve all-time stats |
29
|
|
|
$top5aout = $qb->executeQueryToTable(<<<SQL |
30
|
|
|
SELECT |
31
|
|
|
/* StatsTopCreators::execute()/top5aout */ |
32
|
|
|
COUNT(*), |
33
|
|
|
log.user user_id, |
34
|
|
|
user.username log_user, |
35
|
|
|
user.status user_level |
36
|
|
|
FROM log |
37
|
|
|
LEFT JOIN emailtemplate ON concat('Closed ', emailtemplate.id) = log.action |
38
|
|
|
INNER JOIN user ON user.id = log.user |
39
|
|
|
WHERE emailtemplate.oncreated = '1' |
40
|
|
|
OR log.action = 'Closed custom-y' |
41
|
|
|
|
42
|
|
|
GROUP BY log.user, user.username, user.status |
43
|
|
|
ORDER BY COUNT(*) DESC; |
44
|
|
|
SQL |
45
|
|
|
); |
46
|
|
|
|
47
|
|
|
// Retrieve all-time stats for active users only |
48
|
|
|
$top5activeout = $qb->executeQueryToTable(<<<SQL |
49
|
|
|
SELECT |
50
|
|
|
/* StatsTopCreators::execute()/top5activeout */ |
51
|
|
|
COUNT(*), |
52
|
|
|
log.user user_id, |
53
|
|
|
user.username log_user, |
54
|
|
|
user.status user_level |
55
|
|
|
FROM log |
56
|
|
|
LEFT JOIN emailtemplate ON concat('Closed ', emailtemplate.id) = log.action |
57
|
|
|
INNER JOIN user ON user.id = log.user |
58
|
|
|
WHERE |
59
|
|
|
(emailtemplate.oncreated = 1 OR log.action = 'Closed custom-y') |
60
|
|
|
AND user.status != 'Suspended' |
61
|
|
|
GROUP BY user.username, user.id |
62
|
|
|
ORDER BY COUNT(*) DESC; |
63
|
|
|
SQL |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
// Retrieve today's stats (so far) |
67
|
|
|
$now = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"))); |
|
|
|
|
68
|
|
|
$top5out = $qb->executeQueryToTable(<<<SQL |
69
|
|
|
SELECT |
70
|
|
|
/* StatsTopCreators::execute()/top5out */ |
71
|
|
|
COUNT(*), |
72
|
|
|
log.user user_id, |
73
|
|
|
user.username log_user, |
74
|
|
|
user.status user_level |
75
|
|
|
FROM log |
76
|
|
|
INNER JOIN user ON user.id = log.user |
77
|
|
|
LEFT JOIN emailtemplate ON CONCAT('Closed ', emailtemplate.id) = log.action |
78
|
|
|
WHERE (emailtemplate.oncreated = '1' OR log.action = 'Closed custom-y') |
79
|
|
|
AND log.timestamp LIKE '{$now}%' |
80
|
|
|
GROUP BY log.user, user.username |
81
|
|
|
ORDER BY COUNT(*) DESC; |
82
|
|
|
SQL |
83
|
|
|
); |
84
|
|
|
|
85
|
|
|
// Retrieve Yesterday's stats |
86
|
|
|
$yesterday = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1)); |
87
|
|
|
$top5yout = $qb->executeQueryToTable(<<<SQL |
88
|
|
|
SELECT |
89
|
|
|
/* StatsTopCreators::execute()/top5yout */ |
90
|
|
|
COUNT(*), |
91
|
|
|
log.user user_id, |
92
|
|
|
user.username log_user, |
93
|
|
|
user.status user_level |
94
|
|
|
FROM log |
95
|
|
|
INNER JOIN user ON user.id = log.user |
96
|
|
|
LEFT JOIN emailtemplate ON CONCAT('Closed ', emailtemplate.id) = log.action |
97
|
|
|
WHERE (emailtemplate.oncreated = '1' OR log.action = 'Closed custom-y') |
98
|
|
|
AND log.timestamp LIKE '{$yesterday}%' |
99
|
|
|
GROUP BY log.user, user.username |
100
|
|
|
ORDER BY COUNT(*) DESC; |
101
|
|
|
SQL |
102
|
|
|
); |
103
|
|
|
|
104
|
|
|
// Retrieve last 7 days |
105
|
|
|
$lastweek = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 7)); |
106
|
|
|
$top5wout = $qb->executeQueryToTable(<<<SQL |
107
|
|
|
SELECT |
108
|
|
|
/* StatsTopCreators::execute()/top5wout */ |
109
|
|
|
COUNT(*), |
110
|
|
|
log.user user_id, |
111
|
|
|
user.username log_user, |
112
|
|
|
user.status user_level |
113
|
|
|
FROM log |
114
|
|
|
INNER JOIN user ON user.id = log.user |
115
|
|
|
LEFT JOIN emailtemplate ON CONCAT('Closed ', emailtemplate.id) = log.action |
116
|
|
|
WHERE (emailtemplate.oncreated = '1' OR log.action = 'Closed custom-y') |
117
|
|
|
AND log.timestamp > '{$lastweek}%' |
118
|
|
|
GROUP BY log.user, user.username |
119
|
|
|
ORDER BY COUNT(*) DESC; |
120
|
|
|
SQL |
121
|
|
|
); |
122
|
|
|
|
123
|
|
|
// Retrieve last month's stats |
124
|
|
|
$lastmonth = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 28)); |
125
|
|
|
$top5mout = $qb->executeQueryToTable(<<<SQL |
126
|
|
|
SELECT |
127
|
|
|
/* StatsTopCreators::execute()/top5mout */ |
128
|
|
|
COUNT(*), |
129
|
|
|
log.user user_id, |
130
|
|
|
user.username log_user, |
131
|
|
|
user.status user_level |
132
|
|
|
FROM log |
133
|
|
|
INNER JOIN user ON user.id = log.user |
134
|
|
|
LEFT JOIN emailtemplate ON CONCAT('Closed ', emailtemplate.id) = log.action |
135
|
|
|
WHERE (emailtemplate.oncreated = '1' OR log.action = 'Closed custom-y') |
136
|
|
|
AND log.timestamp > '{$lastmonth}%' |
137
|
|
|
GROUP BY log.user, user.username |
138
|
|
|
ORDER BY COUNT(*) DESC; |
139
|
|
|
SQL |
140
|
|
|
); |
141
|
|
|
|
142
|
|
|
// Put it all together |
143
|
|
|
$smarty->assign("top5aout", $top5aout); |
144
|
|
|
$smarty->assign("top5activeout", $top5activeout); |
145
|
|
|
$smarty->assign("top5out", $top5out); |
146
|
|
|
$smarty->assign("top5yout", $top5yout); |
147
|
|
|
$smarty->assign("top5wout", $top5wout); |
148
|
|
|
$smarty->assign("top5mout", $top5mout); |
149
|
|
|
|
150
|
|
|
return $smarty->fetch("statistics/topcreators.tpl"); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
public function getPageTitle() |
154
|
|
|
{ |
155
|
|
|
return "Top Account Creators"; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
public function getPageName() |
159
|
|
|
{ |
160
|
|
|
return "TopCreators"; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
public function isProtected() |
164
|
|
|
{ |
165
|
|
|
return false; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function requiresWikiDatabase() |
169
|
|
|
{ |
170
|
|
|
return false; |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
function statsTopCreatorsRowCallback($row, $rowno) |
175
|
|
|
{ |
176
|
|
|
$out = "<tr"; |
177
|
|
|
if ($row['log_user'] == User::getCurrent()->getUsername()) { |
178
|
|
|
$out .= ' class="info"'; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
$out .= '>'; |
182
|
|
|
|
183
|
|
|
$out .= '<td>' . $rowno . '</td>'; |
184
|
|
|
$out .= '<td>' . $row['COUNT(*)'] . '</td>'; |
185
|
|
|
|
186
|
|
|
global $baseurl; |
187
|
|
|
$out .= '<td><a '; |
188
|
|
|
|
189
|
|
|
if ($row['user_level'] == "Suspended") { |
190
|
|
|
$out .= 'class="muted" '; |
191
|
|
|
} |
192
|
|
|
if ($row['user_level'] == "Admin") { |
193
|
|
|
$out .= 'class="text-success" '; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
$out .= 'href="' . $baseurl . '/statistics.php?page=Users&user=' . $row['user_id'] . '">' . $row['log_user'] . '</a></td>'; |
197
|
|
|
|
198
|
|
|
$out .= '</tr>'; |
199
|
|
|
|
200
|
|
|
return $out; |
201
|
|
|
} |
202
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..