Completed
Pull Request — newinternal (#285)
by Simon
07:17 queued 04:17
created
includes/Pages/PageSearch.php 1 patch
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -19,157 +19,157 @@
 block discarded – undo
19 19
 
20 20
 class PageSearch extends InternalPageBase
21 21
 {
22
-    /**
23
-     * Main function for this page, when no specific actions are called.
24
-     */
25
-    protected function main()
26
-    {
27
-        $this->setHtmlTitle('Search');
28
-
29
-        // Dual-mode page
30
-        if (WebRequest::wasPosted()) {
31
-            $this->validateCSRFToken();
32
-
33
-            $searchType = WebRequest::postString('type');
34
-            $searchTerm = WebRequest::postString('term');
35
-
36
-            $validationError = "";
37
-            if (!$this->validateSearchParameters($searchType, $searchTerm, $validationError)) {
38
-                SessionAlert::error($validationError, "Search error");
39
-                $this->redirect("search");
40
-
41
-                return;
42
-            }
43
-
44
-            $results = array();
45
-
46
-            switch ($searchType) {
47
-                case 'name':
48
-                    $results = $this->getNameSearchResults($searchTerm);
49
-                    break;
50
-                case 'email':
51
-                    $results = $this->getEmailSearchResults($searchTerm);
52
-                    break;
53
-                case 'ip':
54
-                    $results = $this->getIpSearchResults($searchTerm);
55
-                    break;
56
-            }
57
-
58
-            // deal with results
59
-            $this->assign('requests', $results);
60
-            $this->assign('term', $searchTerm);
61
-            $this->assign('target', $searchType);
62
-
63
-            $userIds = array_map(
64
-                function(Request $entry) {
65
-                    return $entry->getReserved();
66
-                },
67
-                $results);
68
-            $userList = User::getUsernames($userIds, $this->getDatabase());
69
-            $this->assign('userlist', $userList);
70
-
71
-            $this->assignCSRFToken();
72
-            $this->setTemplate('search/searchResult.tpl');
73
-        }
74
-        else {
75
-            $this->assignCSRFToken();
76
-            $this->setTemplate('search/searchForm.tpl');
77
-        }
78
-    }
79
-
80
-    /**
81
-     * Gets search results by name
82
-     *
83
-     * @param string $searchTerm
84
-     *
85
-     * @returns Request[]
86
-     */
87
-    private function getNameSearchResults($searchTerm)
88
-    {
89
-        $padded = '%' . $searchTerm . '%';
90
-
91
-        return RequestSearchHelper::get($this->getDatabase())
92
-            ->byName($padded)
93
-            ->excludingPurgedData($this->getSiteConfiguration())
94
-            ->fetch();
95
-    }
96
-
97
-    /**
98
-     * Gets search results by email
99
-     *
100
-     * @param string $searchTerm
101
-     *
102
-     * @return Request[]
103
-     * @throws ApplicationLogicException
104
-     */
105
-    private function getEmailSearchResults($searchTerm)
106
-    {
107
-        if ($searchTerm === "@") {
108
-            throw new ApplicationLogicException('The search term "@" is not valid for email address searches!');
109
-        }
110
-
111
-        $padded = '%' . $searchTerm . '%';
112
-
113
-        return RequestSearchHelper::get($this->getDatabase())
114
-            ->byEmailAddress($padded)
115
-            ->excludingPurgedData($this->getSiteConfiguration())
116
-            ->fetch();
117
-    }
118
-
119
-    /**
120
-     * Gets search results by IP address or XFF IP address
121
-     *
122
-     * @param string $searchTerm
123
-     *
124
-     * @returns Request[]
125
-     */
126
-    private function getIpSearchResults($searchTerm)
127
-    {
128
-        return RequestSearchHelper::get($this->getDatabase())
129
-            ->byIp($searchTerm)
130
-            ->excludingPurgedData($this->getSiteConfiguration())
131
-            ->fetch();
132
-    }
133
-
134
-    /**
135
-     * Sets up the security for this page. If certain actions have different permissions, this should be reflected in
136
-     * the return value from this function.
137
-     *
138
-     * If this page even supports actions, you will need to check the route
139
-     *
140
-     * @return SecurityConfiguration
141
-     * @category Security-Critical
142
-     */
143
-    protected function getSecurityConfiguration()
144
-    {
145
-        return $this->getSecurityManager()->configure()->asInternalPage();
146
-    }
147
-
148
-    /**
149
-     * @param string $searchType
150
-     * @param string $searchTerm
151
-     *
152
-     * @param string $errorMessage
153
-     *
154
-     * @return bool true if parameters are valid
155
-     * @throws ApplicationLogicException
156
-     */
157
-    protected function validateSearchParameters($searchType, $searchTerm, &$errorMessage)
158
-    {
159
-        if (!in_array($searchType, array('name', 'email', 'ip'))) {
160
-            $errorMessage = 'Unknown search type';
161
-
162
-            return false;
163
-        }
164
-
165
-        if ($searchTerm === '%' || $searchTerm === '' || $searchTerm === null) {
166
-            $errorMessage = 'No search term specified entered';
167
-
168
-            return false;
169
-        }
170
-
171
-        $errorMessage = "";
172
-
173
-        return true;
174
-    }
22
+	/**
23
+	 * Main function for this page, when no specific actions are called.
24
+	 */
25
+	protected function main()
26
+	{
27
+		$this->setHtmlTitle('Search');
28
+
29
+		// Dual-mode page
30
+		if (WebRequest::wasPosted()) {
31
+			$this->validateCSRFToken();
32
+
33
+			$searchType = WebRequest::postString('type');
34
+			$searchTerm = WebRequest::postString('term');
35
+
36
+			$validationError = "";
37
+			if (!$this->validateSearchParameters($searchType, $searchTerm, $validationError)) {
38
+				SessionAlert::error($validationError, "Search error");
39
+				$this->redirect("search");
40
+
41
+				return;
42
+			}
43
+
44
+			$results = array();
45
+
46
+			switch ($searchType) {
47
+				case 'name':
48
+					$results = $this->getNameSearchResults($searchTerm);
49
+					break;
50
+				case 'email':
51
+					$results = $this->getEmailSearchResults($searchTerm);
52
+					break;
53
+				case 'ip':
54
+					$results = $this->getIpSearchResults($searchTerm);
55
+					break;
56
+			}
57
+
58
+			// deal with results
59
+			$this->assign('requests', $results);
60
+			$this->assign('term', $searchTerm);
61
+			$this->assign('target', $searchType);
62
+
63
+			$userIds = array_map(
64
+				function(Request $entry) {
65
+					return $entry->getReserved();
66
+				},
67
+				$results);
68
+			$userList = User::getUsernames($userIds, $this->getDatabase());
69
+			$this->assign('userlist', $userList);
70
+
71
+			$this->assignCSRFToken();
72
+			$this->setTemplate('search/searchResult.tpl');
73
+		}
74
+		else {
75
+			$this->assignCSRFToken();
76
+			$this->setTemplate('search/searchForm.tpl');
77
+		}
78
+	}
79
+
80
+	/**
81
+	 * Gets search results by name
82
+	 *
83
+	 * @param string $searchTerm
84
+	 *
85
+	 * @returns Request[]
86
+	 */
87
+	private function getNameSearchResults($searchTerm)
88
+	{
89
+		$padded = '%' . $searchTerm . '%';
90
+
91
+		return RequestSearchHelper::get($this->getDatabase())
92
+			->byName($padded)
93
+			->excludingPurgedData($this->getSiteConfiguration())
94
+			->fetch();
95
+	}
96
+
97
+	/**
98
+	 * Gets search results by email
99
+	 *
100
+	 * @param string $searchTerm
101
+	 *
102
+	 * @return Request[]
103
+	 * @throws ApplicationLogicException
104
+	 */
105
+	private function getEmailSearchResults($searchTerm)
106
+	{
107
+		if ($searchTerm === "@") {
108
+			throw new ApplicationLogicException('The search term "@" is not valid for email address searches!');
109
+		}
110
+
111
+		$padded = '%' . $searchTerm . '%';
112
+
113
+		return RequestSearchHelper::get($this->getDatabase())
114
+			->byEmailAddress($padded)
115
+			->excludingPurgedData($this->getSiteConfiguration())
116
+			->fetch();
117
+	}
118
+
119
+	/**
120
+	 * Gets search results by IP address or XFF IP address
121
+	 *
122
+	 * @param string $searchTerm
123
+	 *
124
+	 * @returns Request[]
125
+	 */
126
+	private function getIpSearchResults($searchTerm)
127
+	{
128
+		return RequestSearchHelper::get($this->getDatabase())
129
+			->byIp($searchTerm)
130
+			->excludingPurgedData($this->getSiteConfiguration())
131
+			->fetch();
132
+	}
133
+
134
+	/**
135
+	 * Sets up the security for this page. If certain actions have different permissions, this should be reflected in
136
+	 * the return value from this function.
137
+	 *
138
+	 * If this page even supports actions, you will need to check the route
139
+	 *
140
+	 * @return SecurityConfiguration
141
+	 * @category Security-Critical
142
+	 */
143
+	protected function getSecurityConfiguration()
144
+	{
145
+		return $this->getSecurityManager()->configure()->asInternalPage();
146
+	}
147
+
148
+	/**
149
+	 * @param string $searchType
150
+	 * @param string $searchTerm
151
+	 *
152
+	 * @param string $errorMessage
153
+	 *
154
+	 * @return bool true if parameters are valid
155
+	 * @throws ApplicationLogicException
156
+	 */
157
+	protected function validateSearchParameters($searchType, $searchTerm, &$errorMessage)
158
+	{
159
+		if (!in_array($searchType, array('name', 'email', 'ip'))) {
160
+			$errorMessage = 'Unknown search type';
161
+
162
+			return false;
163
+		}
164
+
165
+		if ($searchTerm === '%' || $searchTerm === '' || $searchTerm === null) {
166
+			$errorMessage = 'No search term specified entered';
167
+
168
+			return false;
169
+		}
170
+
171
+		$errorMessage = "";
172
+
173
+		return true;
174
+	}
175 175
 }
176 176
\ No newline at end of file
Please login to merge, or discard this patch.
includes/Pages/PageTeam.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -13,45 +13,45 @@
 block discarded – undo
13 13
 
14 14
 class PageTeam extends InternalPageBase
15 15
 {
16
-    /**
17
-     * Main function for this page, when no specific actions are called.
18
-     * @return void
19
-     */
20
-    protected function main()
21
-    {
22
-        $path = $this->getSiteConfiguration()->getFilePath() . '/team.json';
23
-        $json = file_get_contents($path);
24
-
25
-        $teamData = json_decode($json, true);
26
-
27
-        $active = array();
28
-        $inactive = array();
29
-
30
-        foreach ($teamData as $name => $item) {
31
-            if (count($item['Role']) == 0) {
32
-                $inactive[$name] = $item;
33
-            }
34
-            else {
35
-                $active[$name] = $item;
36
-            }
37
-        }
38
-
39
-        $this->assign('developer', $active);
40
-        $this->assign('inactiveDeveloper', $inactive);
41
-        $this->setTemplate('team/team.tpl');
42
-    }
43
-
44
-    /**
45
-     * Sets up the security for this page. If certain actions have different permissions, this should be reflected in
46
-     * the return value from this function.
47
-     *
48
-     * If this page even supports actions, you will need to check the route
49
-     *
50
-     * @return SecurityConfiguration
51
-     * @category Security-Critical
52
-     */
53
-    protected function getSecurityConfiguration()
54
-    {
55
-        return $this->getSecurityManager()->configure()->asPublicPage();
56
-    }
16
+	/**
17
+	 * Main function for this page, when no specific actions are called.
18
+	 * @return void
19
+	 */
20
+	protected function main()
21
+	{
22
+		$path = $this->getSiteConfiguration()->getFilePath() . '/team.json';
23
+		$json = file_get_contents($path);
24
+
25
+		$teamData = json_decode($json, true);
26
+
27
+		$active = array();
28
+		$inactive = array();
29
+
30
+		foreach ($teamData as $name => $item) {
31
+			if (count($item['Role']) == 0) {
32
+				$inactive[$name] = $item;
33
+			}
34
+			else {
35
+				$active[$name] = $item;
36
+			}
37
+		}
38
+
39
+		$this->assign('developer', $active);
40
+		$this->assign('inactiveDeveloper', $inactive);
41
+		$this->setTemplate('team/team.tpl');
42
+	}
43
+
44
+	/**
45
+	 * Sets up the security for this page. If certain actions have different permissions, this should be reflected in
46
+	 * the return value from this function.
47
+	 *
48
+	 * If this page even supports actions, you will need to check the route
49
+	 *
50
+	 * @return SecurityConfiguration
51
+	 * @category Security-Critical
52
+	 */
53
+	protected function getSecurityConfiguration()
54
+	{
55
+		return $this->getSecurityManager()->configure()->asPublicPage();
56
+	}
57 57
 }
58 58
\ No newline at end of file
Please login to merge, or discard this patch.
includes/Pages/Statistics/StatsTopCreators.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
13 13
 
14 14
 class StatsTopCreators extends InternalPageBase
15 15
 {
16
-    public function main()
17
-    {
18
-        $this->setHtmlTitle('Top Creators :: Statistics');
16
+	public function main()
17
+	{
18
+		$this->setHtmlTitle('Top Creators :: Statistics');
19 19
 
20
-        // Retrieve all-time stats
21
-        $queryAllTime = <<<SQL
20
+		// Retrieve all-time stats
21
+		$queryAllTime = <<<SQL
22 22
 SELECT
23 23
 	/* StatsTopCreators::execute()/queryAllTime */
24 24
     COUNT(*) count,
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 ORDER BY COUNT(*) DESC;
36 36
 SQL;
37 37
 
38
-        // Retrieve all-time stats for active users only
39
-        $queryAllTimeActive = <<<SQL
38
+		// Retrieve all-time stats for active users only
39
+		$queryAllTimeActive = <<<SQL
40 40
 SELECT
41 41
 	/* StatsTopCreators::execute()/queryAllTimeActive */
42 42
     COUNT(*) count,
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 ORDER BY COUNT(*) DESC;
54 54
 SQL;
55 55
 
56
-        // Retrieve today's stats (so far)
57
-        $queryToday = <<<SQL
56
+		// Retrieve today's stats (so far)
57
+		$queryToday = <<<SQL
58 58
 SELECT
59 59
 	/* StatsTopCreators::execute()/top5out */
60 60
     COUNT(*) count,
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 ORDER BY COUNT(*) DESC;
71 71
 SQL;
72 72
 
73
-        // Retrieve Yesterday's stats
74
-        $queryYesterday = <<<SQL
73
+		// Retrieve Yesterday's stats
74
+		$queryYesterday = <<<SQL
75 75
 SELECT
76 76
 	/* StatsTopCreators::execute()/top5yout */
77 77
     COUNT(*) count,
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 ORDER BY COUNT(*) DESC;
88 88
 SQL;
89 89
 
90
-        // Retrieve last 7 days
91
-        $queryLast7Days = <<<SQL
90
+		// Retrieve last 7 days
91
+		$queryLast7Days = <<<SQL
92 92
 SELECT
93 93
 	/* StatsTopCreators::execute()/top5wout */
94 94
     COUNT(*) count,
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 ORDER BY COUNT(*) DESC;
105 105
 SQL;
106 106
 
107
-        // Retrieve last month's stats
108
-        $queryLast28Days = <<<SQL
107
+		// Retrieve last month's stats
108
+		$queryLast28Days = <<<SQL
109 109
 SELECT
110 110
 	/* StatsTopCreators::execute()/top5mout */
111 111
     COUNT(*) count,
@@ -121,29 +121,29 @@  discard block
 block discarded – undo
121 121
 ORDER BY COUNT(*) DESC;
122 122
 SQL;
123 123
 
124
-        // Put it all together
125
-        $queries = array(
126
-            'queryAllTime'       => $queryAllTime,
127
-            'queryAllTimeActive' => $queryAllTimeActive,
128
-            'queryToday'         => $queryToday,
129
-            'queryYesterday'     => $queryYesterday,
130
-            'queryLast7Days'     => $queryLast7Days,
131
-            'queryLast28Days'    => $queryLast28Days,
132
-        );
124
+		// Put it all together
125
+		$queries = array(
126
+			'queryAllTime'       => $queryAllTime,
127
+			'queryAllTimeActive' => $queryAllTimeActive,
128
+			'queryToday'         => $queryToday,
129
+			'queryYesterday'     => $queryYesterday,
130
+			'queryLast7Days'     => $queryLast7Days,
131
+			'queryLast28Days'    => $queryLast28Days,
132
+		);
133 133
 
134
-        $database = $this->getDatabase();
135
-        foreach ($queries as $name => $sql) {
136
-            $statement = $database->query($sql);
137
-            $data = $statement->fetchAll(PDO::FETCH_ASSOC);
138
-            $this->assign($name, $data);
139
-        }
134
+		$database = $this->getDatabase();
135
+		foreach ($queries as $name => $sql) {
136
+			$statement = $database->query($sql);
137
+			$data = $statement->fetchAll(PDO::FETCH_ASSOC);
138
+			$this->assign($name, $data);
139
+		}
140 140
 
141
-        $this->assign('statsPageTitle', 'Top Account Creators');
142
-        $this->setTemplate('statistics/top-creators.tpl');
143
-    }
141
+		$this->assign('statsPageTitle', 'Top Account Creators');
142
+		$this->setTemplate('statistics/top-creators.tpl');
143
+	}
144 144
 
145
-    public function getSecurityConfiguration()
146
-    {
147
-        return $this->getSecurityManager()->configure()->asPublicPage();
148
-    }
145
+	public function getSecurityConfiguration()
146
+	{
147
+		return $this->getSecurityManager()->configure()->asPublicPage();
148
+	}
149 149
 }
150 150
\ No newline at end of file
Please login to merge, or discard this patch.
includes/Pages/Statistics/StatsFastCloses.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 
14 14
 class StatsFastCloses extends InternalPageBase
15 15
 {
16
-    public function main()
17
-    {
18
-        $this->setHtmlTitle('Fast Closes :: Statistics');
16
+	public function main()
17
+	{
18
+		$this->setHtmlTitle('Fast Closes :: Statistics');
19 19
 
20
-        $query = <<<SQL
20
+		$query = <<<SQL
21 21
 SELECT
22 22
   log_closed.objectid AS request,
23 23
   user.username AS user,
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
 ORDER BY TIMEDIFF(log_closed.timestamp, log_reserved.timestamp) ASC
43 43
 ;
44 44
 SQL;
45
-        $database = $this->getDatabase();
46
-        $statement = $database->query($query);
47
-        $data = $statement->fetchAll(PDO::FETCH_ASSOC);
48
-        $this->assign('dataTable', $data);
49
-        $this->assign('statsPageTitle', 'Requests closed less than 30 seconds after reservation in the past 3 months');
50
-        $this->setTemplate('statistics/fast-closes.tpl');
51
-    }
52
-
53
-    public function getSecurityConfiguration()
54
-    {
55
-        return $this->getSecurityManager()->configure()->asInternalPage();
56
-    }
45
+		$database = $this->getDatabase();
46
+		$statement = $database->query($query);
47
+		$data = $statement->fetchAll(PDO::FETCH_ASSOC);
48
+		$this->assign('dataTable', $data);
49
+		$this->assign('statsPageTitle', 'Requests closed less than 30 seconds after reservation in the past 3 months');
50
+		$this->setTemplate('statistics/fast-closes.tpl');
51
+	}
52
+
53
+	public function getSecurityConfiguration()
54
+	{
55
+		return $this->getSecurityManager()->configure()->asInternalPage();
56
+	}
57 57
 }
Please login to merge, or discard this patch.
includes/Pages/Statistics/StatsInactiveUsers.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -14,25 +14,25 @@
 block discarded – undo
14 14
 
15 15
 class StatsInactiveUsers extends InternalPageBase
16 16
 {
17
-    public function main()
18
-    {
19
-        $this->setHtmlTitle('Inactive Users :: Statistics');
17
+	public function main()
18
+	{
19
+		$this->setHtmlTitle('Inactive Users :: Statistics');
20 20
 
21
-        $showImmune = false;
22
-        if (WebRequest::getBoolean('showimmune')) {
23
-            $showImmune = true;
24
-        }
21
+		$showImmune = false;
22
+		if (WebRequest::getBoolean('showimmune')) {
23
+			$showImmune = true;
24
+		}
25 25
 
26
-        $this->assign('showImmune', $showImmune);
27
-        $inactiveUsers = User::getAllInactive($this->getDatabase());
28
-        $this->assign('inactiveUsers', $inactiveUsers);
26
+		$this->assign('showImmune', $showImmune);
27
+		$inactiveUsers = User::getAllInactive($this->getDatabase());
28
+		$this->assign('inactiveUsers', $inactiveUsers);
29 29
 
30
-        $this->setTemplate('statistics/inactive-users.tpl');
31
-        $this->assign('statsPageTitle', 'Inactive tool users');
32
-    }
30
+		$this->setTemplate('statistics/inactive-users.tpl');
31
+		$this->assign('statsPageTitle', 'Inactive tool users');
32
+	}
33 33
 
34
-    public function getSecurityConfiguration()
35
-    {
36
-        return $this->getSecurityManager()->configure()->asInternalPage();
37
-    }
34
+	public function getSecurityConfiguration()
35
+	{
36
+		return $this->getSecurityManager()->configure()->asInternalPage();
37
+	}
38 38
 }
Please login to merge, or discard this patch.
includes/Pages/Statistics/StatsUsers.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -19,52 +19,52 @@  discard block
 block discarded – undo
19 19
 
20 20
 class StatsUsers extends InternalPageBase
21 21
 {
22
-    public function main()
23
-    {
24
-        $this->setHtmlTitle('Users :: Statistics');
25
-
26
-        $database = $this->getDatabase();
27
-
28
-        $lists = array(
29
-            "Admin"      => User::getAllWithStatus("Admin", $database),
30
-            "User"       => User::getAllWithStatus("User", $database),
31
-            "CheckUsers" => User::getAllCheckusers($database),
32
-        );
33
-
34
-        $this->assign("lists", $lists);
35
-
36
-        $this->assign('statsPageTitle', 'Account Creation Tool users');
37
-        $this->setTemplate("statistics/users.tpl");
38
-    }
39
-
40
-    public function getSecurityConfiguration()
41
-    {
42
-        return $this->getSecurityManager()->configure()->asPublicPage();
43
-    }
44
-
45
-    /**
46
-     * Entry point for the detail action.
47
-     *
48
-     * @throws ApplicationLogicException
49
-     */
50
-    protected function detail()
51
-    {
52
-        $userId = WebRequest::getInt('user');
53
-        if ($userId === null) {
54
-            throw new ApplicationLogicException("User not found");
55
-        }
56
-
57
-        $database = $this->getDatabase();
58
-
59
-        $user = User::getById($userId, $database);
60
-        if ($user == false) {
61
-            throw new ApplicationLogicException('User not found');
62
-        }
63
-
64
-        $safeUsername = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8');
65
-        $this->setHtmlTitle($safeUsername . ' :: Users :: Statistics');
66
-
67
-        $activitySummary = $database->prepare(<<<SQL
22
+	public function main()
23
+	{
24
+		$this->setHtmlTitle('Users :: Statistics');
25
+
26
+		$database = $this->getDatabase();
27
+
28
+		$lists = array(
29
+			"Admin"      => User::getAllWithStatus("Admin", $database),
30
+			"User"       => User::getAllWithStatus("User", $database),
31
+			"CheckUsers" => User::getAllCheckusers($database),
32
+		);
33
+
34
+		$this->assign("lists", $lists);
35
+
36
+		$this->assign('statsPageTitle', 'Account Creation Tool users');
37
+		$this->setTemplate("statistics/users.tpl");
38
+	}
39
+
40
+	public function getSecurityConfiguration()
41
+	{
42
+		return $this->getSecurityManager()->configure()->asPublicPage();
43
+	}
44
+
45
+	/**
46
+	 * Entry point for the detail action.
47
+	 *
48
+	 * @throws ApplicationLogicException
49
+	 */
50
+	protected function detail()
51
+	{
52
+		$userId = WebRequest::getInt('user');
53
+		if ($userId === null) {
54
+			throw new ApplicationLogicException("User not found");
55
+		}
56
+
57
+		$database = $this->getDatabase();
58
+
59
+		$user = User::getById($userId, $database);
60
+		if ($user == false) {
61
+			throw new ApplicationLogicException('User not found');
62
+		}
63
+
64
+		$safeUsername = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8');
65
+		$this->setHtmlTitle($safeUsername . ' :: Users :: Statistics');
66
+
67
+		$activitySummary = $database->prepare(<<<SQL
68 68
 SELECT COALESCE(closes.mail_desc, log.action) AS action, COUNT(*) AS count
69 69
 FROM log
70 70
 INNER JOIN user ON log.user = user.id
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
 WHERE user.username = :username
73 73
 GROUP BY action;
74 74
 SQL
75
-        );
76
-        $activitySummary->execute(array(":username" => $user->getUsername()));
77
-        $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC);
75
+		);
76
+		$activitySummary->execute(array(":username" => $user->getUsername()));
77
+		$activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC);
78 78
 
79
-        $this->assign("user", $user);
80
-        $this->assign("activity", $activitySummaryData);
79
+		$this->assign("user", $user);
80
+		$this->assign("activity", $activitySummaryData);
81 81
 
82
-        $usersCreatedQuery = $database->prepare(<<<SQL
82
+		$usersCreatedQuery = $database->prepare(<<<SQL
83 83
 SELECT log.timestamp time, request.name name, request.id id
84 84
 FROM log
85 85
 INNER JOIN request ON (request.id = log.objectid AND log.objecttype = 'Request')
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
     AND (emailtemplate.oncreated = '1' OR log.action = 'Closed custom-y')
91 91
 ORDER BY log.timestamp;
92 92
 SQL
93
-        );
94
-        $usersCreatedQuery->execute(array(":username" => $user->getUsername()));
95
-        $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
96
-        $this->assign("created", $usersCreated);
93
+		);
94
+		$usersCreatedQuery->execute(array(":username" => $user->getUsername()));
95
+		$usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
96
+		$this->assign("created", $usersCreated);
97 97
 
98
-        $usersNotCreatedQuery = $database->prepare(<<<SQL
98
+		$usersNotCreatedQuery = $database->prepare(<<<SQL
99 99
 SELECT log.timestamp time, request.name name, request.id id
100 100
 FROM log
101 101
 JOIN request ON request.id = log.objectid AND log.objecttype = 'Request'
@@ -106,29 +106,29 @@  discard block
 block discarded – undo
106 106
     AND (emailtemplate.oncreated = '0' OR log.action = 'Closed custom-n' OR log.action = 'Closed 0')
107 107
 ORDER BY log.timestamp;
108 108
 SQL
109
-        );
110
-        $usersNotCreatedQuery->execute(array(":username" => $user->getUsername()));
111
-        $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
112
-        $this->assign("notcreated", $usersNotCreated);
113
-
114
-        /** @var Log[] $logs */
115
-        $logs = LogSearchHelper::get($database)
116
-            ->byObjectType('User')
117
-            ->byObjectId($user->getId())
118
-            ->getRecordCount($logCount)
119
-            ->fetch();
120
-
121
-        if ($logCount === 0) {
122
-            $this->assign('accountlog', array());
123
-        }
124
-        else {
125
-            list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration());
126
-
127
-            $this->assign("accountlog", $logData);
128
-            $this->assign("users", $users);
129
-        }
130
-
131
-        $this->assign('statsPageTitle', 'Account Creation Tool users');
132
-        $this->setTemplate("statistics/userdetail.tpl");
133
-    }
109
+		);
110
+		$usersNotCreatedQuery->execute(array(":username" => $user->getUsername()));
111
+		$usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
112
+		$this->assign("notcreated", $usersNotCreated);
113
+
114
+		/** @var Log[] $logs */
115
+		$logs = LogSearchHelper::get($database)
116
+			->byObjectType('User')
117
+			->byObjectId($user->getId())
118
+			->getRecordCount($logCount)
119
+			->fetch();
120
+
121
+		if ($logCount === 0) {
122
+			$this->assign('accountlog', array());
123
+		}
124
+		else {
125
+			list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration());
126
+
127
+			$this->assign("accountlog", $logData);
128
+			$this->assign("users", $users);
129
+		}
130
+
131
+		$this->assign('statsPageTitle', 'Account Creation Tool users');
132
+		$this->setTemplate("statistics/userdetail.tpl");
133
+	}
134 134
 }
