Completed
Push — dependabot/composer/newinterna... ( 9a3136 )
by
unknown
37:39 queued 34:32
created
includes/Background/BackgroundTaskBase.php 1 patch
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -23,267 +23,267 @@
 block discarded – undo
23 23
 
24 24
 abstract class BackgroundTaskBase
25 25
 {
26
-    /** @var JobQueue */
27
-    private $job;
28
-    /** @var PdoDatabase */
29
-    private $database;
30
-    /** @var IOAuthProtocolHelper */
31
-    private $oauthProtocolHelper;
32
-    /** @var SiteConfiguration */
33
-    private $siteConfiguration;
34
-    /** @var IEmailHelper */
35
-    private $emailHelper;
36
-    /** @var HttpHelper */
37
-    private $httpHelper;
38
-    /** @var IrcNotificationHelper */
39
-    private $notificationHelper;
40
-    /** @var User */
41
-    private $triggerUser;
42
-    /** @var Request */
43
-    private $request;
44
-    /** @var EmailTemplate */
45
-    private $emailTemplate = null;
46
-    /** @var mixed */
47
-    private $parameters;
48
-
49
-    /**
50
-     * @return JobQueue
51
-     */
52
-    public function getJob()
53
-    {
54
-        return $this->job;
55
-    }
56
-
57
-    /**
58
-     * @param JobQueue $job
59
-     */
60
-    public function setJob(JobQueue $job)
61
-    {
62
-        $this->job = $job;
63
-    }
64
-
65
-    /**
66
-     * @return PdoDatabase
67
-     */
68
-    public function getDatabase()
69
-    {
70
-        return $this->database;
71
-    }
72
-
73
-    /**
74
-     * @param PdoDatabase $database
75
-     */
76
-    public function setDatabase(PdoDatabase $database)
77
-    {
78
-        $this->database = $database;
79
-    }
80
-
81
-    /**
82
-     * @return IOAuthProtocolHelper
83
-     */
84
-    public function getOauthProtocolHelper()
85
-    {
86
-        return $this->oauthProtocolHelper;
87
-    }
88
-
89
-    /**
90
-     * @param IOAuthProtocolHelper $oauthProtocolHelper
91
-     */
92
-    public function setOauthProtocolHelper(IOAuthProtocolHelper $oauthProtocolHelper)
93
-    {
94
-        $this->oauthProtocolHelper = $oauthProtocolHelper;
95
-    }
96
-
97
-    /**
98
-     * @return SiteConfiguration
99
-     */
100
-    public function getSiteConfiguration()
101
-    {
102
-        return $this->siteConfiguration;
103
-    }
104
-
105
-    /**
106
-     * @param SiteConfiguration $siteConfiguration
107
-     */
108
-    public function setSiteConfiguration(SiteConfiguration $siteConfiguration)
109
-    {
110
-        $this->siteConfiguration = $siteConfiguration;
111
-    }
112
-
113
-    /**
114
-     * @return HttpHelper
115
-     */
116
-    public function getHttpHelper()
117
-    {
118
-        return $this->httpHelper;
119
-    }
120
-
121
-    /**
122
-     * @param HttpHelper $httpHelper
123
-     */
124
-    public function setHttpHelper(HttpHelper $httpHelper)
125
-    {
126
-        $this->httpHelper = $httpHelper;
127
-    }
128
-
129
-    /**
130
-     * @return IEmailHelper
131
-     */
132
-    public function getEmailHelper()
133
-    {
134
-        return $this->emailHelper;
135
-    }
136
-
137
-    /**
138
-     * @param IEmailHelper $emailHelper
139
-     */
140
-    public function setEmailHelper(IEmailHelper $emailHelper)
141
-    {
142
-        $this->emailHelper = $emailHelper;
143
-    }
144
-
145
-    /**
146
-     * @return IrcNotificationHelper
147
-     */
148
-    public function getNotificationHelper()
149
-    {
150
-        return $this->notificationHelper;
151
-    }
152
-
153
-    /**
154
-     * @param IrcNotificationHelper $notificationHelper
155
-     */
156
-    public function setNotificationHelper($notificationHelper)
157
-    {
158
-        $this->notificationHelper = $notificationHelper;
159
-    }
160
-
161
-    /**
162
-     * @return void
163
-     */
164
-    protected abstract function execute();
165
-
166
-    public function run()
167
-    {
168
-        $this->triggerUser = User::getById($this->job->getTriggerUserId(), $this->getDatabase());
169
-
170
-        if ($this->triggerUser === false) {
171
-            throw new ApplicationLogicException('Cannot locate trigger user');
172
-        }
173
-
174
-        $this->request = Request::getById($this->job->getRequest(), $this->getDatabase());
175
-
176
-        if ($this->request === false) {
177
-            throw new ApplicationLogicException('Cannot locate request');
178
-        }
179
-
180
-        if($this->job->getEmailTemplate() !== null){
181
-            $this->emailTemplate = EmailTemplate::getById($this->job->getEmailTemplate(), $this->getDatabase());
182
-
183
-            if ($this->emailTemplate === false) {
184
-                throw new ApplicationLogicException('Cannot locate email template');
185
-            }
186
-        }
187
-
188
-        if($this->job->getParameters() !== null) {
189
-            $this->parameters = json_decode($this->job->getParameters());
190
-
191
-            if (json_last_error() !== JSON_ERROR_NONE) {
192
-                throw new ApplicationLogicException('JSON decode: ' . json_last_error_msg());
193
-            }
194
-        }
195
-
196
-        // Should we wait for a parent job?
197
-        if($this->job->getParent() !== null) {
198
-            /** @var JobQueue $parentJob */
199
-            $parentJob = JobQueue::getById($this->job->getParent(), $this->getDatabase());
200
-
201
-            if($parentJob === false) {
202
-                $this->markFailed("Parent job could not be found");
203
-                return;
204
-            }
205
-
206
-            switch ($parentJob->getStatus()) {
207
-                case JobQueue::STATUS_CANCELLED:
208
-                case JobQueue::STATUS_FAILED:
209
-                    $this->markCancelled('Parent job failed/cancelled');
210
-                    return;
211
-                case JobQueue::STATUS_WAITING:
212
-                case JobQueue::STATUS_READY:
213
-                case JobQueue::STATUS_RUNNING:
214
-                case JobQueue::STATUS_HELD:
215
-                    // Defer to next execution
216
-                    $this->job->setStatus(JobQueue::STATUS_READY);
217
-                    $this->job->save();
218
-                    return;
219
-                case JobQueue::STATUS_COMPLETE:
220
-                    // do nothing
221
-                    break;
222
-            }
223
-        }
224
-
225
-        $this->execute();
226
-    }
227
-
228
-    protected function markComplete()
229
-    {
230
-        $this->job->setStatus(JobQueue::STATUS_COMPLETE);
231
-        $this->job->setError(null);
232
-        $this->job->setAcknowledged(null);
233
-        $this->job->save();
234
-
235
-        Logger::backgroundJobComplete($this->getDatabase(), $this->getJob());
236
-    }
237
-
238
-    protected function markCancelled($reason = null)
239
-    {
240
-        $this->job->setStatus(JobQueue::STATUS_CANCELLED);
241
-        $this->job->setError($reason);
242
-        $this->job->setAcknowledged(null);
243
-        $this->job->save();
244
-
245
-        Logger::backgroundJobIssue($this->getDatabase(), $this->getJob());
246
-    }
247
-
248
-    protected function markFailed($reason = null)
249
-    {
250
-        $this->job->setStatus(JobQueue::STATUS_FAILED);
251
-        $this->job->setError($reason);
252
-        $this->job->setAcknowledged(0);
253
-        $this->job->save();
254
-
255
-        Logger::backgroundJobIssue($this->getDatabase(), $this->getJob());
256
-    }
257
-
258
-    /**
259
-     * @return User
260
-     */
261
-    public function getTriggerUser()
262
-    {
263
-        return $this->triggerUser;
264
-    }
265
-
266
-    /**
267
-     * @return Request
268
-     */
269
-    public function getRequest()
270
-    {
271
-        return $this->request;
272
-    }
273
-
274
-    /**
275
-     * @return EmailTemplate
276
-     */
277
-    public function getEmailTemplate()
278
-    {
279
-        return $this->emailTemplate;
280
-    }
281
-
282
-    /**
283
-     * @return mixed
284
-     */
285
-    public function getParameters()
286
-    {
287
-        return $this->parameters;
288
-    }
26
+	/** @var JobQueue */
27
+	private $job;
28
+	/** @var PdoDatabase */
29
+	private $database;
30
+	/** @var IOAuthProtocolHelper */
31
+	private $oauthProtocolHelper;
32
+	/** @var SiteConfiguration */
33
+	private $siteConfiguration;
34
+	/** @var IEmailHelper */
35
+	private $emailHelper;
36
+	/** @var HttpHelper */
37
+	private $httpHelper;
38
+	/** @var IrcNotificationHelper */
39
+	private $notificationHelper;
40
+	/** @var User */
41
+	private $triggerUser;
42
+	/** @var Request */
43
+	private $request;
44
+	/** @var EmailTemplate */
45
+	private $emailTemplate = null;
46
+	/** @var mixed */
47
+	private $parameters;
48
+
49
+	/**
50
+	 * @return JobQueue
51
+	 */
52
+	public function getJob()
53
+	{
54
+		return $this->job;
55
+	}
56
+
57
+	/**
58
+	 * @param JobQueue $job
59
+	 */
60
+	public function setJob(JobQueue $job)
61
+	{
62
+		$this->job = $job;
63
+	}
64
+
65
+	/**
66
+	 * @return PdoDatabase
67
+	 */
68
+	public function getDatabase()
69
+	{
70
+		return $this->database;
71
+	}
72
+
73
+	/**
74
+	 * @param PdoDatabase $database
75
+	 */
76
+	public function setDatabase(PdoDatabase $database)
77
+	{
78
+		$this->database = $database;
79
+	}
80
+
81
+	/**
82
+	 * @return IOAuthProtocolHelper
83
+	 */
84
+	public function getOauthProtocolHelper()
85
+	{
86
+		return $this->oauthProtocolHelper;
87
+	}
88
+
89
+	/**
90
+	 * @param IOAuthProtocolHelper $oauthProtocolHelper
91
+	 */
92
+	public function setOauthProtocolHelper(IOAuthProtocolHelper $oauthProtocolHelper)
93
+	{
94
+		$this->oauthProtocolHelper = $oauthProtocolHelper;
95
+	}
96
+
97
+	/**
98
+	 * @return SiteConfiguration
99
+	 */
100
+	public function getSiteConfiguration()
101
+	{
102
+		return $this->siteConfiguration;
103
+	}
104
+
105
+	/**
106
+	 * @param SiteConfiguration $siteConfiguration
107
+	 */
108
+	public function setSiteConfiguration(SiteConfiguration $siteConfiguration)
109
+	{
110
+		$this->siteConfiguration = $siteConfiguration;
111
+	}
112
+
113
+	/**
114
+	 * @return HttpHelper
115
+	 */
116
+	public function getHttpHelper()
117
+	{
118
+		return $this->httpHelper;
119
+	}
120
+
121
+	/**
122
+	 * @param HttpHelper $httpHelper
123
+	 */
124
+	public function setHttpHelper(HttpHelper $httpHelper)
125
+	{
126
+		$this->httpHelper = $httpHelper;
127
+	}
128
+
129
+	/**
130
+	 * @return IEmailHelper
131
+	 */
132
+	public function getEmailHelper()
133
+	{
134
+		return $this->emailHelper;
135
+	}
136
+
137
+	/**
138
+	 * @param IEmailHelper $emailHelper
139
+	 */
140
+	public function setEmailHelper(IEmailHelper $emailHelper)
141
+	{
142
+		$this->emailHelper = $emailHelper;
143
+	}
144
+
145
+	/**
146
+	 * @return IrcNotificationHelper
147
+	 */
148
+	public function getNotificationHelper()
149
+	{
150
+		return $this->notificationHelper;
151
+	}
152
+
153
+	/**
154
+	 * @param IrcNotificationHelper $notificationHelper
155
+	 */
156
+	public function setNotificationHelper($notificationHelper)
157
+	{
158
+		$this->notificationHelper = $notificationHelper;
159
+	}
160
+
161
+	/**
162
+	 * @return void
163
+	 */
164
+	protected abstract function execute();
165
+
166
+	public function run()
167
+	{
168
+		$this->triggerUser = User::getById($this->job->getTriggerUserId(), $this->getDatabase());
169
+
170
+		if ($this->triggerUser === false) {
171
+			throw new ApplicationLogicException('Cannot locate trigger user');
172
+		}
173
+
174
+		$this->request = Request::getById($this->job->getRequest(), $this->getDatabase());
175
+
176
+		if ($this->request === false) {
177
+			throw new ApplicationLogicException('Cannot locate request');
178
+		}
179
+
180
+		if($this->job->getEmailTemplate() !== null){
181
+			$this->emailTemplate = EmailTemplate::getById($this->job->getEmailTemplate(), $this->getDatabase());
182
+
183
+			if ($this->emailTemplate === false) {
184
+				throw new ApplicationLogicException('Cannot locate email template');
185
+			}
186
+		}
187
+
188
+		if($this->job->getParameters() !== null) {
189
+			$this->parameters = json_decode($this->job->getParameters());
190
+
191
+			if (json_last_error() !== JSON_ERROR_NONE) {
192
+				throw new ApplicationLogicException('JSON decode: ' . json_last_error_msg());
193
+			}
194
+		}
195
+
196
+		// Should we wait for a parent job?
197
+		if($this->job->getParent() !== null) {
198
+			/** @var JobQueue $parentJob */
199
+			$parentJob = JobQueue::getById($this->job->getParent(), $this->getDatabase());
200
+
201
+			if($parentJob === false) {
202
+				$this->markFailed("Parent job could not be found");
203
+				return;
204
+			}
205
+
206
+			switch ($parentJob->getStatus()) {
207
+				case JobQueue::STATUS_CANCELLED:
208
+				case JobQueue::STATUS_FAILED:
209
+					$this->markCancelled('Parent job failed/cancelled');
210
+					return;
211
+				case JobQueue::STATUS_WAITING:
212
+				case JobQueue::STATUS_READY:
213
+				case JobQueue::STATUS_RUNNING:
214
+				case JobQueue::STATUS_HELD:
215
+					// Defer to next execution
216
+					$this->job->setStatus(JobQueue::STATUS_READY);
217
+					$this->job->save();
218
+					return;
219
+				case JobQueue::STATUS_COMPLETE:
220
+					// do nothing
221
+					break;
222
+			}
223
+		}
224
+
225
+		$this->execute();
226
+	}
227
+
228
+	protected function markComplete()
229
+	{
230
+		$this->job->setStatus(JobQueue::STATUS_COMPLETE);
231
+		$this->job->setError(null);
232
+		$this->job->setAcknowledged(null);
233
+		$this->job->save();
234
+
235
+		Logger::backgroundJobComplete($this->getDatabase(), $this->getJob());
236
+	}
237
+
238
+	protected function markCancelled($reason = null)
239
+	{
240
+		$this->job->setStatus(JobQueue::STATUS_CANCELLED);
241
+		$this->job->setError($reason);
242
+		$this->job->setAcknowledged(null);
243
+		$this->job->save();
244
+
245
+		Logger::backgroundJobIssue($this->getDatabase(), $this->getJob());
246
+	}
247
+
248
+	protected function markFailed($reason = null)
249
+	{
250
+		$this->job->setStatus(JobQueue::STATUS_FAILED);
251
+		$this->job->setError($reason);
252
+		$this->job->setAcknowledged(0);
253
+		$this->job->save();
254
+
255
+		Logger::backgroundJobIssue($this->getDatabase(), $this->getJob());
256
+	}
257
+
258
+	/**
259
+	 * @return User
260
+	 */
261
+	public function getTriggerUser()
262
+	{
263
+		return $this->triggerUser;
264
+	}
265
+
266
+	/**
267
+	 * @return Request
268
+	 */
269
+	public function getRequest()
270
+	{
271
+		return $this->request;
272
+	}
273
+
274
+	/**
275
+	 * @return EmailTemplate
276
+	 */
277
+	public function getEmailTemplate()
278
+	{
279
+		return $this->emailTemplate;
280
+	}
281
+
282
+	/**
283
+	 * @return mixed
284
+	 */
285
+	public function getParameters()
286
+	{
287
+		return $this->parameters;
288
+	}
289 289
 }
