|
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 StatsUsers extends StatisticsPage |
|
16
|
|
|
{ |
|
17
|
|
|
protected function execute() |
|
18
|
|
|
{ |
|
19
|
|
|
if (!isset($_GET['user'])) { |
|
20
|
|
|
return $this->getUserList(); |
|
21
|
|
|
} |
|
22
|
|
|
else { |
|
23
|
|
|
return $this->getUserDetail($_GET['user']); |
|
24
|
|
|
} |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function getPageTitle() |
|
28
|
|
|
{ |
|
29
|
|
|
return "Account Creation Tool users"; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function getPageName() |
|
33
|
|
|
{ |
|
34
|
|
|
return "Users"; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function isProtected() |
|
38
|
|
|
{ |
|
39
|
|
|
return false; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
private function getUserList() |
|
43
|
|
|
{ |
|
44
|
|
|
$lists = array( |
|
45
|
|
|
"Admin" => User::getAllWithStatus("Admin", gGetDb()), |
|
46
|
|
|
"User" => User::getAllWithStatus("User", gGetDb()), |
|
47
|
|
|
"CheckUsers" => User::getAllCheckusers(gGetDb()) |
|
48
|
|
|
); |
|
49
|
|
|
|
|
50
|
|
|
global $smarty; |
|
51
|
|
|
$smarty->assign("lists", $lists); |
|
52
|
|
|
return $smarty->fetch("statistics/users.tpl"); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
private function getUserDetail($userId) |
|
56
|
|
|
{ |
|
57
|
|
|
$database = gGetDb(); |
|
58
|
|
|
|
|
59
|
|
|
$user = User::getById($userId, $database); |
|
60
|
|
|
if ($user == false) { |
|
61
|
|
|
return BootstrapSkin::displayAlertBox("User not found", "alert-error", "Error", true, false, true); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
global $smarty; |
|
65
|
|
|
|
|
66
|
|
|
$activitySummary = $database->prepare(<<<SQL |
|
67
|
|
|
SELECT COALESCE(closes.mail_desc, log.action) AS action, COUNT(*) AS count |
|
68
|
|
|
FROM log |
|
69
|
|
|
INNER JOIN user ON log.user = user.id |
|
70
|
|
|
LEFT JOIN closes ON log.action = closes.closes |
|
71
|
|
|
WHERE user.username = :username |
|
72
|
|
|
GROUP BY action; |
|
73
|
|
|
SQL |
|
74
|
|
|
); |
|
75
|
|
|
$activitySummary->execute(array(":username" => $user->getUsername())); |
|
|
|
|
|
|
76
|
|
|
$activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC); |
|
77
|
|
|
|
|
78
|
|
|
$smarty->assign("user", $user); |
|
79
|
|
|
$smarty->assign("activity", $activitySummaryData); |
|
80
|
|
|
|
|
81
|
|
|
$usersCreatedQuery = $database->prepare(<<<SQL |
|
82
|
|
|
SELECT log.timestamp time, request.name name, request.id id |
|
83
|
|
|
FROM log |
|
84
|
|
|
INNER JOIN request ON (request.id = log.objectid and log.objecttype = 'Request') |
|
85
|
|
|
INNER JOIN user ON log.user = user.id |
|
86
|
|
|
LEFT JOIN emailtemplate ON concat('Closed ', emailtemplate.id) = log.action |
|
87
|
|
|
WHERE user.username = :username |
|
88
|
|
|
AND log.action LIKE 'Closed %' |
|
89
|
|
|
AND (emailtemplate.oncreated = '1' OR log.action = 'Closed custom-y') |
|
90
|
|
|
ORDER BY log.timestamp; |
|
91
|
|
|
SQL |
|
92
|
|
|
); |
|
93
|
|
|
$usersCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
94
|
|
|
$usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
95
|
|
|
$smarty->assign("created", $usersCreated); |
|
96
|
|
|
|
|
97
|
|
|
$usersNotCreatedQuery = $database->prepare(<<<SQL |
|
98
|
|
|
SELECT log.timestamp time, request.name name, request.id id |
|
99
|
|
|
FROM log |
|
100
|
|
|
JOIN request ON request.id = log.objectid and log.objecttype = 'Request' |
|
101
|
|
|
JOIN user ON log.user = user.id |
|
102
|
|
|
LEFT JOIN emailtemplate ON concat('Closed ', emailtemplate.id) = log.action |
|
103
|
|
|
WHERE user.username = :username |
|
104
|
|
|
AND log.action LIKE 'Closed %' |
|
105
|
|
|
AND (emailtemplate.oncreated = '0' OR log.action = 'Closed custom-n' OR log.action = 'Closed 0') |
|
106
|
|
|
ORDER BY log.timestamp; |
|
107
|
|
|
SQL |
|
108
|
|
|
); |
|
109
|
|
|
$usersNotCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
110
|
|
|
$usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
111
|
|
|
$smarty->assign("notcreated", $usersNotCreated); |
|
112
|
|
|
|
|
113
|
|
|
$accountLogQuery = $database->prepare(<<<SQL |
|
114
|
|
|
SELECT |
|
115
|
|
|
user.username as log_user, |
|
116
|
|
|
log.action as log_action, |
|
117
|
|
|
log.timestamp as log_time, |
|
118
|
|
|
log.comment as log_cmt |
|
119
|
|
|
FROM log |
|
120
|
|
|
INNER JOIN user ON user.id = log.user |
|
121
|
|
|
WHERE log.objectid = :userid |
|
122
|
|
|
AND log.objecttype = 'User' |
|
123
|
|
|
AND log.action IN ('Approved','Suspended','Declined','Promoted','Demoted','Renamed','Prefchange'); |
|
124
|
|
|
SQL |
|
125
|
|
|
); |
|
126
|
|
|
$accountLogQuery->execute(array(":userid" => $user->getId())); |
|
127
|
|
|
$accountLog = $accountLogQuery->fetchAll(PDO::FETCH_ASSOC); |
|
128
|
|
|
$smarty->assign("accountlog", $accountLog); |
|
129
|
|
|
|
|
130
|
|
|
return $smarty->fetch("statistics/userdetail.tpl"); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
public function requiresWikiDatabase() |
|
134
|
|
|
{ |
|
135
|
|
|
return false; |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|