Please login to merge, or discard this patch.
includes/Pages/Statistics/StatsMonthlyStats.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 
14 14
 class StatsMonthlyStats extends InternalPageBase
15 15
 {
16
-    public function main()
17
-    {
18
-        $this->setHtmlTitle('Monthly Stats :: Statistics');
16
+	public function main()
17
+	{
18
+		$this->setHtmlTitle('Monthly Stats :: Statistics');
19 19
 
20
-        $query = <<<SQL
20
+		$query = <<<SQL
21 21
 SELECT
22 22
     COUNT(DISTINCT id) AS closed,
23 23
     YEAR(timestamp) AS year,
@@ -28,17 +28,17 @@  discard block
 block discarded – undo
28 28
 ORDER BY YEAR(timestamp) , MONTH(timestamp) ASC;
29 29
 SQL;
30 30
 
31
-        $database = $this->getDatabase();
32
-        $statement = $database->query($query);
33
-        $data = $statement->fetchAll(PDO::FETCH_ASSOC);
31
+		$database = $this->getDatabase();
32
+		$statement = $database->query($query);
33
+		$data = $statement->fetchAll(PDO::FETCH_ASSOC);
34 34
 
35
-        $this->assign('dataTable', $data);
36
-        $this->assign('statsPageTitle', 'Monthly Statistics');
37
-        $this->setTemplate('statistics/monthly-stats.tpl');
38
-    }
35
+		$this->assign('dataTable', $data);
36
+		$this->assign('statsPageTitle', 'Monthly Statistics');
37
+		$this->setTemplate('statistics/monthly-stats.tpl');
38
+	}
39 39
 
40
-    public function getSecurityConfiguration()
41
-    {
42
-        return $this->getSecurityManager()->configure()->asInternalPage();
43
-    }
40
+	public function getSecurityConfiguration()
41
+	{
42
+		return $this->getSecurityManager()->configure()->asInternalPage();
43
+	}
44 44
 }