Please login to merge, or discard this patch.
includes/DataObject.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -23,124 +23,124 @@
 block discarded – undo
23 23
  */
24 24
 abstract class DataObject
25 25
 {
26
-    /** @var int ID of the object */
27
-    protected $id = null;
28
-    /** @var int update version for optimistic locking */
29
-    protected $updateversion = 0;
30
-    /**
31
-     * @var PdoDatabase
32
-     */
33
-    protected $dbObject;
34
-
35
-    /**
36
-     * Retrieves a data object by it's row ID.
37
-     *
38
-     * @param int         $id
39
-     * @param PdoDatabase $database
40
-     *
41
-     * @return DataObject|false
42
-     */
43
-    public static function getById($id, PdoDatabase $database)
44
-    {
45
-        $array = explode('\\', get_called_class());
46
-        $realClassName = strtolower(end($array));
47
-
48
-        $statement = $database->prepare("SELECT * FROM {$realClassName} WHERE id = :id LIMIT 1;");
49
-        $statement->bindValue(":id", $id);
50
-
51
-        $statement->execute();
52
-
53
-        $resultObject = $statement->fetchObject(get_called_class());
54
-
55
-        if ($resultObject != false) {
56
-            $resultObject->setDatabase($database);
57
-        }
58
-
59
-        return $resultObject;
60
-    }
61
-
62
-    public function setDatabase(PdoDatabase $db)
63
-    {
64
-        $this->dbObject = $db;
65
-    }
66
-
67
-    /**
68
-     * Gets the database associated with this data object.
69
-     * @return PdoDatabase
70
-     */
71
-    public function getDatabase()
72
-    {
73
-        return $this->dbObject;
74
-    }
75
-
76
-    /**
77
-     * Saves a data object to the database, either updating or inserting a record.
78
-     *
79
-     * @return void
80
-     */
81
-    abstract public function save();
82
-
83
-    /**
84
-     * Retrieves the ID attribute
85
-     */
86
-    public function getId()
87
-    {
88
-        return (int)$this->id;
89
-    }
90
-
91
-    /**
92
-     * Deletes the object from the database
93
-     */
94
-    public function delete()
95
-    {
96
-        if ($this->id === null) {
97
-            // wtf?
98
-            return;
99
-        }
100
-
101
-        $array = explode('\\', get_called_class());
102
-        $realClassName = strtolower(end($array));
103
-
104
-        $deleteQuery = "DELETE FROM {$realClassName} WHERE id = :id AND updateversion = :updateversion;";
105
-        $statement = $this->dbObject->prepare($deleteQuery);
106
-
107
-        $statement->bindValue(":id", $this->id);
108
-        $statement->bindValue(":updateversion", $this->updateversion);
109
-        $statement->execute();
110
-
111
-        if ($statement->rowCount() !== 1) {
112
-            throw new OptimisticLockFailedException();
113
-        }
114
-
115
-        $this->id = null;
116
-    }
117
-
118
-    /**
119
-     * @return int
120
-     */
121
-    public function getUpdateVersion()
122
-    {
123
-        return $this->updateversion;
124
-    }
125
-
126
-    /**
127
-     * Sets the update version.
128
-     *
129
-     * You should never call this to change the value of the update version. You should only call it when passing user
130
-     * input through.
131
-     *
132
-     * @param int $updateVersion
133
-     */
134
-    public function setUpdateVersion($updateVersion)
135
-    {
136
-        $this->updateversion = $updateVersion;
137
-    }
138
-
139
-    /**
140
-     * @return bool
141
-     */
142
-    public function isNew()
143
-    {
144
-        return $this->id === null;
145
-    }
26
+	/** @var int ID of the object */
27
+	protected $id = null;
28
+	/** @var int update version for optimistic locking */
29
+	protected $updateversion = 0;
30
+	/**
31
+	 * @var PdoDatabase
32
+	 */
33
+	protected $dbObject;
34
+
35
+	/**
36
+	 * Retrieves a data object by it's row ID.
37
+	 *
38
+	 * @param int         $id
39
+	 * @param PdoDatabase $database
40
+	 *
41
+	 * @return DataObject|false
42
+	 */
43
+	public static function getById($id, PdoDatabase $database)
44
+	{
45
+		$array = explode('\\', get_called_class());
46
+		$realClassName = strtolower(end($array));
47
+
48
+		$statement = $database->prepare("SELECT * FROM {$realClassName} WHERE id = :id LIMIT 1;");
49
+		$statement->bindValue(":id", $id);
50
+
51
+		$statement->execute();
52
+
53
+		$resultObject = $statement->fetchObject(get_called_class());
54
+
55
+		if ($resultObject != false) {
56
+			$resultObject->setDatabase($database);
57
+		}
58
+
59
+		return $resultObject;
60
+	}
61
+
62
+	public function setDatabase(PdoDatabase $db)
63
+	{
64
+		$this->dbObject = $db;
65
+	}
66
+
67
+	/**
68
+	 * Gets the database associated with this data object.
69
+	 * @return PdoDatabase
70
+	 */
71
+	public function getDatabase()
72
+	{
73
+		return $this->dbObject;
74
+	}
75
+
76
+	/**
77
+	 * Saves a data object to the database, either updating or inserting a record.
78
+	 *
79
+	 * @return void
80
+	 */
81
+	abstract public function save();
82
+
83
+	/**
84
+	 * Retrieves the ID attribute
85
+	 */
86
+	public function getId()
87
+	{
88
+		return (int)$this->id;
89
+	}
90
+
91
+	/**
92
+	 * Deletes the object from the database
93
+	 */
94
+	public function delete()
95
+	{
96
+		if ($this->id === null) {
97
+			// wtf?
98
+			return;
99
+		}
100
+
101
+		$array = explode('\\', get_called_class());
102
+		$realClassName = strtolower(end($array));
103
+
104
+		$deleteQuery = "DELETE FROM {$realClassName} WHERE id = :id AND updateversion = :updateversion;";
105
+		$statement = $this->dbObject->prepare($deleteQuery);
106
+
107
+		$statement->bindValue(":id", $this->id);
108
+		$statement->bindValue(":updateversion", $this->updateversion);
109
+		$statement->execute();
110
+
111
+		if ($statement->rowCount() !== 1) {
112
+			throw new OptimisticLockFailedException();
113
+		}
114
+
115
+		$this->id = null;
116
+	}
117
+
118
+	/**
119
+	 * @return int
120
+	 */
121
+	public function getUpdateVersion()
122
+	{
123
+		return $this->updateversion;
124
+	}
125
+
126
+	/**
127
+	 * Sets the update version.
128
+	 *
129
+	 * You should never call this to change the value of the update version. You should only call it when passing user
130
+	 * input through.
131
+	 *
132
+	 * @param int $updateVersion
133
+	 */
134
+	public function setUpdateVersion($updateVersion)
135
+	{
136
+		$this->updateversion = $updateVersion;
137
+	}
138
+
139
+	/**
140
+	 * @return bool
141
+	 */
142
+	public function isNew()
143
+	{
144
+		return $this->id === null;
145
+	}
146 146
 }
