Failed Conditions
Push — sul3-quickfix ( f1546e...6b5732 )
by Michael
10:01 queued 05:48
created
includes/Pages/Statistics/StatsUsers.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
 
26 26
 class StatsUsers extends InternalPageBase
27 27
 {
28
-    public function main()
29
-    {
30
-        $this->setHtmlTitle('Users :: Statistics');
28
+	public function main()
29
+	{
30
+		$this->setHtmlTitle('Users :: Statistics');
31 31
 
32
-        $database = $this->getDatabase();
32
+		$database = $this->getDatabase();
33 33
 
34
-        $query = <<<SQL
34
+		$query = <<<SQL
35 35
 SELECT
36 36
     u.id
37 37
     , u.username
@@ -47,34 +47,34 @@  discard block
 block discarded – undo
47 47
 WHERE u.status = 'Active'
48 48
 SQL;
49 49
 
50
-        $users = $database->query($query)->fetchAll(PDO::FETCH_ASSOC);
51
-        $this->assign('users', $users);
50
+		$users = $database->query($query)->fetchAll(PDO::FETCH_ASSOC);
51
+		$this->assign('users', $users);
52 52
 
53
-        $this->assign('statsPageTitle', 'Account Creation Tool users');
54
-        $this->setTemplate("statistics/users.tpl");
55
-    }
53
+		$this->assign('statsPageTitle', 'Account Creation Tool users');
54
+		$this->setTemplate("statistics/users.tpl");
55
+	}
56 56
 
57
-    /**
58
-     * Entry point for the detail action.
59
-     *
60
-     * @throws ApplicationLogicException
61
-     */
62
-    protected function detail()
63
-    {
64
-        $userId = WebRequest::getInt('user');
65
-        if ($userId === null) {
66
-            throw new ApplicationLogicException("User not found");
67
-        }
57
+	/**
58
+	 * Entry point for the detail action.
59
+	 *
60
+	 * @throws ApplicationLogicException
61
+	 */
62
+	protected function detail()
63
+	{
64
+		$userId = WebRequest::getInt('user');
65
+		if ($userId === null) {
66
+			throw new ApplicationLogicException("User not found");
67
+		}
68 68
 
69
-        $database = $this->getDatabase();
69
+		$database = $this->getDatabase();
70 70
 
71
-        $user = User::getById($userId, $database);
72
-        if ($user == false) {
73
-            throw new ApplicationLogicException('User not found');
74
-        }
71
+		$user = User::getById($userId, $database);
72
+		if ($user == false) {
73
+			throw new ApplicationLogicException('User not found');
74
+		}
75 75
 
76 76
 
77
-        $activitySummary = $database->prepare(<<<SQL
77
+		$activitySummary = $database->prepare(<<<SQL
78 78
 SELECT COALESCE(closes.mail_desc, log.action) AS action, COUNT(*) AS count
79 79
 FROM log
80 80
 INNER JOIN user ON log.user = user.id
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 WHERE user.username = :username
83 83
 GROUP BY action;
84 84
 SQL
85
-        );
86
-        $activitySummary->execute(array(":username" => $user->getUsername()));
87
-        $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC);
85
+		);
86
+		$activitySummary->execute(array(":username" => $user->getUsername()));
87
+		$activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC);
88 88
 
89
-        $this->assign("user", $user);
90
-        $this->assign("activity", $activitySummaryData);
89
+		$this->assign("user", $user);
90
+		$this->assign("activity", $activitySummaryData);
91 91
 
92
-        $usersCreatedQuery = $database->prepare(<<<SQL
92
+		$usersCreatedQuery = $database->prepare(<<<SQL
93 93
 SELECT log.timestamp time, request.name name, request.id id
94 94
 FROM log
95 95
 INNER JOIN request ON (request.id = log.objectid AND log.objecttype = 'Request')
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
     AND (emailtemplate.defaultaction = :created OR log.action = 'Closed custom-y')
101 101
 ORDER BY log.timestamp;
102 102
 SQL
103
-        );
104
-        $usersCreatedQuery->execute(array(":username" => $user->getUsername(), ':created' => EmailTemplate::ACTION_CREATED));
105
-        $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
106
-        $this->assign("created", $usersCreated);
103
+		);
104
+		$usersCreatedQuery->execute(array(":username" => $user->getUsername(), ':created' => EmailTemplate::ACTION_CREATED));
105
+		$usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
106
+		$this->assign("created", $usersCreated);
107 107
 
108
-        $usersNotCreatedQuery = $database->prepare(<<<SQL
108
+		$usersNotCreatedQuery = $database->prepare(<<<SQL
109 109
 SELECT log.timestamp time, request.name name, request.id id
110 110
 FROM log
111 111
 JOIN request ON request.id = log.objectid AND log.objecttype = 'Request'
@@ -116,59 +116,59 @@  discard block
 block discarded – undo
116 116
     AND (emailtemplate.defaultaction = :created OR log.action = 'Closed custom-n' OR log.action = 'Closed 0')
117 117
 ORDER BY log.timestamp;
118 118
 SQL
119
-        );
120
-        $usersNotCreatedQuery->execute(array(":username" => $user->getUsername(), ':created' => EmailTemplate::ACTION_NOT_CREATED));
121
-        $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
122
-        $this->assign("notcreated", $usersNotCreated);
123
-
124
-        /** @var Log[] $logs */
125
-        $logs = LogSearchHelper::get($database, Domain::getCurrent($database)->getId())
126
-            ->byObjectType('User')
127
-            ->byObjectId($user->getId())
128
-            ->getRecordCount($logCount)
129
-            ->fetch();
130
-
131
-        if ($logCount === 0) {
132
-            $this->assign('accountlog', array());
133
-        }
134
-        else {
135
-            list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration(), $this->getSecurityManager());
136
-
137
-            $this->assign("accountlog", $logData);
138
-            $this->assign("users", $users);
139
-        }
140
-
141
-        $currentUser = User::getCurrent($database);
142
-        $this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class));
143
-        $this->assign('canDeactivate', $this->barrierTest('deactivate', $currentUser, PageUserManagement::class));
144
-        $this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class));
145
-        $this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class));
146
-        $this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class));
147
-
148
-        $oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration());
149
-        $this->assign('oauth', $oauth);
150
-
151
-        if ($user->getForceIdentified() === null) {
152
-            $idVerifier = new IdentificationVerifier($this->getHttpHelper(), $this->getSiteConfiguration(), $this->getDatabase());
153
-            $this->assign('identificationStatus', $idVerifier->isUserIdentified($user->getOnWikiName()) ? 'detected' : 'missing');
154
-        }
155
-        else {
156
-            $this->assign('identificationStatus', $user->getForceIdentified() == 1 ? 'forced-on' : 'forced-off');
157
-        }
158
-
159
-        if ($oauth->isFullyLinked()) {
160
-            $this->assign('identity', $oauth->getIdentity(true));
161
-            $this->assign('identityExpired', $oauth->identityExpired());
162
-        }
163
-
164
-        $this->assign('statsPageTitle', 'Account Creation Tool users');
165
-
166
-        // FIXME: domains!
167
-        /** @var Domain $domain */
168
-        $domain = Domain::getById(1, $this->getDatabase());
169
-        $this->assign('mediawikiScriptPath', $domain->getWikiArticlePath());
170
-
171
-        $this->setHtmlTitle('{$user->getUsername()|escape} :: Users :: Statistics');
172
-        $this->setTemplate("statistics/userdetail.tpl");
173
-    }
119
+		);
120
+		$usersNotCreatedQuery->execute(array(":username" => $user->getUsername(), ':created' => EmailTemplate::ACTION_NOT_CREATED));
121
+		$usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
122
+		$this->assign("notcreated", $usersNotCreated);
123
+
124
+		/** @var Log[] $logs */
125
+		$logs = LogSearchHelper::get($database, Domain::getCurrent($database)->getId())
126
+			->byObjectType('User')
127
+			->byObjectId($user->getId())
128
+			->getRecordCount($logCount)
129
+			->fetch();
130
+
131
+		if ($logCount === 0) {
132
+			$this->assign('accountlog', array());
133
+		}
134
+		else {
135
+			list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration(), $this->getSecurityManager());
136
+
137
+			$this->assign("accountlog", $logData);
138
+			$this->assign("users", $users);
139
+		}
140
+
141
+		$currentUser = User::getCurrent($database);
142
+		$this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class));
143
+		$this->assign('canDeactivate', $this->barrierTest('deactivate', $currentUser, PageUserManagement::class));
144
+		$this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class));
145
+		$this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class));
146
+		$this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class));
147
+
148
+		$oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration());
149
+		$this->assign('oauth', $oauth);
150
+
151
+		if ($user->getForceIdentified() === null) {
152
+			$idVerifier = new IdentificationVerifier($this->getHttpHelper(), $this->getSiteConfiguration(), $this->getDatabase());
153
+			$this->assign('identificationStatus', $idVerifier->isUserIdentified($user->getOnWikiName()) ? 'detected' : 'missing');
154
+		}
155
+		else {
156
+			$this->assign('identificationStatus', $user->getForceIdentified() == 1 ? 'forced-on' : 'forced-off');
157
+		}
158
+
159
+		if ($oauth->isFullyLinked()) {
160
+			$this->assign('identity', $oauth->getIdentity(true));
161
+			$this->assign('identityExpired', $oauth->identityExpired());
162
+		}
163
+
164
+		$this->assign('statsPageTitle', 'Account Creation Tool users');
165
+
166
+		// FIXME: domains!
167
+		/** @var Domain $domain */
168
+		$domain = Domain::getById(1, $this->getDatabase());
169
+		$this->assign('mediawikiScriptPath', $domain->getWikiArticlePath());
170
+
171
+		$this->setHtmlTitle('{$user->getUsername()|escape} :: Users :: Statistics');
172
+		$this->setTemplate("statistics/userdetail.tpl");
173
+	}
174 174
 }