Please login to merge, or discard this patch.
includes/Pages/Statistics/StatsMain.php 1 patch
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -12,104 +12,104 @@
 block discarded – undo
12 12
 
13 13
 class StatsMain extends InternalPageBase
14 14
 {
15
-    public function main()
16
-    {
17
-        $this->setHtmlTitle('Statistics');
18
-
19
-        $this->assign('statsPageTitle', 'Account Creation Statistics');
20
-
21
-        $statsPages = array(
22
-            'fastCloses'       => 'Requests closed less than 30 seconds after reservation in the past 3 months',
23
-            'inactiveUsers'    => 'Inactive tool users',
24
-            'monthlyStats'     => 'Monthly Statistics',
25
-            'reservedRequests' => 'All currently reserved requests',
26
-            'templateStats'    => 'Template Stats',
27
-            'topCreators'      => 'Top Account Creators',
28
-            'users'            => 'Account Creation Tool users',
29
-        );
30
-
31
-        $this->generateSmallStatsTable();
32
-
33
-        $this->assign('statsPages', $statsPages);
34
-
35
-        $graphList = array('day', '2day', '4day', 'week', '2week', 'month', '3month');
36
-        $this->assign('graphList', $graphList);
37
-
38
-        $this->setTemplate('statistics/main.tpl');
39
-    }
40
-
41
-    /**
42
-     * Gets the relevant statistics from the database for the small statistics table
43
-     */
44
-    private function generateSmallStatsTable()
45
-    {
46
-        $database = $this->getDatabase();
47
-        $requestsQuery = <<<'SQL'
15
+	public function main()
16
+	{
17
+		$this->setHtmlTitle('Statistics');
18
+
19
+		$this->assign('statsPageTitle', 'Account Creation Statistics');
20
+
21
+		$statsPages = array(
22
+			'fastCloses'       => 'Requests closed less than 30 seconds after reservation in the past 3 months',
23
+			'inactiveUsers'    => 'Inactive tool users',
24
+			'monthlyStats'     => 'Monthly Statistics',
25
+			'reservedRequests' => 'All currently reserved requests',
26
+			'templateStats'    => 'Template Stats',
27
+			'topCreators'      => 'Top Account Creators',
28
+			'users'            => 'Account Creation Tool users',
29
+		);
30
+
31
+		$this->generateSmallStatsTable();
32
+
33
+		$this->assign('statsPages', $statsPages);
34
+
35
+		$graphList = array('day', '2day', '4day', 'week', '2week', 'month', '3month');
36
+		$this->assign('graphList', $graphList);
37
+
38
+		$this->setTemplate('statistics/main.tpl');
39
+	}
40
+
41
+	/**
42
+	 * Gets the relevant statistics from the database for the small statistics table
43
+	 */
44
+	private function generateSmallStatsTable()
45
+	{
46
+		$database = $this->getDatabase();
47
+		$requestsQuery = <<<'SQL'
48 48
 SELECT COUNT(*) FROM request WHERE status = :status AND emailconfirm = 'Confirmed';
49 49
 SQL;
50
-        $requestsStatement = $database->prepare($requestsQuery);
50
+		$requestsStatement = $database->prepare($requestsQuery);
51 51
 
52
-        $requestStates = $this->getSiteConfiguration()->getRequestStates();
52
+		$requestStates = $this->getSiteConfiguration()->getRequestStates();
53 53
 
54
-        $requestStateData = array();
54
+		$requestStateData = array();
55 55
 
56
-        foreach ($requestStates as $statusName => $data) {
57
-            $requestsStatement->execute(array(':status' => $statusName));
58
-            $requestCount = $requestsStatement->fetchColumn();
59
-            $requestsStatement->closeCursor();
60
-            $headerText = $data['header'];
61
-            $requestStateData[$headerText] = $requestCount;
62
-        }
56
+		foreach ($requestStates as $statusName => $data) {
57
+			$requestsStatement->execute(array(':status' => $statusName));
58
+			$requestCount = $requestsStatement->fetchColumn();
59
+			$requestsStatement->closeCursor();
60
+			$headerText = $data['header'];
61
+			$requestStateData[$headerText] = $requestCount;
62
+		}
63 63
 
64
-        $this->assign('requestCountData', $requestStateData);
64
+		$this->assign('requestCountData', $requestStateData);
65 65
 
66
-        // Unconfirmed requests
67
-        $unconfirmedStatement = $database->query(<<<SQL
66
+		// Unconfirmed requests
67
+		$unconfirmedStatement = $database->query(<<<SQL
68 68
 SELECT COUNT(*) FROM request WHERE emailconfirm != 'Confirmed' AND emailconfirm != '';
69 69
 SQL
70
-        );
71
-        $unconfirmed = $unconfirmedStatement->fetchColumn();
72
-        $unconfirmedStatement->closeCursor();
73
-        $this->assign('statsUnconfirmed', $unconfirmed);
74
-
75
-        $userStatusStatement = $database->prepare('SELECT COUNT(*) FROM user WHERE status = :status;');
76
-
77
-        // Admin users
78
-        $userStatusStatement->execute(array(':status' => 'Admin'));
79
-        $adminUsers = $userStatusStatement->fetchColumn();
80
-        $userStatusStatement->closeCursor();
81
-        $this->assign('statsAdminUsers', $adminUsers);
82
-
83
-        // Users
84
-        $userStatusStatement->execute(array(':status' => 'User'));
85
-        $users = $userStatusStatement->fetchColumn();
86
-        $userStatusStatement->closeCursor();
87
-        $this->assign('statsUsers', $users);
88
-
89
-        // Suspended users
90
-        $userStatusStatement->execute(array(':status' => 'Suspended'));
91
-        $suspendedUsers = $userStatusStatement->fetchColumn();
92
-        $userStatusStatement->closeCursor();
93
-        $this->assign('statsSuspendedUsers', $suspendedUsers);
94
-
95
-        // New users
96
-        $userStatusStatement->execute(array(':status' => 'New'));
97
-        $newUsers = $userStatusStatement->fetchColumn();
98
-        $userStatusStatement->closeCursor();
99
-        $this->assign('statsNewUsers', $newUsers);
100
-
101
-        // Most comments on a request
102
-        $mostCommentsStatement = $database->query(<<<SQL
70
+		);
71
+		$unconfirmed = $unconfirmedStatement->fetchColumn();
72
+		$unconfirmedStatement->closeCursor();
73
+		$this->assign('statsUnconfirmed', $unconfirmed);
74
+
75
+		$userStatusStatement = $database->prepare('SELECT COUNT(*) FROM user WHERE status = :status;');
76
+
77
+		// Admin users
78
+		$userStatusStatement->execute(array(':status' => 'Admin'));
79
+		$adminUsers = $userStatusStatement->fetchColumn();
80
+		$userStatusStatement->closeCursor();
81
+		$this->assign('statsAdminUsers', $adminUsers);
82
+
83
+		// Users
84
+		$userStatusStatement->execute(array(':status' => 'User'));
85
+		$users = $userStatusStatement->fetchColumn();
86
+		$userStatusStatement->closeCursor();
87
+		$this->assign('statsUsers', $users);
88
+
89
+		// Suspended users
90
+		$userStatusStatement->execute(array(':status' => 'Suspended'));
91
+		$suspendedUsers = $userStatusStatement->fetchColumn();
92
+		$userStatusStatement->closeCursor();
93
+		$this->assign('statsSuspendedUsers', $suspendedUsers);
94
+
95
+		// New users
96
+		$userStatusStatement->execute(array(':status' => 'New'));
97
+		$newUsers = $userStatusStatement->fetchColumn();
98
+		$userStatusStatement->closeCursor();
99
+		$this->assign('statsNewUsers', $newUsers);
100
+
101
+		// Most comments on a request
102
+		$mostCommentsStatement = $database->query(<<<SQL
103 103
 SELECT request FROM comment GROUP BY request ORDER BY COUNT(*) DESC LIMIT 1;
104 104
 SQL
105
-        );
106
-        $mostComments = $mostCommentsStatement->fetchColumn();
107
-        $mostCommentsStatement->closeCursor();
108
-        $this->assign('mostComments', $mostComments);
109
-    }
110
-
111
-    public function getSecurityConfiguration()
112
-    {
113
-        return $this->getSecurityManager()->configure()->asInternalPage();
114
-    }
105
+		);
106
+		$mostComments = $mostCommentsStatement->fetchColumn();
107
+		$mostCommentsStatement->closeCursor();
108
+		$this->assign('mostComments', $mostComments);
109
+	}
110
+
111
+	public function getSecurityConfiguration()
112
+	{
113
+		return $this->getSecurityManager()->configure()->asInternalPage();
114
+	}
115 115
 }