Please login to merge, or discard this patch.
includes/Pages/PageEmailManagement.php 1 patch
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -19,179 +19,179 @@
 block discarded – undo
19 19
 
20 20
 class PageEmailManagement extends InternalPageBase
21 21
 {
22
-    /**
23
-     * Main function for this page, when no specific actions are called.
24
-     * @return void
25
-     */
26
-    protected function main()
27
-    {
28
-        $this->setHtmlTitle('Close Emails');
29
-
30
-        // Get all active email templates
31
-        $activeTemplates = EmailTemplate::getAllActiveTemplates(null, $this->getDatabase());
32
-        $inactiveTemplates = EmailTemplate::getAllInactiveTemplates($this->getDatabase());
33
-
34
-        $this->assign('activeTemplates', $activeTemplates);
35
-        $this->assign('inactiveTemplates', $inactiveTemplates);
36
-
37
-        $user = User::getCurrent($this->getDatabase());
38
-        $this->assign('canCreate', $this->barrierTest('create', $user));
39
-        $this->assign('canEdit', $this->barrierTest('edit', $user));
40
-
41
-        $this->setTemplate('email-management/main.tpl');
42
-    }
43
-
44
-    protected function view()
45
-    {
46
-        $this->setHtmlTitle('Close Emails');
47
-
48
-        $database = $this->getDatabase();
49
-        $template = $this->getTemplate($database);
50
-
51
-        $createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId();
52
-        $requestStates = $this->getSiteConfiguration()->getRequestStates();
53
-
54
-        $this->assign('id', $template->getId());
55
-        $this->assign('emailTemplate', $template);
56
-        $this->assign('createdid', $createdId);
57
-        $this->assign('requeststates', $requestStates);
58
-
59
-        $this->setTemplate('email-management/view.tpl');
60
-    }
61
-
62
-    /**
63
-     * @param PdoDatabase $database
64
-     *
65
-     * @return EmailTemplate
66
-     * @throws ApplicationLogicException
67
-     */
68
-    protected function getTemplate(PdoDatabase $database)
69
-    {
70
-        $templateId = WebRequest::getInt('id');
71
-        if ($templateId === null) {
72
-            throw new ApplicationLogicException('Template not specified');
73
-        }
74
-        $template = EmailTemplate::getById($templateId, $database);
75
-        if ($template === false || !is_a($template, EmailTemplate::class)) {
76
-            throw new ApplicationLogicException('Template not found');
77
-        }
78
-
79
-        return $template;
80
-    }
81
-
82
-    protected function edit()
83
-    {
84
-        $this->setHtmlTitle('Close Emails');
85
-
86
-        $database = $this->getDatabase();
87
-        $template = $this->getTemplate($database);
88
-
89
-        $createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId();
90
-        $requestStates = $this->getSiteConfiguration()->getRequestStates();
91
-
92
-        if (WebRequest::wasPosted()) {
93
-            $this->validateCSRFToken();
94
-
95
-            $this->modifyTemplateData($template);
96
-
97
-            $other = EmailTemplate::getByName($template->getName(), $database);
98
-            if ($other !== false && $other->getId() !== $template->getId()) {
99
-                throw new ApplicationLogicException('A template with this name already exists');
100
-            }
101
-
102
-            if ($template->getId() === $createdId) {
103
-                $template->setDefaultAction(EmailTemplate::CREATED);
104
-                $template->setActive(true);
105
-                $template->setPreloadOnly(false);
106
-            }
107
-
108
-            // optimistically lock on load of edit form
109
-            $updateVersion = WebRequest::postInt('updateversion');
110
-            $template->setUpdateVersion($updateVersion);
111
-
112
-            $template->save();
113
-            Logger::editedEmail($database, $template);
114
-            $this->getNotificationHelper()->emailEdited($template);
115
-            SessionAlert::success("Email template has been saved successfully.");
116
-
117
-            $this->redirect('emailManagement');
118
-        }
119
-        else {
120
-            $this->assignCSRFToken();
121
-            $this->assign('id', $template->getId());
122
-            $this->assign('emailTemplate', $template);
123
-            $this->assign('createdid', $createdId);
124
-            $this->assign('requeststates', $requestStates);
125
-
126
-            $this->setTemplate('email-management/edit.tpl');
127
-        }
128
-    }
129
-
130
-    /**
131
-     * @param EmailTemplate $template
132
-     *
133
-     * @throws ApplicationLogicException
134
-     */
135
-    private function modifyTemplateData(EmailTemplate $template)
136
-    {
137
-        $name = WebRequest::postString('name');
138
-        if ($name === null || $name === '') {
139
-            throw new ApplicationLogicException('Name not specified');
140
-        }
141
-
142
-        $template->setName($name);
143
-
144
-        $text = WebRequest::postString('text');
145
-        if ($text === null || $text === '') {
146
-            throw new ApplicationLogicException('Text not specified');
147
-        }
148
-
149
-        $template->setText($text);
150
-
151
-        $template->setJsquestion(WebRequest::postString('jsquestion'));
152
-
153
-        $template->setDefaultAction(WebRequest::postString('defaultaction'));
154
-        $template->setActive(WebRequest::postBoolean('active'));
155
-        $template->setPreloadOnly(WebRequest::postBoolean('preloadonly'));
156
-    }
157
-
158
-    protected function create()
159
-    {
160
-        $this->setHtmlTitle('Close Emails');
161
-
162
-        $database = $this->getDatabase();
163
-
164
-        $requestStates = $this->getSiteConfiguration()->getRequestStates();
165
-
166
-        if (WebRequest::wasPosted()) {
167
-            $this->validateCSRFToken();
168
-            $template = new EmailTemplate();
169
-            $template->setDatabase($database);
170
-
171
-            $this->modifyTemplateData($template);
172
-
173
-            $other = EmailTemplate::getByName($template->getName(), $database);
174
-            if ($other !== false) {
175
-                throw new ApplicationLogicException('A template with this name already exists');
176
-            }
177
-
178
-            $template->save();
179
-
180
-            Logger::createEmail($database, $template);
181
-            $this->getNotificationHelper()->emailCreated($template);
182
-
183
-            SessionAlert::success("Email template has been saved successfully.");
184
-
185
-            $this->redirect('emailManagement');
186
-        }
187
-        else {
188
-            $this->assignCSRFToken();
189
-            $this->assign('id', -1);
190
-            $this->assign('emailTemplate', new EmailTemplate());
191
-            $this->assign('createdid', -2);
192
-
193
-            $this->assign('requeststates', $requestStates);
194
-            $this->setTemplate('email-management/edit.tpl');
195
-        }
196
-    }
22
+	/**
23
+	 * Main function for this page, when no specific actions are called.
24
+	 * @return void
25
+	 */
26
+	protected function main()
27
+	{
28
+		$this->setHtmlTitle('Close Emails');
29
+
30
+		// Get all active email templates
31
+		$activeTemplates = EmailTemplate::getAllActiveTemplates(null, $this->getDatabase());
32
+		$inactiveTemplates = EmailTemplate::getAllInactiveTemplates($this->getDatabase());
33
+
34
+		$this->assign('activeTemplates', $activeTemplates);
35
+		$this->assign('inactiveTemplates', $inactiveTemplates);
36
+
37
+		$user = User::getCurrent($this->getDatabase());
38
+		$this->assign('canCreate', $this->barrierTest('create', $user));
39
+		$this->assign('canEdit', $this->barrierTest('edit', $user));
40
+
41
+		$this->setTemplate('email-management/main.tpl');
42
+	}
43
+
44
+	protected function view()
45
+	{
46
+		$this->setHtmlTitle('Close Emails');
47
+
48
+		$database = $this->getDatabase();
49
+		$template = $this->getTemplate($database);
50
+
51
+		$createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId();
52
+		$requestStates = $this->getSiteConfiguration()->getRequestStates();
53
+
54
+		$this->assign('id', $template->getId());
55
+		$this->assign('emailTemplate', $template);
56
+		$this->assign('createdid', $createdId);
57
+		$this->assign('requeststates', $requestStates);
58
+
59
+		$this->setTemplate('email-management/view.tpl');
60
+	}
61
+
62
+	/**
63
+	 * @param PdoDatabase $database
64
+	 *
65
+	 * @return EmailTemplate
66
+	 * @throws ApplicationLogicException
67
+	 */
68
+	protected function getTemplate(PdoDatabase $database)
69
+	{
70
+		$templateId = WebRequest::getInt('id');
71
+		if ($templateId === null) {
72
+			throw new ApplicationLogicException('Template not specified');
73
+		}
74
+		$template = EmailTemplate::getById($templateId, $database);
75
+		if ($template === false || !is_a($template, EmailTemplate::class)) {
76
+			throw new ApplicationLogicException('Template not found');
77
+		}
78
+
79
+		return $template;
80
+	}
81
+
82
+	protected function edit()
83
+	{
84
+		$this->setHtmlTitle('Close Emails');
85
+
86
+		$database = $this->getDatabase();
87
+		$template = $this->getTemplate($database);
88
+
89
+		$createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId();
90
+		$requestStates = $this->getSiteConfiguration()->getRequestStates();
91
+
92
+		if (WebRequest::wasPosted()) {
93
+			$this->validateCSRFToken();
94
+
95
+			$this->modifyTemplateData($template);
96
+
97
+			$other = EmailTemplate::getByName($template->getName(), $database);
98
+			if ($other !== false && $other->getId() !== $template->getId()) {
99
+				throw new ApplicationLogicException('A template with this name already exists');
100
+			}
101
+
102
+			if ($template->getId() === $createdId) {
103
+				$template->setDefaultAction(EmailTemplate::CREATED);
104
+				$template->setActive(true);
105
+				$template->setPreloadOnly(false);
106
+			}
107
+
108
+			// optimistically lock on load of edit form
109
+			$updateVersion = WebRequest::postInt('updateversion');
110
+			$template->setUpdateVersion($updateVersion);
111
+
112
+			$template->save();
113
+			Logger::editedEmail($database, $template);
114
+			$this->getNotificationHelper()->emailEdited($template);
115
+			SessionAlert::success("Email template has been saved successfully.");
116
+
117
+			$this->redirect('emailManagement');
118
+		}
119
+		else {
120
+			$this->assignCSRFToken();
121
+			$this->assign('id', $template->getId());
122
+			$this->assign('emailTemplate', $template);
123
+			$this->assign('createdid', $createdId);
124
+			$this->assign('requeststates', $requestStates);
125
+
126
+			$this->setTemplate('email-management/edit.tpl');
127
+		}
128
+	}
129
+
130
+	/**
131
+	 * @param EmailTemplate $template
132
+	 *
133
+	 * @throws ApplicationLogicException
134
+	 */
135
+	private function modifyTemplateData(EmailTemplate $template)
136
+	{
137
+		$name = WebRequest::postString('name');
138
+		if ($name === null || $name === '') {
139
+			throw new ApplicationLogicException('Name not specified');
140
+		}
141
+
142
+		$template->setName($name);
143
+
144
+		$text = WebRequest::postString('text');
145
+		if ($text === null || $text === '') {
146
+			throw new ApplicationLogicException('Text not specified');
147
+		}
148
+
149
+		$template->setText($text);
150
+
151
+		$template->setJsquestion(WebRequest::postString('jsquestion'));
152
+
153
+		$template->setDefaultAction(WebRequest::postString('defaultaction'));
154
+		$template->setActive(WebRequest::postBoolean('active'));
155
+		$template->setPreloadOnly(WebRequest::postBoolean('preloadonly'));
156
+	}
157
+
158
+	protected function create()
159
+	{
160
+		$this->setHtmlTitle('Close Emails');
161
+
162
+		$database = $this->getDatabase();
163
+
164
+		$requestStates = $this->getSiteConfiguration()->getRequestStates();
165
+
166
+		if (WebRequest::wasPosted()) {
167
+			$this->validateCSRFToken();
168
+			$template = new EmailTemplate();
169
+			$template->setDatabase($database);
170
+
171
+			$this->modifyTemplateData($template);
172
+
173
+			$other = EmailTemplate::getByName($template->getName(), $database);
174
+			if ($other !== false) {
175
+				throw new ApplicationLogicException('A template with this name already exists');
176
+			}
177
+
178
+			$template->save();
179
+
180
+			Logger::createEmail($database, $template);
181
+			$this->getNotificationHelper()->emailCreated($template);
182
+
183
+			SessionAlert::success("Email template has been saved successfully.");
184
+
185
+			$this->redirect('emailManagement');
186
+		}
187
+		else {
188
+			$this->assignCSRFToken();
189
+			$this->assign('id', -1);
190
+			$this->assign('emailTemplate', new EmailTemplate());
191
+			$this->assign('createdid', -2);
192
+
193
+			$this->assign('requeststates', $requestStates);
194
+			$this->setTemplate('email-management/edit.tpl');
195
+		}
196
+	}
197 197
 }