Please login to merge, or discard this patch.
includes/Pages/RequestAction/PageCreateRequest.php 1 patch
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -35,156 +35,156 @@
 block discarded – undo
35 35
  */
36 36
 class PageCreateRequest extends RequestActionBase
37 37
 {
38
-    /**
39
-     * Main function for this page, when no specific actions are called.
40
-     * @return void
41
-     * @throws AccessDeniedException
42
-     * @throws ApplicationLogicException
43
-     */
44
-    protected function main()
45
-    {
46
-        $this->checkPosted();
47
-
48
-        $database = $this->getDatabase();
49
-
50
-        $request = $this->getRequest($database);
51
-        $template = $this->getTemplate($database);
52
-        $creationMode = $this->getCreationMode();
53
-        $user = User::getCurrent($database);
54
-        $preferencesManager = PreferenceManager::getForCurrent($database);
55
-
56
-        $secMgr = $this->getSecurityManager();
57
-        if ($secMgr->allows('RequestCreation', PreferenceManager::CREATION_BOT, $user) !== ISecurityManager::ALLOWED
58
-            && $creationMode === 'bot'
59
-        ) {
60
-            throw new AccessDeniedException($secMgr, $this->getDomainAccessManager());
61
-        }
62
-        elseif ($secMgr->allows('RequestCreation', PreferenceManager::CREATION_OAUTH, $user) !== ISecurityManager::ALLOWED
63
-            && $creationMode === 'oauth'
64
-        ) {
65
-            throw new AccessDeniedException($secMgr, $this->getDomainAccessManager());
66
-        }
67
-
68
-        if ($request->getEmailSent()) {
69
-            throw new ApplicationLogicException('This requester has already had an email sent to them. Please fall back to manual creation or a custom close');
70
-        }
71
-
72
-        $request->setStatus(RequestStatus::JOBQUEUE);
73
-        $request->setReserved(null);
74
-        $request->save();
75
-
76
-        Logger::enqueuedJobQueue($database, $request);
77
-
78
-        $creationTaskId = $this->enqueueCreationTask($creationMode, $request, $template, $user, $database);
79
-
80
-        $welcomeTemplate = $preferencesManager->getPreference(PreferenceManager::PREF_WELCOMETEMPLATE);
81
-        if ($welcomeTemplate !== null && !WebRequest::postBoolean('skipAutoWelcome')) {
82
-            $this->enqueueWelcomeTask($request, $creationTaskId, $user, $database);
83
-        }
84
-
85
-        $this->getNotificationHelper()->requestCloseQueued($request, $template->getName());
86
-
87
-        SessionAlert::success("Request {$request->getId()} has been queued for autocreation");
88
-
89
-        $this->redirect();
90
-    }
91
-
92
-    protected function getCreationMode()
93
-    {
94
-        $creationMode = WebRequest::postString('mode');
95
-        if ($creationMode !== 'oauth' && $creationMode !== 'bot') {
96
-            throw new ApplicationLogicException('Unknown creation mode');
97
-        }
98
-
99
-        return $creationMode;
100
-    }
101
-
102
-    /**
103
-     * @param PdoDatabase $database
104
-     *
105
-     * @return EmailTemplate
106
-     * @throws ApplicationLogicException
107
-     */
108
-    protected function getTemplate(PdoDatabase $database)
109
-    {
110
-        $templateId = WebRequest::postInt('template');
111
-        if ($templateId === null) {
112
-            throw new ApplicationLogicException('No template specified');
113
-        }
114
-
115
-        /** @var EmailTemplate $template */
116
-        $template = EmailTemplate::getById($templateId, $database);
117
-        if ($template === false || !$template->getActive()) {
118
-            throw new ApplicationLogicException('Invalid or inactive template specified');
119
-        }
120
-
121
-        if ($template->getDefaultAction() !== EmailTemplate::ACTION_CREATED) {
122
-            throw new ApplicationLogicException('Specified template is not a creation template!');
123
-        }
124
-
125
-        return $template;
126
-    }
127
-
128
-    /**
129
-     * @param PdoDatabase $database
130
-     *
131
-     * @return Request
132
-     * @throws ApplicationLogicException
133
-     */
134
-    protected function getRequest(PdoDatabase $database)
135
-    {
136
-        $request = parent::getRequest($database);
137
-
138
-        if ($request->getStatus() == RequestStatus::CLOSED) {
139
-            throw new ApplicationLogicException('Request is already closed');
140
-        }
141
-
142
-        return $request;
143
-    }
144
-
145
-    /**
146
-     * @param               $creationMode
147
-     * @param Request       $request
148
-     * @param EmailTemplate $template
149
-     * @param User          $user
150
-     *
151
-     * @param PdoDatabase   $database
152
-     *
153
-     * @return int
154
-     * @throws ApplicationLogicException
155
-     */
156
-    protected function enqueueCreationTask(
157
-        $creationMode,
158
-        Request $request,
159
-        EmailTemplate $template,
160
-        User $user,
161
-        PdoDatabase $database
162
-    ) {
163
-        $creationTaskClass = null;
164
-
165
-        if ($creationMode == "oauth") {
166
-            $creationTaskClass = UserCreationTask::class;
167
-        }
168
-
169
-        if ($creationMode == "bot") {
170
-            $creationTaskClass = BotCreationTask::class;
171
-        }
172
-
173
-        if ($creationTaskClass === null) {
174
-            throw new ApplicationLogicException('Cannot determine creation mode');
175
-        }
176
-
177
-        $creationTask = new JobQueue();
178
-        $creationTask->setDomain(1); // FIXME: domains!
179
-        $creationTask->setTask($creationTaskClass);
180
-        $creationTask->setRequest($request->getId());
181
-        $creationTask->setEmailTemplate($template->getId());
182
-        $creationTask->setTriggerUserId($user->getId());
183
-        $creationTask->setDatabase($database);
184
-        $creationTask->save();
185
-
186
-        $creationTaskId = $creationTask->getId();
187
-
188
-        return $creationTaskId;
189
-    }
38
+	/**
39
+	 * Main function for this page, when no specific actions are called.
40
+	 * @return void
41
+	 * @throws AccessDeniedException
42
+	 * @throws ApplicationLogicException
43
+	 */
44
+	protected function main()
45
+	{
46
+		$this->checkPosted();
47
+
48
+		$database = $this->getDatabase();
49
+
50
+		$request = $this->getRequest($database);
51
+		$template = $this->getTemplate($database);
52
+		$creationMode = $this->getCreationMode();
53
+		$user = User::getCurrent($database);
54
+		$preferencesManager = PreferenceManager::getForCurrent($database);
55
+
56
+		$secMgr = $this->getSecurityManager();
57
+		if ($secMgr->allows('RequestCreation', PreferenceManager::CREATION_BOT, $user) !== ISecurityManager::ALLOWED
58
+			&& $creationMode === 'bot'
59
+		) {
60
+			throw new AccessDeniedException($secMgr, $this->getDomainAccessManager());
61
+		}
62
+		elseif ($secMgr->allows('RequestCreation', PreferenceManager::CREATION_OAUTH, $user) !== ISecurityManager::ALLOWED
63
+			&& $creationMode === 'oauth'
64
+		) {
65
+			throw new AccessDeniedException($secMgr, $this->getDomainAccessManager());
66
+		}
67
+
68
+		if ($request->getEmailSent()) {
69
+			throw new ApplicationLogicException('This requester has already had an email sent to them. Please fall back to manual creation or a custom close');
70
+		}
71
+
72
+		$request->setStatus(RequestStatus::JOBQUEUE);
73
+		$request->setReserved(null);
74
+		$request->save();
75
+
76
+		Logger::enqueuedJobQueue($database, $request);
77
+
78
+		$creationTaskId = $this->enqueueCreationTask($creationMode, $request, $template, $user, $database);
79
+
80
+		$welcomeTemplate = $preferencesManager->getPreference(PreferenceManager::PREF_WELCOMETEMPLATE);
81
+		if ($welcomeTemplate !== null && !WebRequest::postBoolean('skipAutoWelcome')) {
82
+			$this->enqueueWelcomeTask($request, $creationTaskId, $user, $database);
83
+		}
84
+
85
+		$this->getNotificationHelper()->requestCloseQueued($request, $template->getName());
86
+
87
+		SessionAlert::success("Request {$request->getId()} has been queued for autocreation");
88
+
89
+		$this->redirect();
90
+	}
91
+
92
+	protected function getCreationMode()
93
+	{
94
+		$creationMode = WebRequest::postString('mode');
95
+		if ($creationMode !== 'oauth' && $creationMode !== 'bot') {
96
+			throw new ApplicationLogicException('Unknown creation mode');
97
+		}
98
+
99
+		return $creationMode;
100
+	}
101
+
102
+	/**
103
+	 * @param PdoDatabase $database
104
+	 *
105
+	 * @return EmailTemplate
106
+	 * @throws ApplicationLogicException
107
+	 */
108
+	protected function getTemplate(PdoDatabase $database)
109
+	{
110
+		$templateId = WebRequest::postInt('template');
111
+		if ($templateId === null) {
112
+			throw new ApplicationLogicException('No template specified');
113
+		}
114
+
115
+		/** @var EmailTemplate $template */
116
+		$template = EmailTemplate::getById($templateId, $database);
117
+		if ($template === false || !$template->getActive()) {
118
+			throw new ApplicationLogicException('Invalid or inactive template specified');
119
+		}
120
+
121
+		if ($template->getDefaultAction() !== EmailTemplate::ACTION_CREATED) {
122
+			throw new ApplicationLogicException('Specified template is not a creation template!');
123
+		}
124
+
125
+		return $template;
126
+	}
127
+
128
+	/**
129
+	 * @param PdoDatabase $database
130
+	 *
131
+	 * @return Request
132
+	 * @throws ApplicationLogicException
133
+	 */
134
+	protected function getRequest(PdoDatabase $database)
135
+	{
136
+		$request = parent::getRequest($database);
137
+
138
+		if ($request->getStatus() == RequestStatus::CLOSED) {
139
+			throw new ApplicationLogicException('Request is already closed');
140
+		}
141
+
142
+		return $request;
143
+	}
144
+
145
+	/**
146
+	 * @param               $creationMode
147
+	 * @param Request       $request
148
+	 * @param EmailTemplate $template
149
+	 * @param User          $user
150
+	 *
151
+	 * @param PdoDatabase   $database
152
+	 *
153
+	 * @return int
154
+	 * @throws ApplicationLogicException
155
+	 */
156
+	protected function enqueueCreationTask(
157
+		$creationMode,
158
+		Request $request,
159
+		EmailTemplate $template,
160
+		User $user,
161
+		PdoDatabase $database
162
+	) {
163
+		$creationTaskClass = null;
164
+
165
+		if ($creationMode == "oauth") {
166
+			$creationTaskClass = UserCreationTask::class;
167
+		}
168
+
169
+		if ($creationMode == "bot") {
170
+			$creationTaskClass = BotCreationTask::class;
171
+		}
172
+
173
+		if ($creationTaskClass === null) {
174
+			throw new ApplicationLogicException('Cannot determine creation mode');
175
+		}
176
+
177
+		$creationTask = new JobQueue();
178
+		$creationTask->setDomain(1); // FIXME: domains!
179
+		$creationTask->setTask($creationTaskClass);
180
+		$creationTask->setRequest($request->getId());
181
+		$creationTask->setEmailTemplate($template->getId());
182
+		$creationTask->setTriggerUserId($user->getId());
183
+		$creationTask->setDatabase($database);
184
+		$creationTask->save();
185
+
186
+		$creationTaskId = $creationTask->getId();
187
+
188
+		return $creationTaskId;
189
+	}
190 190
 }