Please login to merge, or discard this patch.
includes/Pages/Statistics/StatsReservedRequests.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 
14 14
 class StatsReservedRequests extends InternalPageBase
15 15
 {
16
-    public function main()
17
-    {
18
-        $this->setHtmlTitle('Reserved Requests :: Statistics');
16
+	public function main()
17
+	{
18
+		$this->setHtmlTitle('Reserved Requests :: Statistics');
19 19
 
20
-        $query = <<<sql
20
+		$query = <<<sql
21 21
 SELECT
22 22
     p.id AS requestid,
23 23
     p.name AS name,
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
 WHERE reserved != 0;
30 30
 sql;
31 31
 
32
-        $database = $this->getDatabase();
33
-        $statement = $database->query($query);
34
-        $data = $statement->fetchAll(PDO::FETCH_ASSOC);
35
-        $this->assign('dataTable', $data);
36
-        $this->assign('statsPageTitle', 'All currently reserved requests');
37
-        $this->setTemplate('statistics/reserved-requests.tpl');
38
-    }
32
+		$database = $this->getDatabase();
33
+		$statement = $database->query($query);
34
+		$data = $statement->fetchAll(PDO::FETCH_ASSOC);
35
+		$this->assign('dataTable', $data);
36
+		$this->assign('statsPageTitle', 'All currently reserved requests');
37
+		$this->setTemplate('statistics/reserved-requests.tpl');
38
+	}
39 39
 
40
-    public function getSecurityConfiguration()
41
-    {
42
-        return $this->getSecurityManager()->configure()->asInternalPage();
43
-    }
40
+	public function getSecurityConfiguration()
41
+	{
42
+		return $this->getSecurityManager()->configure()->asInternalPage();
43
+	}
44 44
 }
Please login to merge, or discard this patch.