Please login to merge, or discard this patch.
includes/Pages/Statistics/StatsUsers.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 
23 23
 class StatsUsers extends InternalPageBase
24 24
 {
25
-    public function main()
26
-    {
27
-        $this->setHtmlTitle('Users :: Statistics');
25
+	public function main()
26
+	{
27
+		$this->setHtmlTitle('Users :: Statistics');
28 28
 
29
-        $database = $this->getDatabase();
29
+		$database = $this->getDatabase();
30 30
 
31
-        $query = <<<SQL
31
+		$query = <<<SQL
32 32
 SELECT
33 33
     u.id
34 34
     , u.username
@@ -44,34 +44,34 @@  discard block
 block discarded – undo
44 44
 WHERE u.status = 'Active'
45 45
 SQL;
46 46
 
47
-        $users = $database->query($query)->fetchAll(PDO::FETCH_ASSOC);
48
-        $this->assign('users', $users);
47
+		$users = $database->query($query)->fetchAll(PDO::FETCH_ASSOC);
48
+		$this->assign('users', $users);
49 49
 
50
-        $this->assign('statsPageTitle', 'Account Creation Tool users');
51
-        $this->setTemplate("statistics/users.tpl");
52
-    }
50
+		$this->assign('statsPageTitle', 'Account Creation Tool users');
51
+		$this->setTemplate("statistics/users.tpl");
52
+	}
53 53
 
54
-    /**
55
-     * Entry point for the detail action.
56
-     *
57
-     * @throws ApplicationLogicException
58
-     */
59
-    protected function detail()
60
-    {
61
-        $userId = WebRequest::getInt('user');
62
-        if ($userId === null) {
63
-            throw new ApplicationLogicException("User not found");
64
-        }
54
+	/**
55
+	 * Entry point for the detail action.
56
+	 *
57
+	 * @throws ApplicationLogicException
58
+	 */
59
+	protected function detail()
60
+	{
61
+		$userId = WebRequest::getInt('user');
62
+		if ($userId === null) {
63
+			throw new ApplicationLogicException("User not found");
64
+		}
65 65
 
66
-        $database = $this->getDatabase();
66
+		$database = $this->getDatabase();
67 67
 
68
-        $user = User::getById($userId, $database);
69
-        if ($user == false) {
70
-            throw new ApplicationLogicException('User not found');
71
-        }
68
+		$user = User::getById($userId, $database);
69
+		if ($user == false) {
70
+			throw new ApplicationLogicException('User not found');
71
+		}
72 72
 
73 73
 
74
-        $activitySummary = $database->prepare(<<<SQL
74
+		$activitySummary = $database->prepare(<<<SQL
75 75
 SELECT COALESCE(closes.mail_desc, log.action) AS action, COUNT(*) AS count
76 76
 FROM log
77 77
 INNER JOIN user ON log.user = user.id
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 WHERE user.username = :username
80 80
 GROUP BY action;
81 81
 SQL
82
-        );
83
-        $activitySummary->execute(array(":username" => $user->getUsername()));
84
-        $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC);
82
+		);
83
+		$activitySummary->execute(array(":username" => $user->getUsername()));
84
+		$activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC);
85 85
 
86
-        $this->assign("user", $user);
87
-        $this->assign("activity", $activitySummaryData);
86
+		$this->assign("user", $user);
87
+		$this->assign("activity", $activitySummaryData);
88 88
 
89
-        $usersCreatedQuery = $database->prepare(<<<SQL
89
+		$usersCreatedQuery = $database->prepare(<<<SQL
90 90
 SELECT log.timestamp time, request.name name, request.id id
91 91
 FROM log
92 92
 INNER JOIN request ON (request.id = log.objectid AND log.objecttype = 'Request')
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
     AND (emailtemplate.oncreated = '1' OR log.action = 'Closed custom-y')
98 98
 ORDER BY log.timestamp;
99 99
 SQL
100
-        );
101
-        $usersCreatedQuery->execute(array(":username" => $user->getUsername()));
102
-        $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
103
-        $this->assign("created", $usersCreated);
100
+		);
101
+		$usersCreatedQuery->execute(array(":username" => $user->getUsername()));
102
+		$usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
103
+		$this->assign("created", $usersCreated);
104 104
 
105
-        $usersNotCreatedQuery = $database->prepare(<<<SQL
105
+		$usersNotCreatedQuery = $database->prepare(<<<SQL
106 106
 SELECT log.timestamp time, request.name name, request.id id
107 107
 FROM log
108 108
 JOIN request ON request.id = log.objectid AND log.objecttype = 'Request'
@@ -113,54 +113,54 @@  discard block
 block discarded – undo
113 113
     AND (emailtemplate.oncreated = '0' OR log.action = 'Closed custom-n' OR log.action = 'Closed 0')
114 114
 ORDER BY log.timestamp;
115 115
 SQL
116
-        );
117
-        $usersNotCreatedQuery->execute(array(":username" => $user->getUsername()));
118
-        $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
119
-        $this->assign("notcreated", $usersNotCreated);
120
-
121
-        /** @var Log[] $logs */
122
-        $logs = LogSearchHelper::get($database)
123
-            ->byObjectType('User')
124
-            ->byObjectId($user->getId())
125
-            ->getRecordCount($logCount)
126
-            ->fetch();
127
-
128
-        if ($logCount === 0) {
129
-            $this->assign('accountlog', array());
130
-        }
131
-        else {
132
-            list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration());
133
-
134
-            $this->assign("accountlog", $logData);
135
-            $this->assign("users", $users);
136
-        }
137
-
138
-        $currentUser = User::getCurrent($database);
139
-        $this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class));
140
-        $this->assign('canDecline', $this->barrierTest('decline', $currentUser, PageUserManagement::class));
141
-        $this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class));
142
-        $this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class));
143
-        $this->assign('canSuspend', $this->barrierTest('suspend', $currentUser, PageUserManagement::class));
144
-        $this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class));
145
-
146
-        $oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration());
147
-        $this->assign('oauth', $oauth);
148
-
149
-        if($user->getForceIdentified() === null) {
150
-            $idVerifier = new IdentificationVerifier($this->getHttpHelper(), $this->getSiteConfiguration(), $this->getDatabase());
151
-            $this->assign('identificationStatus', $idVerifier->isUserIdentified($user->getOnWikiName()) ? 'detected' : 'missing');
152
-        } else {
153
-            $this->assign('identificationStatus', $user->getForceIdentified() == 1 ? 'forced-on' : 'forced-off');
154
-        }
155
-
156
-        if ($oauth->isFullyLinked()) {
157
-            $this->assign('identity', $oauth->getIdentity(true));
158
-            $this->assign('identityExpired', $oauth->identityExpired());
159
-        }
160
-
161
-        $this->assign('statsPageTitle', 'Account Creation Tool users');
162
-
163
-        $this->setHtmlTitle('{$user->getUsername()|escape} :: Users :: Statistics');
164
-        $this->setTemplate("statistics/userdetail.tpl");
165
-    }
116
+		);
117
+		$usersNotCreatedQuery->execute(array(":username" => $user->getUsername()));
118
+		$usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC);
119
+		$this->assign("notcreated", $usersNotCreated);
120
+
121
+		/** @var Log[] $logs */
122
+		$logs = LogSearchHelper::get($database)
123
+			->byObjectType('User')
124
+			->byObjectId($user->getId())
125
+			->getRecordCount($logCount)
126
+			->fetch();
127
+
128
+		if ($logCount === 0) {
129
+			$this->assign('accountlog', array());
130
+		}
131
+		else {
132
+			list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration());
133
+
134
+			$this->assign("accountlog", $logData);
135
+			$this->assign("users", $users);
136
+		}
137
+
138
+		$currentUser = User::getCurrent($database);
139
+		$this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class));
140
+		$this->assign('canDecline', $this->barrierTest('decline', $currentUser, PageUserManagement::class));
141
+		$this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class));
142
+		$this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class));
143
+		$this->assign('canSuspend', $this->barrierTest('suspend', $currentUser, PageUserManagement::class));
144
+		$this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class));
145
+
146
+		$oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration());
147
+		$this->assign('oauth', $oauth);
148
+
149
+		if($user->getForceIdentified() === null) {
150
+			$idVerifier = new IdentificationVerifier($this->getHttpHelper(), $this->getSiteConfiguration(), $this->getDatabase());
151
+			$this->assign('identificationStatus', $idVerifier->isUserIdentified($user->getOnWikiName()) ? 'detected' : 'missing');
152
+		} else {
153
+			$this->assign('identificationStatus', $user->getForceIdentified() == 1 ? 'forced-on' : 'forced-off');
154
+		}
155
+
156
+		if ($oauth->isFullyLinked()) {
157
+			$this->assign('identity', $oauth->getIdentity(true));
158
+			$this->assign('identityExpired', $oauth->identityExpired());
159
+		}
160
+
161
+		$this->assign('statsPageTitle', 'Account Creation Tool users');
162
+
163
+		$this->setHtmlTitle('{$user->getUsername()|escape} :: Users :: Statistics');
164
+		$this->setTemplate("statistics/userdetail.tpl");
165
+	}
166 166
 }