Please login to merge, or discard this patch.
includes/Pages/PageListFlaggedComments.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -18,112 +18,112 @@
 block discarded – undo
18 18
 
19 19
 class PageListFlaggedComments extends InternalPageBase
20 20
 {
21
-    /**
22
-     * @inheritDoc
23
-     */
24
-    protected function main()
25
-    {
26
-        $this->setHtmlTitle('Flagged comments');
27
-        $this->setTemplate('flagged-comments.tpl');
28
-
29
-        $database = $this->getDatabase();
30
-        $this->assignCSRFToken();
31
-
32
-        /** @var Comment[] $commentObjects */
33
-        $commentObjects = Comment::getFlaggedComments($database, 1); // FIXME: domains
34
-        $comments = [];
35
-
36
-        $currentUser = User::getCurrent($database);
37
-
38
-        $seeRestrictedComments = $this->barrierTest('seeRestrictedComments', $currentUser, 'RequestData');
39
-        $seeCheckuserComments = $this->barrierTest('seeCheckuserComments', $currentUser, 'RequestData');
40
-        $alwaysSeePrivateData = $this->barrierTest('alwaysSeePrivateData', $currentUser, 'RequestData');
41
-
42
-        foreach ($commentObjects as $object) {
43
-            $data = [
44
-                'visibility'    => $object->getVisibility(),
45
-                'hidden'        => false,
46
-                'hiddenText'    => false,
47
-            ];
48
-
49
-            if (!$alwaysSeePrivateData) {
50
-                // tl;dr: This is a stupid configuration, but let's account for it anyway.
51
-                //
52
-                // Flagged comments are treated as private data. If you don't have the privilege
53
-                // RequestData::alwaysSeePrivateData, then we can't show you the content of the comments here.
54
-                // This page is forced to degrade into basically a list of requests, seriously hampering the usefulness
55
-                // of this page. Still, we need to handle the case where we have access to this page, but not access
56
-                // to private data.
57
-                // At the time of writing, this case does not exist in the current role configuration, but for the role
58
-                // configuration to be free of assumptions, we need this code.
59
-
60
-                /** @var Request $request */
61
-                $request = Request::getById($object->getRequest(), $database);
62
-
63
-                if ($request->getReserved() === $currentUser->getId()) {
64
-                    $data['hiddenText'] = false;
65
-                }
66
-                else {
67
-                    $data['hiddenText'] = true;
68
-                }
69
-            }
70
-
71
-            if ($object->getVisibility() == 'requester' || $object->getVisibility() == 'user') {
72
-                $data['hidden'] = false;
73
-            }
74
-            elseif ($object->getVisibility() == 'admin') {
75
-                if ($seeRestrictedComments) {
76
-                    $data['hidden'] = false;
77
-                }
78
-                else {
79
-                    $data['hidden'] = true;
80
-                }
81
-            }
82
-            elseif ($object->getVisibility() == 'checkuser') {
83
-                if ($seeCheckuserComments) {
84
-                    $data['hidden'] = false;
85
-                }
86
-                else {
87
-                    $data['hidden'] = true;
88
-                }
89
-            }
90
-
91
-            $this->copyCommentData($object, $data, $database);
92
-
93
-            $comments[] = $data;
94
-        }
95
-
96
-        $this->assign('comments', $comments);
97
-        $this->assign('seeRestrictedComments', $seeRestrictedComments);
98
-        $this->assign('seeCheckuserComments', $seeCheckuserComments);
99
-
100
-        $this->assign('editOthersComments', $this->barrierTest('editOthers', $currentUser, PageEditComment::class));
101
-        $this->assign('editComments', $this->barrierTest(RoleConfigurationBase::MAIN, $currentUser, PageEditComment::class));
102
-        $this->assign('canUnflag', $this->barrierTest('unflag', $currentUser, PageFlagComment::class) && $this->barrierTest(RoleConfigurationBase::MAIN, $currentUser, PageFlagComment::class));
103
-    }
104
-
105
-    private function copyCommentData(Comment $object, array &$data, PdoDatabase $database): void
106
-    {
107
-        if ($data['hidden']) {
108
-            // All details hidden, so don't copy anything.
109
-            return;
110
-        }
111
-
112
-        /** @var Request $request */
113
-        $request = Request::getById($object->getRequest(), $database);
114
-
115
-        if (!$data['hiddenText']) {
116
-            // Comment text is hidden, but presence of the comment is visible.
117
-            $data['comment'] = $object->getComment();
118
-        }
119
-
120
-        $data['id'] = $object->getId();
121
-        $data['updateversion'] = $object->getUpdateVersion();
122
-        $data['time'] = $object->getTime();
123
-        $data['requestid'] = $object->getRequest();
124
-        $data['request'] = $request->getName();
125
-        $data['requeststatus'] = $request->getStatus();
126
-        $data['userid'] = $object->getUser();
127
-        $data['user'] = User::getById($object->getUser(), $database)->getUsername();
128
-    }
21
+	/**
22
+	 * @inheritDoc
23
+	 */
24
+	protected function main()
25
+	{
26
+		$this->setHtmlTitle('Flagged comments');
27
+		$this->setTemplate('flagged-comments.tpl');
28
+
29
+		$database = $this->getDatabase();
30
+		$this->assignCSRFToken();
31
+
32
+		/** @var Comment[] $commentObjects */
33
+		$commentObjects = Comment::getFlaggedComments($database, 1); // FIXME: domains
34
+		$comments = [];
35
+
36
+		$currentUser = User::getCurrent($database);
37
+
38
+		$seeRestrictedComments = $this->barrierTest('seeRestrictedComments', $currentUser, 'RequestData');
39
+		$seeCheckuserComments = $this->barrierTest('seeCheckuserComments', $currentUser, 'RequestData');
40
+		$alwaysSeePrivateData = $this->barrierTest('alwaysSeePrivateData', $currentUser, 'RequestData');
41
+
42
+		foreach ($commentObjects as $object) {
43
+			$data = [
44
+				'visibility'    => $object->getVisibility(),
45
+				'hidden'        => false,
46
+				'hiddenText'    => false,
47
+			];
48
+
49
+			if (!$alwaysSeePrivateData) {
50
+				// tl;dr: This is a stupid configuration, but let's account for it anyway.
51
+				//
52
+				// Flagged comments are treated as private data. If you don't have the privilege
53
+				// RequestData::alwaysSeePrivateData, then we can't show you the content of the comments here.
54
+				// This page is forced to degrade into basically a list of requests, seriously hampering the usefulness
55
+				// of this page. Still, we need to handle the case where we have access to this page, but not access
56
+				// to private data.
57
+				// At the time of writing, this case does not exist in the current role configuration, but for the role
58
+				// configuration to be free of assumptions, we need this code.
59
+
60
+				/** @var Request $request */
61
+				$request = Request::getById($object->getRequest(), $database);
62
+
63
+				if ($request->getReserved() === $currentUser->getId()) {
64
+					$data['hiddenText'] = false;
65
+				}
66
+				else {
67
+					$data['hiddenText'] = true;
68
+				}
69
+			}
70
+
71
+			if ($object->getVisibility() == 'requester' || $object->getVisibility() == 'user') {
72
+				$data['hidden'] = false;
73
+			}
74
+			elseif ($object->getVisibility() == 'admin') {
75
+				if ($seeRestrictedComments) {
76
+					$data['hidden'] = false;
77
+				}
78
+				else {
79
+					$data['hidden'] = true;
80
+				}
81
+			}
82
+			elseif ($object->getVisibility() == 'checkuser') {
83
+				if ($seeCheckuserComments) {
84
+					$data['hidden'] = false;
85
+				}
86
+				else {
87
+					$data['hidden'] = true;
88
+				}
89
+			}
90
+
91
+			$this->copyCommentData($object, $data, $database);
92
+
93
+			$comments[] = $data;
94
+		}
95
+
96
+		$this->assign('comments', $comments);
97
+		$this->assign('seeRestrictedComments', $seeRestrictedComments);
98
+		$this->assign('seeCheckuserComments', $seeCheckuserComments);
99
+
100
+		$this->assign('editOthersComments', $this->barrierTest('editOthers', $currentUser, PageEditComment::class));
101
+		$this->assign('editComments', $this->barrierTest(RoleConfigurationBase::MAIN, $currentUser, PageEditComment::class));
102
+		$this->assign('canUnflag', $this->barrierTest('unflag', $currentUser, PageFlagComment::class) && $this->barrierTest(RoleConfigurationBase::MAIN, $currentUser, PageFlagComment::class));
103
+	}
104
+
105
+	private function copyCommentData(Comment $object, array &$data, PdoDatabase $database): void
106
+	{
107
+		if ($data['hidden']) {
108
+			// All details hidden, so don't copy anything.
109
+			return;
110
+		}
111
+
112
+		/** @var Request $request */
113
+		$request = Request::getById($object->getRequest(), $database);
114
+
115
+		if (!$data['hiddenText']) {
116
+			// Comment text is hidden, but presence of the comment is visible.
117
+			$data['comment'] = $object->getComment();
118
+		}
119
+
120
+		$data['id'] = $object->getId();
121
+		$data['updateversion'] = $object->getUpdateVersion();
122
+		$data['time'] = $object->getTime();
123
+		$data['requestid'] = $object->getRequest();
124
+		$data['request'] = $request->getName();
125
+		$data['requeststatus'] = $request->getStatus();
126
+		$data['userid'] = $object->getUser();
127
+		$data['user'] = User::getById($object->getUser(), $database)->getUsername();
128
+	}
129 129
 }
130 130
\ No newline at end of file
Please login to merge, or discard this patch.