Please login to merge, or discard this patch.
includes/Pages/Statistics/StatsInactiveUsers.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
 
18 18
 class StatsInactiveUsers extends InternalPageBase
19 19
 {
20
-    public function main()
21
-    {
22
-        $this->setHtmlTitle('Inactive Users :: Statistics');
23
-
24
-        $date = new DateTime();
25
-        $date->modify("-90 days");
26
-
27
-        $inactiveUsers = UserSearchHelper::get($this->getDatabase())
28
-            ->byStatus('Active')
29
-            ->lastActiveBefore($date)
30
-            ->getRoleMap($roleMap)
31
-            ->fetch();
32
-
33
-        $this->assign('inactiveUsers', $inactiveUsers);
34
-        $this->assign('roles', $roleMap);
35
-        $this->assign('canSuspend',
36
-            $this->barrierTest('suspend', User::getCurrent($this->getDatabase()), PageUserManagement::class));
37
-
38
-        $immuneUsers = $this->getDatabase()
39
-            ->query("SELECT user FROM userrole WHERE role IN ('toolRoot', 'checkuser') GROUP BY user;")
40
-            ->fetchAll(PDO::FETCH_COLUMN);
20
+	public function main()
21
+	{
22
+		$this->setHtmlTitle('Inactive Users :: Statistics');
23
+
24
+		$date = new DateTime();
25
+		$date->modify("-90 days");
26
+
27
+		$inactiveUsers = UserSearchHelper::get($this->getDatabase())
28
+			->byStatus('Active')
29
+			->lastActiveBefore($date)
30
+			->getRoleMap($roleMap)
31
+			->fetch();
32
+
33
+		$this->assign('inactiveUsers', $inactiveUsers);
34
+		$this->assign('roles', $roleMap);
35
+		$this->assign('canSuspend',
36
+			$this->barrierTest('suspend', User::getCurrent($this->getDatabase()), PageUserManagement::class));
37
+
38
+		$immuneUsers = $this->getDatabase()
39
+			->query("SELECT user FROM userrole WHERE role IN ('toolRoot', 'checkuser') GROUP BY user;")
40
+			->fetchAll(PDO::FETCH_COLUMN);
41 41
         
42
-        $this->assign('immune', array_fill_keys($immuneUsers, true));
42
+		$this->assign('immune', array_fill_keys($immuneUsers, true));
43 43
 
44
-        $this->setTemplate('statistics/inactive-users.tpl');
45
-        $this->assign('statsPageTitle', 'Inactive tool users');
46
-    }
44
+		$this->setTemplate('statistics/inactive-users.tpl');
45
+		$this->assign('statsPageTitle', 'Inactive tool users');
46
+	}
47 47
 }
Please login to merge, or discard this patch.
includes/Pages/PageExpandedRequestList.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -16,65 +16,65 @@
 block discarded – undo
16 16
 
17 17
 class PageExpandedRequestList extends InternalPageBase
18 18
 {
19
-    use RequestListData;
19
+	use RequestListData;
20 20
 
21
-    /**
22
-     * Main function for this page, when no specific actions are called.
23
-     * @return void
24
-     * @todo This is very similar to the PageMain code, we could probably generalise this somehow
25
-     */
26
-    protected function main()
27
-    {
28
-        $config = $this->getSiteConfiguration();
21
+	/**
22
+	 * Main function for this page, when no specific actions are called.
23
+	 * @return void
24
+	 * @todo This is very similar to the PageMain code, we could probably generalise this somehow
25
+	 */
26
+	protected function main()
27
+	{
28
+		$config = $this->getSiteConfiguration();
29 29
 
30
-        $requestedStatus = WebRequest::getString('status');
31
-        $requestStates = $config->getRequestStates();
30
+		$requestedStatus = WebRequest::getString('status');
31
+		$requestStates = $config->getRequestStates();
32 32
 
33
-        if ($requestedStatus !== null && isset($requestStates[$requestedStatus])) {
33
+		if ($requestedStatus !== null && isset($requestStates[$requestedStatus])) {
34 34
 
35
-            $this->assignCSRFToken();
35
+			$this->assignCSRFToken();
36 36
 
37
-            $database = $this->getDatabase();
37
+			$database = $this->getDatabase();
38 38
 
39
-            $help = $requestStates[$requestedStatus]['queuehelp'];
40
-            $this->assign('queuehelp', $help);
39
+			$help = $requestStates[$requestedStatus]['queuehelp'];
40
+			$this->assign('queuehelp', $help);
41 41
 
42
-            if ($config->getEmailConfirmationEnabled()) {
43
-                $query = "SELECT * FROM request WHERE status = :type AND emailconfirm = 'Confirmed';";
44
-                $totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type AND emailconfirm = 'Confirmed';";
45
-            }
46
-            else {
47
-                $query = "SELECT * FROM request WHERE status = :type;";
48
-                $totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type;";
49
-            }
42
+			if ($config->getEmailConfirmationEnabled()) {
43
+				$query = "SELECT * FROM request WHERE status = :type AND emailconfirm = 'Confirmed';";
44
+				$totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type AND emailconfirm = 'Confirmed';";
45
+			}
46
+			else {
47
+				$query = "SELECT * FROM request WHERE status = :type;";
48
+				$totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type;";
49
+			}
50 50
 
51
-            $statement = $database->prepare($query);
52
-            $totalRequestsStatement = $database->prepare($totalQuery);
51
+			$statement = $database->prepare($query);
52
+			$totalRequestsStatement = $database->prepare($totalQuery);
53 53
 
54
-            $statement->bindValue(":type", $requestedStatus);
55
-            $statement->execute();
54
+			$statement->bindValue(":type", $requestedStatus);
55
+			$statement->execute();
56 56
 
57
-            $requests = $statement->fetchAll(PDO::FETCH_CLASS, Request::class);
57
+			$requests = $statement->fetchAll(PDO::FETCH_CLASS, Request::class);
58 58
 
59
-            /** @var Request $req */
60
-            foreach ($requests as $req) {
61
-                $req->setDatabase($database);
62
-            }
59
+			/** @var Request $req */
60
+			foreach ($requests as $req) {
61
+				$req->setDatabase($database);
62
+			}
63 63
 
64
-            $this->assign('requests', $this->prepareRequestData($requests));
65
-            $this->assign('header', $requestedStatus);
66
-            $this->assign('requestLimitShowOnly', $config->getMiserModeLimit());
67
-            $this->assign('defaultRequestState', $config->getDefaultRequestStateKey());
64
+			$this->assign('requests', $this->prepareRequestData($requests));
65
+			$this->assign('header', $requestedStatus);
66
+			$this->assign('requestLimitShowOnly', $config->getMiserModeLimit());
67
+			$this->assign('defaultRequestState', $config->getDefaultRequestStateKey());
68 68
 
69
-            $totalRequestsStatement->bindValue(':type', $requestedStatus);
70
-            $totalRequestsStatement->execute();
71
-            $totalRequests = $totalRequestsStatement->fetchColumn();
72
-            $totalRequestsStatement->closeCursor();
73
-            $this->assign('totalRequests', $totalRequests);
69
+			$totalRequestsStatement->bindValue(':type', $requestedStatus);
70
+			$totalRequestsStatement->execute();
71
+			$totalRequests = $totalRequestsStatement->fetchColumn();
72
+			$totalRequestsStatement->closeCursor();
73
+			$this->assign('totalRequests', $totalRequests);
74 74
 
75 75
 
76
-            $this->setHtmlTitle('{$header|escape}{if $totalRequests > 0} [{$totalRequests|escape}]{/if}');
77
-            $this->setTemplate('mainpage/expandedrequestlist.tpl');
78
-        }
79
-    }
76
+			$this->setHtmlTitle('{$header|escape}{if $totalRequests > 0} [{$totalRequests|escape}]{/if}');
77
+			$this->setTemplate('mainpage/expandedrequestlist.tpl');
78
+		}
79
+	}
80 80
 }
Please login to merge, or discard this patch.
includes/Pages/PageEditComment.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -20,67 +20,67 @@
 block discarded – undo
20 20
 
21 21
 class PageEditComment extends InternalPageBase
22 22
 {
23
-    /**
24
-     * Main function for this page, when no specific actions are called.
25
-     * @throws ApplicationLogicException
26
-     */
27
-    protected function main()
28
-    {
29
-        $commentId = WebRequest::getInt('id');
30
-        if ($commentId === null) {
31
-            throw new ApplicationLogicException('Comment ID not specified');
32
-        }
23
+	/**
24
+	 * Main function for this page, when no specific actions are called.
25
+	 * @throws ApplicationLogicException
26
+	 */
27
+	protected function main()
28
+	{
29
+		$commentId = WebRequest::getInt('id');
30
+		if ($commentId === null) {
31
+			throw new ApplicationLogicException('Comment ID not specified');
32
+		}
33 33
 
34
-        $database = $this->getDatabase();
34
+		$database = $this->getDatabase();
35 35
 
36
-        /** @var Comment $comment */
37
-        $comment = Comment::getById($commentId, $database);
38
-        if ($comment === false) {
39
-            throw new ApplicationLogicException('Comment not found');
40
-        }
36
+		/** @var Comment $comment */
37
+		$comment = Comment::getById($commentId, $database);
38
+		if ($comment === false) {
39
+			throw new ApplicationLogicException('Comment not found');
40
+		}
41 41
 
42
-        $currentUser = User::getCurrent($database);
43
-        if ($comment->getUser() !== $currentUser->getId() && !$this->barrierTest('editOthers', $currentUser)) {
44
-            throw new AccessDeniedException($this->getSecurityManager());
45
-        }
42
+		$currentUser = User::getCurrent($database);
43
+		if ($comment->getUser() !== $currentUser->getId() && !$this->barrierTest('editOthers', $currentUser)) {
44
+			throw new AccessDeniedException($this->getSecurityManager());
45
+		}
46 46
 
47
-        /** @var Request $request */
48
-        $request = Request::getById($comment->getRequest(), $database);
47
+		/** @var Request $request */
48
+		$request = Request::getById($comment->getRequest(), $database);
49 49
 
50
-        if ($request === false) {
51
-            throw new ApplicationLogicException('Request was not found.');
52
-        }
50
+		if ($request === false) {
51
+			throw new ApplicationLogicException('Request was not found.');
52
+		}
53 53
 
54
-        if (WebRequest::wasPosted()) {
55
-            $this->validateCSRFToken();
56
-            $newComment = WebRequest::postString('newcomment');
57
-            $visibility = WebRequest::postString('visibility');
54
+		if (WebRequest::wasPosted()) {
55
+			$this->validateCSRFToken();
56
+			$newComment = WebRequest::postString('newcomment');
57
+			$visibility = WebRequest::postString('visibility');
58 58
 
59
-            if ($visibility !== 'user' && $visibility !== 'admin') {
60
-                throw new ApplicationLogicException('Comment visibility is not valid');
61
-            }
59
+			if ($visibility !== 'user' && $visibility !== 'admin') {
60
+				throw new ApplicationLogicException('Comment visibility is not valid');
61
+			}
62 62
 
63
-            // optimistically lock from the load of the edit comment form
64
-            $updateVersion = WebRequest::postInt('updateversion');
65
-            $comment->setUpdateVersion($updateVersion);
63
+			// optimistically lock from the load of the edit comment form
64
+			$updateVersion = WebRequest::postInt('updateversion');
65
+			$comment->setUpdateVersion($updateVersion);
66 66
 
67
-            $comment->setComment($newComment);
68
-            $comment->setVisibility($visibility);
67
+			$comment->setComment($newComment);
68
+			$comment->setVisibility($visibility);
69 69
 
70
-            $comment->save();
70
+			$comment->save();
71 71
 
72
-            Logger::editComment($database, $comment, $request);
73
-            $this->getNotificationHelper()->commentEdited($comment, $request);
74
-            SessionAlert::success("Comment has been saved successfully");
72
+			Logger::editComment($database, $comment, $request);
73
+			$this->getNotificationHelper()->commentEdited($comment, $request);
74
+			SessionAlert::success("Comment has been saved successfully");
75 75
 
76
-            $this->redirect('viewRequest', null, array('id' => $comment->getRequest()));
77
-        }
78
-        else {
79
-            $this->assignCSRFToken();
80
-            $this->assign('comment', $comment);
81
-            $this->assign('request', $request);
82
-            $this->assign('user', User::getById($comment->getUser(), $database));
83
-            $this->setTemplate('edit-comment.tpl');
84
-        }
85
-    }
76
+			$this->redirect('viewRequest', null, array('id' => $comment->getRequest()));
77
+		}
78
+		else {
79
+			$this->assignCSRFToken();
80
+			$this->assign('comment', $comment);
81
+			$this->assign('request', $request);
82
+			$this->assign('user', User::getById($comment->getUser(), $database));
83
+			$this->setTemplate('edit-comment.tpl');
84
+		}
85
+	}
86 86
 }
Please login to merge, or discard this patch.
includes/Pages/RequestAction/PageBreakReservation.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -19,81 +19,81 @@
 block discarded – undo
19 19
 
20 20
 class PageBreakReservation extends RequestActionBase
21 21
 {
22
-    protected function main()
23
-    {
24
-        $this->checkPosted();
25
-        $database = $this->getDatabase();
26
-        $request = $this->getRequest($database);
22
+	protected function main()
23
+	{
24
+		$this->checkPosted();
25
+		$database = $this->getDatabase();
26
+		$request = $this->getRequest($database);
27 27
 
28
-        if ($request->getReserved() === null) {
29
-            throw new ApplicationLogicException('Request is not reserved!');
30
-        }
28
+		if ($request->getReserved() === null) {
29
+			throw new ApplicationLogicException('Request is not reserved!');
30
+		}
31 31
 
32
-        $currentUser = User::getCurrent($database);
32
+		$currentUser = User::getCurrent($database);
33 33
 
34
-        if ($currentUser->getId() === $request->getReserved()) {
35
-            $this->doUnreserve($request, $database);
36
-        }
37
-        else {
38
-            // not the same user!
39
-            if ($this->barrierTest('force', $currentUser)) {
40
-                $this->doBreakReserve($request, $database);
41
-            }
42
-            else {
43
-                throw new AccessDeniedException($this->getSecurityManager());
44
-            }
45
-        }
46
-    }
34
+		if ($currentUser->getId() === $request->getReserved()) {
35
+			$this->doUnreserve($request, $database);
36
+		}
37
+		else {
38
+			// not the same user!
39
+			if ($this->barrierTest('force', $currentUser)) {
40
+				$this->doBreakReserve($request, $database);
41
+			}
42
+			else {
43
+				throw new AccessDeniedException($this->getSecurityManager());
44
+			}
45
+		}
46
+	}
47 47
 
48
-    /**
49
-     * @param Request     $request
50
-     * @param PdoDatabase $database
51
-     *
52
-     * @throws Exception
53
-     */
54
-    protected function doUnreserve(Request $request, PdoDatabase $database)
55
-    {
56
-        // same user! we allow people to unreserve their own stuff
57
-        $request->setReserved(null);
58
-        $request->setUpdateVersion(WebRequest::postInt('updateversion'));
59
-        $request->save();
48
+	/**
49
+	 * @param Request     $request
50
+	 * @param PdoDatabase $database
51
+	 *
52
+	 * @throws Exception
53
+	 */
54
+	protected function doUnreserve(Request $request, PdoDatabase $database)
55
+	{
56
+		// same user! we allow people to unreserve their own stuff
57
+		$request->setReserved(null);
58
+		$request->setUpdateVersion(WebRequest::postInt('updateversion'));
59
+		$request->save();
60 60
 
61
-        Logger::unreserve($database, $request);
62
-        $this->getNotificationHelper()->requestUnreserved($request);
61
+		Logger::unreserve($database, $request);
62
+		$this->getNotificationHelper()->requestUnreserved($request);
63 63
 
64
-        // Redirect home!
65
-        $this->redirect();
66
-    }
64
+		// Redirect home!
65
+		$this->redirect();
66
+	}
67 67
 
68
-    /**
69
-     * @param Request     $request
70
-     * @param PdoDatabase $database
71
-     *
72
-     * @throws Exception
73
-     */
74
-    protected function doBreakReserve(Request $request, PdoDatabase $database)
75
-    {
76
-        if (!WebRequest::postBoolean("confirm")) {
77
-            $this->assignCSRFToken();
68
+	/**
69
+	 * @param Request     $request
70
+	 * @param PdoDatabase $database
71
+	 *
72
+	 * @throws Exception
73
+	 */
74
+	protected function doBreakReserve(Request $request, PdoDatabase $database)
75
+	{
76
+		if (!WebRequest::postBoolean("confirm")) {
77
+			$this->assignCSRFToken();
78 78
 
79
-            $this->assign("request", $request->getId());
80
-            $this->assign("reservedUser", User::getById($request->getReserved(), $database));
81
-            $this->assign("updateversion", WebRequest::postInt('updateversion'));
79
+			$this->assign("request", $request->getId());
80
+			$this->assign("reservedUser", User::getById($request->getReserved(), $database));
81
+			$this->assign("updateversion", WebRequest::postInt('updateversion'));
82 82
 
83
-            $this->skipAlerts();
83
+			$this->skipAlerts();
84 84
 
85
-            $this->setTemplate("confirmations/breakreserve.tpl");
86
-        }
87
-        else {
88
-            $request->setReserved(null);
89
-            $request->setUpdateVersion(WebRequest::postInt('updateversion'));
90
-            $request->save();
85
+			$this->setTemplate("confirmations/breakreserve.tpl");
86
+		}
87
+		else {
88
+			$request->setReserved(null);
89
+			$request->setUpdateVersion(WebRequest::postInt('updateversion'));
90
+			$request->save();
91 91
 
92
-            Logger::breakReserve($database, $request);
93
-            $this->getNotificationHelper()->requestReserveBroken($request);
92
+			Logger::breakReserve($database, $request);
93
+			$this->getNotificationHelper()->requestReserveBroken($request);
94 94
 
95
-            // Redirect home!
96
-            $this->redirect();
97
-        }
98
-    }
95
+			// Redirect home!
96
+			$this->redirect();
97
+		}
98
+	}
99 99
 }
Please login to merge, or discard this patch.
includes/Pages/RequestAction/RequestActionBase.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -19,54 +19,54 @@
 block discarded – undo
19 19
 
20 20
 abstract class RequestActionBase extends InternalPageBase
21 21
 {
22
-    /**
23
-     * @param PdoDatabase $database
24
-     *
25
-     * @return Request
26
-     * @throws ApplicationLogicException
27
-     */
28
-    protected function getRequest(PdoDatabase $database)
29
-    {
30
-        $requestId = WebRequest::postInt('request');
31
-        if ($requestId === null) {
32
-            throw new ApplicationLogicException('Request ID not found');
33
-        }
22
+	/**
23
+	 * @param PdoDatabase $database
24
+	 *
25
+	 * @return Request
26
+	 * @throws ApplicationLogicException
27
+	 */
28
+	protected function getRequest(PdoDatabase $database)
29
+	{
30
+		$requestId = WebRequest::postInt('request');
31
+		if ($requestId === null) {
32
+			throw new ApplicationLogicException('Request ID not found');
33
+		}
34 34
 
35
-        /** @var Request $request */
36
-        $request = Request::getById($requestId, $database);
35
+		/** @var Request $request */
36
+		$request = Request::getById($requestId, $database);
37 37
 
38
-        if ($request === false) {
39
-            throw new ApplicationLogicException('Request not found');
40
-        }
38
+		if ($request === false) {
39
+			throw new ApplicationLogicException('Request not found');
40
+		}
41 41
 
42
-        return $request;
43
-    }
42
+		return $request;
43
+	}
44 44
 
45
-    final protected function checkPosted()
46
-    {
47
-        // if the request was not posted, send the user away.
48
-        if (!WebRequest::wasPosted()) {
49
-            throw new ApplicationLogicException('This page does not support GET methods.');
50
-        }
45
+	final protected function checkPosted()
46
+	{
47
+		// if the request was not posted, send the user away.
48
+		if (!WebRequest::wasPosted()) {
49
+			throw new ApplicationLogicException('This page does not support GET methods.');
50
+		}
51 51
 
52
-        // validate the CSRF token
53
-        $this->validateCSRFToken();
54
-    }
52
+		// validate the CSRF token
53
+		$this->validateCSRFToken();
54
+	}
55 55
 
56
-    /**
57
-     * @param Request     $request
58
-     * @param             $parentTaskId
59
-     * @param User        $user
60
-     * @param PdoDatabase $database
61
-     */
62
-    protected function enqueueWelcomeTask(Request $request, $parentTaskId, User $user, PdoDatabase $database)
63
-    {
64
-        $welcomeTask = new JobQueue();
65
-        $welcomeTask->setTask(WelcomeUserTask::class);
66
-        $welcomeTask->setRequest($request->getId());
67
-        $welcomeTask->setParent($parentTaskId);
68
-        $welcomeTask->setTriggerUserId($user->getId());
69
-        $welcomeTask->setDatabase($database);
70
-        $welcomeTask->save();
71
-    }
56
+	/**
57
+	 * @param Request     $request
58
+	 * @param             $parentTaskId
59
+	 * @param User        $user
60
+	 * @param PdoDatabase $database
61
+	 */
62
+	protected function enqueueWelcomeTask(Request $request, $parentTaskId, User $user, PdoDatabase $database)
63
+	{
64
+		$welcomeTask = new JobQueue();
65
+		$welcomeTask->setTask(WelcomeUserTask::class);
66
+		$welcomeTask->setRequest($request->getId());
67
+		$welcomeTask->setParent($parentTaskId);
68
+		$welcomeTask->setTriggerUserId($user->getId());
69
+		$welcomeTask->setDatabase($database);
70
+		$welcomeTask->save();
71
+	}
72 72
 }
73 73
\ No newline at end of file
Please login to merge, or discard this patch.