Test Setup Failed
Push — dependabot/composer/twbs/boots... ( 3e72c6 )
by
unknown
13:19
created
includes/DataObjects/GeoLocation.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -21,110 +21,110 @@
 block discarded – undo
21 21
  */
22 22
 class GeoLocation extends DataObject
23 23
 {
24
-    private $address;
25
-    private $data;
26
-    private $creation;
27
-
28
-    /**
29
-     * @param string      $address
30
-     * @param PdoDatabase $database
31
-     * @param bool        $forUpdate
32
-     * @return GeoLocation
33
-     */
34
-    public static function getByAddress($address, PdoDatabase $database, $forUpdate = false)
35
-    {
36
-        $lockMode = $forUpdate ? ' FOR UPDATE' : '';
37
-        $sql = "SELECT * FROM geolocation WHERE address = :id LIMIT 1" . $lockMode;
38
-
39
-        $statement = $database->prepare($sql);
40
-        $statement->bindValue(":id", $address);
41
-
42
-        $statement->execute();
43
-
44
-        $resultObject = $statement->fetchObject(get_called_class());
45
-
46
-        if ($resultObject != false) {
47
-            $resultObject->setDatabase($database);
48
-        }
49
-
50
-        return $resultObject;
51
-    }
52
-
53
-    public function save()
54
-    {
55
-        if ($this->isNew()) {
56
-            // insert
57
-            $statement = $this->dbObject->prepare("INSERT INTO `geolocation` (address, data) VALUES (:address, :data) ON DUPLICATE KEY UPDATE address = address;");
58
-
59
-            $statement->bindValue(":address", $this->address);
60
-            $statement->bindValue(":data", $this->data);
61
-
62
-            if ($statement->execute()) {
63
-                $this->id = (int)$this->dbObject->lastInsertId();
64
-            }
65
-            else {
66
-                throw new Exception($statement->errorInfo());
67
-            }
68
-        }
69
-        else {
70
-            // update
71
-            $statement = $this->dbObject->prepare(<<<SQL
24
+	private $address;
25
+	private $data;
26
+	private $creation;
27
+
28
+	/**
29
+	 * @param string      $address
30
+	 * @param PdoDatabase $database
31
+	 * @param bool        $forUpdate
32
+	 * @return GeoLocation
33
+	 */
34
+	public static function getByAddress($address, PdoDatabase $database, $forUpdate = false)
35
+	{
36
+		$lockMode = $forUpdate ? ' FOR UPDATE' : '';
37
+		$sql = "SELECT * FROM geolocation WHERE address = :id LIMIT 1" . $lockMode;
38
+
39
+		$statement = $database->prepare($sql);
40
+		$statement->bindValue(":id", $address);
41
+
42
+		$statement->execute();
43
+
44
+		$resultObject = $statement->fetchObject(get_called_class());
45
+
46
+		if ($resultObject != false) {
47
+			$resultObject->setDatabase($database);
48
+		}
49
+
50
+		return $resultObject;
51
+	}
52
+
53
+	public function save()
54
+	{
55
+		if ($this->isNew()) {
56
+			// insert
57
+			$statement = $this->dbObject->prepare("INSERT INTO `geolocation` (address, data) VALUES (:address, :data) ON DUPLICATE KEY UPDATE address = address;");
58
+
59
+			$statement->bindValue(":address", $this->address);
60
+			$statement->bindValue(":data", $this->data);
61
+
62
+			if ($statement->execute()) {
63
+				$this->id = (int)$this->dbObject->lastInsertId();
64
+			}
65
+			else {
66
+				throw new Exception($statement->errorInfo());
67
+			}
68
+		}
69
+		else {
70
+			// update
71
+			$statement = $this->dbObject->prepare(<<<SQL
72 72
 UPDATE `geolocation`
73 73
 SET address = :address, data = :data, updateversion = updateversion + 1
74 74
 WHERE id = :id AND updateversion = :updateversion;
75 75
 SQL
76
-            );
77
-
78
-            $statement->bindValue(":id", $this->id);
79
-            $statement->bindValue(":updateversion", $this->updateversion);
80
-
81
-            $statement->bindValue(":address", $this->address);
82
-            $statement->bindValue(":data", $this->data);
83
-
84
-            if (!$statement->execute()) {
85
-                throw new Exception($statement->errorInfo());
86
-            }
87
-
88
-            if ($statement->rowCount() !== 1) {
89
-                throw new OptimisticLockFailedException();
90
-            }
91
-
92
-            $this->updateversion++;
93
-        }
94
-    }
95
-
96
-    public function getAddress()
97
-    {
98
-        return $this->address;
99
-    }
100
-
101
-    /**
102
-     * @param string $address
103
-     */
104
-    public function setAddress($address)
105
-    {
106
-        $this->address = $address;
107
-    }
108
-
109
-    /**
110
-     * @return array
111
-     */
112
-    public function getData()
113
-    {
114
-        return unserialize($this->data);
115
-    }
116
-
117
-    /**
118
-     * @param array $data
119
-     */
120
-    public function setData($data)
121
-    {
122
-        $this->data = serialize($data);
123
-    }
124
-
125
-    /** @return DateTimeImmutable */
126
-    public function getCreation()
127
-    {
128
-        return new DateTimeImmutable($this->creation);
129
-    }
76
+			);
77
+
78
+			$statement->bindValue(":id", $this->id);
79
+			$statement->bindValue(":updateversion", $this->updateversion);
80
+
81
+			$statement->bindValue(":address", $this->address);
82
+			$statement->bindValue(":data", $this->data);
83
+
84
+			if (!$statement->execute()) {
85
+				throw new Exception($statement->errorInfo());
86
+			}
87
+
88
+			if ($statement->rowCount() !== 1) {
89
+				throw new OptimisticLockFailedException();
90
+			}
91
+
92
+			$this->updateversion++;
93
+		}
94
+	}
95
+
96
+	public function getAddress()
97
+	{
98
+		return $this->address;
99
+	}
100
+
101
+	/**
102
+	 * @param string $address
103
+	 */
104
+	public function setAddress($address)
105
+	{
106
+		$this->address = $address;
107
+	}
108
+
109
+	/**
110
+	 * @return array
111
+	 */
112
+	public function getData()
113
+	{
114
+		return unserialize($this->data);
115
+	}
116
+
117
+	/**
118
+	 * @param array $data
119
+	 */
120
+	public function setData($data)
121
+	{
122
+		$this->data = serialize($data);
123
+	}
124
+
125
+	/** @return DateTimeImmutable */
126
+	public function getCreation()
127
+	{
128
+		return new DateTimeImmutable($this->creation);
129
+	}
130 130
 }
Please login to merge, or discard this patch.
includes/DataObjects/JobQueue.php 1 patch
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 class JobQueue extends DataObject
19 19
 {
20
-    /*
20
+	/*
21 21
      * Status workflow is this:
22 22
      *
23 23
      * 1) Ready. The job has been added to the queue
@@ -26,78 +26,78 @@  discard block
 block discarded – undo
26 26
      * 3) Complete / Failed. The job has been processed
27 27
      *
28 28
      */
29
-    const STATUS_READY = 'ready';
30
-    const STATUS_WAITING = 'waiting';
31
-    const STATUS_RUNNING = 'running';
32
-    const STATUS_COMPLETE = 'complete';
33
-    const STATUS_CANCELLED = 'cancelled';
34
-    const STATUS_FAILED = 'failed';
35
-    const STATUS_HELD = 'held';
36
-
37
-    /** @var string */
38
-    private $task;
39
-    /** @var int */
40
-    private $user;
41
-    /** @var int */
42
-    private $request;
43
-    /** @var int */
44
-    private $emailtemplate;
45
-    /** @var string */
46
-    private $status;
47
-    /** @var string */
48
-    private $enqueue;
49
-    /** @var string */
50
-    private $parameters;
51
-    /** @var string */
52
-    private $error;
53
-    /** @var int */
54
-    private $acknowledged;
55
-    /** @var int */
56
-    private $parent;
57
-
58
-    /**
59
-     * This feels like the least bad place to put this method.
60
-     */
61
-    public static function getTaskDescriptions() {
62
-        return array(
63
-            BotCreationTask::class  => 'Create account (via bot)',
64
-            UserCreationTask::class => 'Create account (via OAuth)',
65
-            WelcomeUserTask::class  => 'Welcome user',
66
-        );
67
-    }
68
-
69
-    /**
70
-     * Saves a data object to the database, either updating or inserting a record.
71
-     * @return void
72
-     * @throws Exception
73
-     * @throws OptimisticLockFailedException
74
-     */
75
-    public function save()
76
-    {
77
-        if ($this->isNew()) {
78
-            // insert
79
-            $statement = $this->dbObject->prepare(<<<SQL
29
+	const STATUS_READY = 'ready';
30
+	const STATUS_WAITING = 'waiting';
31
+	const STATUS_RUNNING = 'running';
32
+	const STATUS_COMPLETE = 'complete';
33
+	const STATUS_CANCELLED = 'cancelled';
34
+	const STATUS_FAILED = 'failed';
35
+	const STATUS_HELD = 'held';
36
+
37
+	/** @var string */
38
+	private $task;
39
+	/** @var int */
40
+	private $user;
41
+	/** @var int */
42
+	private $request;
43
+	/** @var int */
44
+	private $emailtemplate;
45
+	/** @var string */
46
+	private $status;
47
+	/** @var string */
48
+	private $enqueue;
49
+	/** @var string */
50
+	private $parameters;
51
+	/** @var string */
52
+	private $error;
53
+	/** @var int */
54
+	private $acknowledged;
55
+	/** @var int */
56
+	private $parent;
57
+
58
+	/**
59
+	 * This feels like the least bad place to put this method.
60
+	 */
61
+	public static function getTaskDescriptions() {
62
+		return array(
63
+			BotCreationTask::class  => 'Create account (via bot)',
64
+			UserCreationTask::class => 'Create account (via OAuth)',
65
+			WelcomeUserTask::class  => 'Welcome user',
66
+		);
67
+	}
68
+
69
+	/**
70
+	 * Saves a data object to the database, either updating or inserting a record.
71
+	 * @return void
72
+	 * @throws Exception
73
+	 * @throws OptimisticLockFailedException
74
+	 */
75
+	public function save()
76
+	{
77
+		if ($this->isNew()) {
78
+			// insert
79
+			$statement = $this->dbObject->prepare(<<<SQL
80 80
                 INSERT INTO jobqueue (task, user, request, emailtemplate, parameters, parent) 
81 81
                 VALUES (:task, :user, :request, :emailtemplate, :parameters, :parent)
82 82
 SQL
83
-            );
84
-            $statement->bindValue(":task", $this->task);
85
-            $statement->bindValue(":user", $this->user);
86
-            $statement->bindValue(":request", $this->request);
87
-            $statement->bindValue(":emailtemplate", $this->emailtemplate);
88
-            $statement->bindValue(":parameters", $this->parameters);
89
-            $statement->bindValue(":parent", $this->parent);
90
-
91
-            if ($statement->execute()) {
92
-                $this->id = (int)$this->dbObject->lastInsertId();
93
-            }
94
-            else {
95
-                throw new Exception($statement->errorInfo());
96
-            }
97
-        }
98
-        else {
99
-            // update
100
-            $statement = $this->dbObject->prepare(<<<SQL
83
+			);
84
+			$statement->bindValue(":task", $this->task);
85
+			$statement->bindValue(":user", $this->user);
86
+			$statement->bindValue(":request", $this->request);
87
+			$statement->bindValue(":emailtemplate", $this->emailtemplate);
88
+			$statement->bindValue(":parameters", $this->parameters);
89
+			$statement->bindValue(":parent", $this->parent);
90
+
91
+			if ($statement->execute()) {
92
+				$this->id = (int)$this->dbObject->lastInsertId();
93
+			}
94
+			else {
95
+				throw new Exception($statement->errorInfo());
96
+			}
97
+		}
98
+		else {
99
+			// update
100
+			$statement = $this->dbObject->prepare(<<<SQL
101 101
                 UPDATE jobqueue SET 
102 102
                       status = :status
103 103
                     , error = :error
@@ -105,187 +105,187 @@  discard block
 block discarded – undo
105 105
                     , updateversion = updateversion + 1
106 106
                 WHERE id = :id AND updateversion = :updateversion;
107 107
 SQL
108
-            );
109
-
110
-            $statement->bindValue(":id", $this->id);
111
-            $statement->bindValue(":updateversion", $this->updateversion);
112
-
113
-            $statement->bindValue(":status", $this->status);
114
-            $statement->bindValue(":error", $this->error);
115
-            $statement->bindValue(":ack", $this->acknowledged);
116
-
117
-            if (!$statement->execute()) {
118
-                throw new Exception($statement->errorInfo());
119
-            }
120
-
121
-            if ($statement->rowCount() !== 1) {
122
-                throw new OptimisticLockFailedException();
123
-            }
124
-
125
-            $this->updateversion++;
126
-        }
127
-    }
128
-
129
-    #region Properties
130
-
131
-    /**
132
-     * @return string
133
-     */
134
-    public function getTask()
135
-    {
136
-        return $this->task;
137
-    }
138
-
139
-    /**
140
-     * @param string $task
141
-     */
142
-    public function setTask($task)
143
-    {
144
-        $this->task = $task;
145
-    }
146
-
147
-    /**
148
-     * @return int
149
-     */
150
-    public function getTriggerUserId()
151
-    {
152
-        return $this->user;
153
-    }
154
-
155
-    /**
156
-     * @param int $user
157
-     */
158
-    public function setTriggerUserId($user)
159
-    {
160
-        $this->user = $user;
161
-    }
162
-
163
-    /**
164
-     * @return int
165
-     */
166
-    public function getRequest()
167
-    {
168
-        return $this->request;
169
-    }
170
-
171
-    /**
172
-     * @param int $request
173
-     */
174
-    public function setRequest($request)
175
-    {
176
-        $this->request = $request;
177
-    }
178
-
179
-    /**
180
-     * @return string
181
-     */
182
-    public function getStatus()
183
-    {
184
-        return $this->status;
185
-    }
186
-
187
-    /**
188
-     * @param string $status
189
-     */
190
-    public function setStatus($status)
191
-    {
192
-        $this->status = $status;
193
-    }
194
-
195
-    /**
196
-     * @return string
197
-     */
198
-    public function getEnqueue()
199
-    {
200
-        return $this->enqueue;
201
-    }
202
-
203
-    /**
204
-     * @param string $enqueue
205
-     */
206
-    public function setEnqueue($enqueue)
207
-    {
208
-        $this->enqueue = $enqueue;
209
-    }
210
-
211
-    /**
212
-     * @return string
213
-     */
214
-    public function getParameters()
215
-    {
216
-        return $this->parameters;
217
-    }
218
-
219
-    /**
220
-     * @param string $parameters
221
-     */
222
-    public function setParameters($parameters)
223
-    {
224
-        $this->parameters = $parameters;
225
-    }
226
-
227
-    /**
228
-     * @return mixed
229
-     */
230
-    public function getError()
231
-    {
232
-        return $this->error;
233
-    }
234
-
235
-    /**
236
-     * @param mixed $error
237
-     */
238
-    public function setError($error)
239
-    {
240
-        $this->error = $error;
241
-    }
242
-
243
-    /**
244
-     * @return int
245
-     */
246
-    public function getAcknowledged()
247
-    {
248
-        return $this->acknowledged;
249
-    }
250
-
251
-    /**
252
-     * @param int $acknowledged
253
-     */
254
-    public function setAcknowledged($acknowledged)
255
-    {
256
-        $this->acknowledged = $acknowledged;
257
-    }
258
-
259
-    /**
260
-     * @return int
261
-     */
262
-    public function getParent()
263
-    {
264
-        return $this->parent;
265
-    }
266
-
267
-    /**
268
-     * @param int $parent
269
-     */
270
-    public function setParent($parent)
271
-    {
272
-        $this->parent = $parent;
273
-    }
274
-
275
-    /**
276
-     * @return int
277
-     */
278
-    public function getEmailTemplate()
279
-    {
280
-        return $this->emailtemplate;
281
-    }
282
-
283
-    /**
284
-     * @param int $emailTemplate
285
-     */
286
-    public function setEmailTemplate($emailTemplate)
287
-    {
288
-        $this->emailtemplate = $emailTemplate;
289
-    }
290
-    #endregion
108
+			);
109
+
110
+			$statement->bindValue(":id", $this->id);
111
+			$statement->bindValue(":updateversion", $this->updateversion);
112
+
113
+			$statement->bindValue(":status", $this->status);
114
+			$statement->bindValue(":error", $this->error);
115
+			$statement->bindValue(":ack", $this->acknowledged);
116
+
117
+			if (!$statement->execute()) {
118
+				throw new Exception($statement->errorInfo());
119
+			}
120
+
121
+			if ($statement->rowCount() !== 1) {
122
+				throw new OptimisticLockFailedException();
123
+			}
124
+
125
+			$this->updateversion++;
126
+		}
127
+	}
128
+
129
+	#region Properties
130
+
131
+	/**
132
+	 * @return string
133
+	 */
134
+	public function getTask()
135
+	{
136
+		return $this->task;
137
+	}
138
+
139
+	/**
140
+	 * @param string $task
141
+	 */
142
+	public function setTask($task)
143
+	{
144
+		$this->task = $task;
145
+	}
146
+
147
+	/**
148
+	 * @return int
149
+	 */
150
+	public function getTriggerUserId()
151
+	{
152
+		return $this->user;
153
+	}
154
+
155
+	/**
156
+	 * @param int $user
157
+	 */
158
+	public function setTriggerUserId($user)
159
+	{
160
+		$this->user = $user;
161
+	}
162
+
163
+	/**
164
+	 * @return int
165
+	 */
166
+	public function getRequest()
167
+	{
168
+		return $this->request;
169
+	}
170
+
171
+	/**
172
+	 * @param int $request
173
+	 */
174
+	public function setRequest($request)
175
+	{
176
+		$this->request = $request;
177
+	}
178
+
179
+	/**
180
+	 * @return string
181
+	 */
182
+	public function getStatus()
183
+	{
184
+		return $this->status;
185
+	}
186
+
187
+	/**
188
+	 * @param string $status
189
+	 */
190
+	public function setStatus($status)
191
+	{
192
+		$this->status = $status;
193
+	}
194
+
195
+	/**
196
+	 * @return string
197
+	 */
198
+	public function getEnqueue()
199
+	{
200
+		return $this->enqueue;
201
+	}
202
+
203
+	/**
204
+	 * @param string $enqueue
205
+	 */
206
+	public function setEnqueue($enqueue)
207
+	{
208
+		$this->enqueue = $enqueue;
209
+	}
210
+
211
+	/**
212
+	 * @return string
213
+	 */
214
+	public function getParameters()
215
+	{
216
+		return $this->parameters;
217
+	}
218
+
219
+	/**
220
+	 * @param string $parameters
221
+	 */
222
+	public function setParameters($parameters)
223
+	{
224
+		$this->parameters = $parameters;
225
+	}
226
+
227
+	/**
228
+	 * @return mixed
229
+	 */
230
+	public function getError()
231
+	{
232
+		return $this->error;
233
+	}
234
+
235
+	/**
236
+	 * @param mixed $error
237
+	 */
238
+	public function setError($error)
239
+	{
240
+		$this->error = $error;
241
+	}
242
+
243
+	/**
244
+	 * @return int
245
+	 */
246
+	public function getAcknowledged()
247
+	{
248
+		return $this->acknowledged;
249
+	}
250
+
251
+	/**
252
+	 * @param int $acknowledged
253
+	 */
254
+	public function setAcknowledged($acknowledged)
255
+	{
256
+		$this->acknowledged = $acknowledged;
257
+	}
258
+
259
+	/**
260
+	 * @return int
261
+	 */
262
+	public function getParent()
263
+	{
264
+		return $this->parent;
265
+	}
266
+
267
+	/**
268
+	 * @param int $parent
269
+	 */
270
+	public function setParent($parent)
271
+	{
272
+		$this->parent = $parent;
273
+	}
274
+
275
+	/**
276
+	 * @return int
277
+	 */
278
+	public function getEmailTemplate()
279
+	{
280
+		return $this->emailtemplate;
281
+	}
282
+
283
+	/**
284
+	 * @param int $emailTemplate
285
+	 */
286
+	public function setEmailTemplate($emailTemplate)
287
+	{
288
+		$this->emailtemplate = $emailTemplate;
289
+	}
290
+	#endregion
291 291
 }
292 292
\ No newline at end of file
Please login to merge, or discard this patch.
includes/DataObjects/WelcomeTemplate.php 1 patch
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -19,166 +19,166 @@
 block discarded – undo
19 19
  */
20 20
 class WelcomeTemplate extends DataObject
21 21
 {
22
-    /** @var string */
23
-    private $usercode;
24
-    /** @var string */
25
-    private $botcode;
26
-    private $usageCache;
27
-    private $deleted = 0;
28
-
29
-    /**
30
-     * Summary of getAll
31
-     *
32
-     * @param PdoDatabase $database
33
-     *
34
-     * @return WelcomeTemplate[]
35
-     */
36
-    public static function getAll(PdoDatabase $database)
37
-    {
38
-        $statement = $database->prepare("SELECT * FROM welcometemplate WHERE deleted = 0;");
39
-
40
-        $statement->execute();
41
-
42
-        $result = array();
43
-        /** @var WelcomeTemplate $v */
44
-        foreach ($statement->fetchAll(PDO::FETCH_CLASS, self::class) as $v) {
45
-            $v->setDatabase($database);
46
-            $result[] = $v;
47
-        }
48
-
49
-        return $result;
50
-    }
51
-
52
-    /**
53
-     * @throws Exception
54
-     */
55
-    public function save()
56
-    {
57
-        if ($this->isNew()) {
58
-            // insert
59
-            $statement = $this->dbObject->prepare(<<<SQL
22
+	/** @var string */
23
+	private $usercode;
24
+	/** @var string */
25
+	private $botcode;
26
+	private $usageCache;
27
+	private $deleted = 0;
28
+
29
+	/**
30
+	 * Summary of getAll
31
+	 *
32
+	 * @param PdoDatabase $database
33
+	 *
34
+	 * @return WelcomeTemplate[]
35
+	 */
36
+	public static function getAll(PdoDatabase $database)
37
+	{
38
+		$statement = $database->prepare("SELECT * FROM welcometemplate WHERE deleted = 0;");
39
+
40
+		$statement->execute();
41
+
42
+		$result = array();
43
+		/** @var WelcomeTemplate $v */
44
+		foreach ($statement->fetchAll(PDO::FETCH_CLASS, self::class) as $v) {
45
+			$v->setDatabase($database);
46
+			$result[] = $v;
47
+		}
48
+
49
+		return $result;
50
+	}
51
+
52
+	/**
53
+	 * @throws Exception
54
+	 */
55
+	public function save()
56
+	{
57
+		if ($this->isNew()) {
58
+			// insert
59
+			$statement = $this->dbObject->prepare(<<<SQL
60 60
 INSERT INTO welcometemplate (usercode, botcode) VALUES (:usercode, :botcode);
61 61
 SQL
62
-            );
63
-            $statement->bindValue(":usercode", $this->usercode);
64
-            $statement->bindValue(":botcode", $this->botcode);
65
-
66
-            if ($statement->execute()) {
67
-                $this->id = (int)$this->dbObject->lastInsertId();
68
-            }
69
-            else {
70
-                throw new Exception($statement->errorInfo());
71
-            }
72
-        }
73
-        else {
74
-            // update
75
-            $statement = $this->dbObject->prepare(<<<SQL
62
+			);
63
+			$statement->bindValue(":usercode", $this->usercode);
64
+			$statement->bindValue(":botcode", $this->botcode);
65
+
66
+			if ($statement->execute()) {
67
+				$this->id = (int)$this->dbObject->lastInsertId();
68
+			}
69
+			else {
70
+				throw new Exception($statement->errorInfo());
71
+			}
72
+		}
73
+		else {
74
+			// update
75
+			$statement = $this->dbObject->prepare(<<<SQL
76 76
 UPDATE `welcometemplate`
77 77
 SET usercode = :usercode, botcode = :botcode, updateversion = updateversion + 1
78 78
 WHERE id = :id AND updateversion = :updateversion;
79 79
 SQL
80
-            );
81
-
82
-            $statement->bindValue(':id', $this->id);
83
-            $statement->bindValue(':updateversion', $this->updateversion);
84
-
85
-            $statement->bindValue(':usercode', $this->usercode);
86
-            $statement->bindValue(':botcode', $this->botcode);
87
-
88
-            if (!$statement->execute()) {
89
-                throw new Exception($statement->errorInfo());
90
-            }
91
-
92
-            if ($statement->rowCount() !== 1) {
93
-                throw new OptimisticLockFailedException();
94
-            }
95
-
96
-            $this->updateversion++;
97
-        }
98
-    }
99
-
100
-    /**
101
-     * @return string
102
-     */
103
-    public function getUserCode()
104
-    {
105
-        return $this->usercode;
106
-    }
107
-
108
-    /**
109
-     * @param string $usercode
110
-     */
111
-    public function setUserCode($usercode)
112
-    {
113
-        $this->usercode = $usercode;
114
-    }
115
-
116
-    /**
117
-     * @return string
118
-     */
119
-    public function getBotCode()
120
-    {
121
-        return $this->botcode;
122
-    }
123
-
124
-    /**
125
-     * @param string $botcode
126
-     */
127
-    public function setBotCode($botcode)
128
-    {
129
-        $this->botcode = $botcode;
130
-    }
131
-
132
-    /**
133
-     * @return User[]
134
-     */
135
-    public function getUsersUsingTemplate()
136
-    {
137
-        if ($this->usageCache === null) {
138
-            $statement = $this->dbObject->prepare("SELECT * FROM user WHERE welcome_template = :id;");
139
-
140
-            $statement->execute(array(":id" => $this->id));
141
-
142
-            $result = array();
143
-            /** @var WelcomeTemplate $v */
144
-            foreach ($statement->fetchAll(PDO::FETCH_CLASS, User::class) as $v) {
145
-                $v->setDatabase($this->dbObject);
146
-                $result[] = $v;
147
-            }
148
-
149
-            $this->usageCache = $result;
150
-        }
151
-
152
-        return $this->usageCache;
153
-    }
154
-
155
-    /**
156
-     * Deletes the object from the database
157
-     */
158
-    public function delete()
159
-    {
160
-        if ($this->id === null) {
161
-            // wtf?
162
-            return;
163
-        }
164
-
165
-        $deleteQuery = "UPDATE welcometemplate SET deleted = 1 WHERE id = :id AND updateversion = :updateversion;";
166
-        $statement = $this->dbObject->prepare($deleteQuery);
167
-
168
-        $statement->bindValue(":id", $this->id);
169
-        $statement->bindValue(":updateversion", $this->updateversion);
170
-        $statement->execute();
171
-
172
-        if ($statement->rowCount() !== 1) {
173
-            throw new OptimisticLockFailedException();
174
-        }
175
-    }
176
-
177
-    /**
178
-     * @return bool
179
-     */
180
-    public function isDeleted()
181
-    {
182
-        return ((int)$this->deleted) === 1;
183
-    }
80
+			);
81
+
82
+			$statement->bindValue(':id', $this->id);
83
+			$statement->bindValue(':updateversion', $this->updateversion);
84
+
85
+			$statement->bindValue(':usercode', $this->usercode);
86
+			$statement->bindValue(':botcode', $this->botcode);
87
+
88
+			if (!$statement->execute()) {
89
+				throw new Exception($statement->errorInfo());
90
+			}
91
+
92
+			if ($statement->rowCount() !== 1) {
93
+				throw new OptimisticLockFailedException();
94
+			}
95
+
96
+			$this->updateversion++;
97
+		}
98
+	}
99
+
100
+	/**
101
+	 * @return string
102
+	 */
103
+	public function getUserCode()
104
+	{
105
+		return $this->usercode;
106
+	}
107
+
108
+	/**
109
+	 * @param string $usercode
110
+	 */
111
+	public function setUserCode($usercode)
112
+	{
113
+		$this->usercode = $usercode;
114
+	}
115
+
116
+	/**
117
+	 * @return string
118
+	 */
119
+	public function getBotCode()
120
+	{
121
+		return $this->botcode;
122
+	}
123
+
124
+	/**
125
+	 * @param string $botcode
126
+	 */
127
+	public function setBotCode($botcode)
128
+	{
129
+		$this->botcode = $botcode;
130
+	}
131
+
132
+	/**
133
+	 * @return User[]
134
+	 */
135
+	public function getUsersUsingTemplate()
136
+	{
137
+		if ($this->usageCache === null) {
138
+			$statement = $this->dbObject->prepare("SELECT * FROM user WHERE welcome_template = :id;");
139
+
140
+			$statement->execute(array(":id" => $this->id));
141
+
142
+			$result = array();
143
+			/** @var WelcomeTemplate $v */
144
+			foreach ($statement->fetchAll(PDO::FETCH_CLASS, User::class) as $v) {
145
+				$v->setDatabase($this->dbObject);
146
+				$result[] = $v;
147
+			}
148
+
149
+			$this->usageCache = $result;
150
+		}
151
+
152
+		return $this->usageCache;
153
+	}
154
+
155
+	/**
156
+	 * Deletes the object from the database
157
+	 */
158
+	public function delete()
159
+	{
160
+		if ($this->id === null) {
161
+			// wtf?
162
+			return;
163
+		}
164
+
165
+		$deleteQuery = "UPDATE welcometemplate SET deleted = 1 WHERE id = :id AND updateversion = :updateversion;";
166
+		$statement = $this->dbObject->prepare($deleteQuery);
167
+
168
+		$statement->bindValue(":id", $this->id);
169
+		$statement->bindValue(":updateversion", $this->updateversion);
170
+		$statement->execute();
171
+
172
+		if ($statement->rowCount() !== 1) {
173
+			throw new OptimisticLockFailedException();
174
+		}
175
+	}
176
+
177
+	/**
178
+	 * @return bool
179
+	 */
180
+	public function isDeleted()
181
+	{
182
+		return ((int)$this->deleted) === 1;
183
+	}
184 184
 }
Please login to merge, or discard this patch.
includes/DataObjects/EmailTemplate.php 1 patch
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -21,176 +21,176 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class EmailTemplate extends DataObject
23 23
 {
24
-    /** Note, also used in template-table.tpl */
25
-    const CREATED = "created";
26
-    /** Note, also used in template-table.tpl */
27
-    const NOT_CREATED = "not created";
28
-    /** Note, also used in template-table.tpl */
29
-    const NONE = null;
30
-    /** @var string the name of the template */
31
-    private $name;
32
-    private $text;
33
-    /** @var string|null */
34
-    private $jsquestion;
35
-    private $active = 1;
36
-    private $preloadonly = 0;
37
-    private $defaultaction = self::NOT_CREATED;
38
-
39
-    /**
40
-     * Gets active non-preload templates
41
-     *
42
-     * @param string      $defaultAction Default action to take (EmailTemplate::CREATED or EmailTemplate::NOT_CREATED)
43
-     * @param PdoDatabase $database
44
-     *
45
-     * @return array|false
46
-     */
47
-    public static function getActiveTemplates($defaultAction, PdoDatabase $database)
48
-    {
49
-        global $createdid;
50
-
51
-        $statement = $database->prepare(<<<SQL
24
+	/** Note, also used in template-table.tpl */
25
+	const CREATED = "created";
26
+	/** Note, also used in template-table.tpl */
27
+	const NOT_CREATED = "not created";
28
+	/** Note, also used in template-table.tpl */
29
+	const NONE = null;
30
+	/** @var string the name of the template */
31
+	private $name;
32
+	private $text;
33
+	/** @var string|null */
34
+	private $jsquestion;
35
+	private $active = 1;
36
+	private $preloadonly = 0;
37
+	private $defaultaction = self::NOT_CREATED;
38
+
39
+	/**
40
+	 * Gets active non-preload templates
41
+	 *
42
+	 * @param string      $defaultAction Default action to take (EmailTemplate::CREATED or EmailTemplate::NOT_CREATED)
43
+	 * @param PdoDatabase $database
44
+	 *
45
+	 * @return array|false
46
+	 */
47
+	public static function getActiveTemplates($defaultAction, PdoDatabase $database)
48
+	{
49
+		global $createdid;
50
+
51
+		$statement = $database->prepare(<<<SQL
52 52
 SELECT * FROM `emailtemplate`
53 53
 WHERE defaultaction = :forcreated AND active = 1 AND preloadonly = 0 AND id != :createdid;
54 54
 SQL
55
-        );
56
-        $statement->bindValue(":createdid", $createdid);
57
-        $statement->bindValue(":forcreated", $defaultAction);
58
-
59
-        $statement->execute();
60
-
61
-        $resultObject = $statement->fetchAll(PDO::FETCH_CLASS, get_called_class());
62
-
63
-        /** @var EmailTemplate $t */
64
-        foreach ($resultObject as $t) {
65
-            $t->setDatabase($database);
66
-        }
67
-
68
-        return $resultObject;
69
-    }
70
-
71
-    /**
72
-     * Gets active non-preload and preload templates, optionally filtered by the default action.
73
-     *
74
-     * @param null|bool|string $defaultAction Default action to take (EmailTemplate::CREATED,
75
-     *                                        EmailTemplate::NOT_CREATED, or EmailTemplate::NONE), or optionally null to
76
-     *                                        just get everything.
77
-     * @param PdoDatabase      $database
78
-     *
79
-     * @return array|false
80
-     */
81
-    public static function getAllActiveTemplates($defaultAction, PdoDatabase $database)
82
-    {
83
-        $statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE defaultaction = :forcreated AND active = 1;");
84
-
85
-        if ($defaultAction === false) {
86
-            $statement = $database->prepare(
87
-                "SELECT * FROM `emailtemplate` WHERE defaultaction NOT IN ('created', 'not created') AND active = 1;");
88
-        }
89
-
90
-        if ($defaultAction === null) {
91
-            $statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE  active = 1;");
92
-        }
93
-
94
-        $statement->bindValue(":forcreated", $defaultAction);
95
-
96
-        $statement->execute();
97
-
98
-        $resultObject = $statement->fetchAll(PDO::FETCH_CLASS, get_called_class());
99
-
100
-        /** @var EmailTemplate $t */
101
-        foreach ($resultObject as $t) {
102
-            $t->setDatabase($database);
103
-        }
104
-
105
-        return $resultObject;
106
-    }
107
-
108
-    /**
109
-     * Gets all the unactive templates
110
-     *
111
-     * @param PdoDatabase $database
112
-     *
113
-     * @return array
114
-     */
115
-    public static function getAllInactiveTemplates(PdoDatabase $database)
116
-    {
117
-        $statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE  active = 0;");
118
-        $statement->execute();
119
-
120
-        $resultObject = $statement->fetchAll(PDO::FETCH_CLASS, get_called_class());
121
-
122
-        /** @var EmailTemplate $t */
123
-        foreach ($resultObject as $t) {
124
-            $t->setDatabase($database);
125
-        }
126
-
127
-        return $resultObject;
128
-    }
129
-
130
-    /**
131
-     * @param string      $name
132
-     * @param PdoDatabase $database
133
-     *
134
-     * @return EmailTemplate|false
135
-     */
136
-    public static function getByName($name, PdoDatabase $database)
137
-    {
138
-        $statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE name = :name LIMIT 1;");
139
-        $statement->bindValue(":name", $name);
140
-
141
-        $statement->execute();
142
-
143
-        $resultObject = $statement->fetchObject(get_called_class());
144
-
145
-        if ($resultObject != false) {
146
-            $resultObject->setDatabase($database);
147
-        }
148
-
149
-        return $resultObject;
150
-    }
151
-
152
-    /**
153
-     * @return EmailTemplate
154
-     */
155
-    public static function getDroppedTemplate()
156
-    {
157
-        $t = new EmailTemplate();
158
-        $t->id = 0;
159
-        $t->active = 1;
160
-        $t->name = 'Dropped';
161
-
162
-        return $t;
163
-    }
164
-
165
-    /**
166
-     * @throws Exception
167
-     */
168
-    public function save()
169
-    {
170
-        if ($this->isNew()) {
171
-            // insert
172
-            $statement = $this->dbObject->prepare(<<<SQL
55
+		);
56
+		$statement->bindValue(":createdid", $createdid);
57
+		$statement->bindValue(":forcreated", $defaultAction);
58
+
59
+		$statement->execute();
60
+
61
+		$resultObject = $statement->fetchAll(PDO::FETCH_CLASS, get_called_class());
62
+
63
+		/** @var EmailTemplate $t */
64
+		foreach ($resultObject as $t) {
65
+			$t->setDatabase($database);
66
+		}
67
+
68
+		return $resultObject;
69
+	}
70
+
71
+	/**
72
+	 * Gets active non-preload and preload templates, optionally filtered by the default action.
73
+	 *
74
+	 * @param null|bool|string $defaultAction Default action to take (EmailTemplate::CREATED,
75
+	 *                                        EmailTemplate::NOT_CREATED, or EmailTemplate::NONE), or optionally null to
76
+	 *                                        just get everything.
77
+	 * @param PdoDatabase      $database
78
+	 *
79
+	 * @return array|false
80
+	 */
81
+	public static function getAllActiveTemplates($defaultAction, PdoDatabase $database)
82
+	{
83
+		$statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE defaultaction = :forcreated AND active = 1;");
84
+
85
+		if ($defaultAction === false) {
86
+			$statement = $database->prepare(
87
+				"SELECT * FROM `emailtemplate` WHERE defaultaction NOT IN ('created', 'not created') AND active = 1;");
88
+		}
89
+
90
+		if ($defaultAction === null) {
91
+			$statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE  active = 1;");
92
+		}
93
+
94
+		$statement->bindValue(":forcreated", $defaultAction);
95
+
96
+		$statement->execute();
97
+
98
+		$resultObject = $statement->fetchAll(PDO::FETCH_CLASS, get_called_class());
99
+
100
+		/** @var EmailTemplate $t */
101
+		foreach ($resultObject as $t) {
102
+			$t->setDatabase($database);
103
+		}
104
+
105
+		return $resultObject;
106
+	}
107
+
108
+	/**
109
+	 * Gets all the unactive templates
110
+	 *
111
+	 * @param PdoDatabase $database
112
+	 *
113
+	 * @return array
114
+	 */
115
+	public static function getAllInactiveTemplates(PdoDatabase $database)
116
+	{
117
+		$statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE  active = 0;");
118
+		$statement->execute();
119
+
120
+		$resultObject = $statement->fetchAll(PDO::FETCH_CLASS, get_called_class());
121
+
122
+		/** @var EmailTemplate $t */
123
+		foreach ($resultObject as $t) {
124
+			$t->setDatabase($database);
125
+		}
126
+
127
+		return $resultObject;
128
+	}
129
+
130
+	/**
131
+	 * @param string      $name
132
+	 * @param PdoDatabase $database
133
+	 *
134
+	 * @return EmailTemplate|false
135
+	 */
136
+	public static function getByName($name, PdoDatabase $database)
137
+	{
138
+		$statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE name = :name LIMIT 1;");
139
+		$statement->bindValue(":name", $name);
140
+
141
+		$statement->execute();
142
+
143
+		$resultObject = $statement->fetchObject(get_called_class());
144
+
145
+		if ($resultObject != false) {
146
+			$resultObject->setDatabase($database);
147
+		}
148
+
149
+		return $resultObject;
150
+	}
151
+
152
+	/**
153
+	 * @return EmailTemplate
154
+	 */
155
+	public static function getDroppedTemplate()
156
+	{
157
+		$t = new EmailTemplate();
158
+		$t->id = 0;
159
+		$t->active = 1;
160
+		$t->name = 'Dropped';
161
+
162
+		return $t;
163
+	}
164
+
165
+	/**
166
+	 * @throws Exception
167
+	 */
168
+	public function save()
169
+	{
170
+		if ($this->isNew()) {
171
+			// insert
172
+			$statement = $this->dbObject->prepare(<<<SQL
173 173
 INSERT INTO `emailtemplate` (name, text, jsquestion, defaultaction, active, preloadonly)
174 174
 VALUES (:name, :text, :jsquestion, :defaultaction, :active, :preloadonly);
175 175
 SQL
176
-            );
177
-            $statement->bindValue(":name", $this->name);
178
-            $statement->bindValue(":text", $this->text);
179
-            $statement->bindValue(":jsquestion", $this->jsquestion);
180
-            $statement->bindValue(":defaultaction", $this->defaultaction);
181
-            $statement->bindValue(":active", $this->active);
182
-            $statement->bindValue(":preloadonly", $this->preloadonly);
183
-
184
-            if ($statement->execute()) {
185
-                $this->id = (int)$this->dbObject->lastInsertId();
186
-            }
187
-            else {
188
-                throw new Exception($statement->errorInfo());
189
-            }
190
-        }
191
-        else {
192
-            // update
193
-            $statement = $this->dbObject->prepare(<<<SQL
176
+			);
177
+			$statement->bindValue(":name", $this->name);
178
+			$statement->bindValue(":text", $this->text);
179
+			$statement->bindValue(":jsquestion", $this->jsquestion);
180
+			$statement->bindValue(":defaultaction", $this->defaultaction);
181
+			$statement->bindValue(":active", $this->active);
182
+			$statement->bindValue(":preloadonly", $this->preloadonly);
183
+
184
+			if ($statement->execute()) {
185
+				$this->id = (int)$this->dbObject->lastInsertId();
186
+			}
187
+			else {
188
+				throw new Exception($statement->errorInfo());
189
+			}
190
+		}
191
+		else {
192
+			// update
193
+			$statement = $this->dbObject->prepare(<<<SQL
194 194
 UPDATE `emailtemplate`
195 195
 SET name = :name,
196 196
 	text = :text,
@@ -201,130 +201,130 @@  discard block
 block discarded – undo
201 201
 	updateversion = updateversion + 1
202 202
 WHERE id = :id AND updateversion = :updateversion;
203 203
 SQL
204
-            );
205
-            $statement->bindValue(':id', $this->id);
206
-            $statement->bindValue(':updateversion', $this->updateversion);
207
-
208
-            $statement->bindValue(':name', $this->name);
209
-            $statement->bindValue(":text", $this->text);
210
-            $statement->bindValue(":jsquestion", $this->jsquestion);
211
-            $statement->bindValue(":defaultaction", $this->defaultaction);
212
-            $statement->bindValue(":active", $this->active);
213
-            $statement->bindValue(":preloadonly", $this->preloadonly);
214
-
215
-            if (!$statement->execute()) {
216
-                throw new Exception($statement->errorInfo());
217
-            }
218
-
219
-            if ($statement->rowCount() !== 1) {
220
-                throw new OptimisticLockFailedException();
221
-            }
222
-
223
-            $this->updateversion++;
224
-        }
225
-    }
226
-
227
-    /**
228
-     * Override delete() from DataObject
229
-     */
230
-    public function delete()
231
-    {
232
-        throw new Exception("You shouldn't be doing that, you'll break logs.");
233
-    }
234
-
235
-    /**
236
-     * @return string
237
-     */
238
-    public function getName()
239
-    {
240
-        return $this->name;
241
-    }
242
-
243
-    /**
244
-     * @param string $name
245
-     */
246
-    public function setName($name)
247
-    {
248
-        $this->name = $name;
249
-    }
250
-
251
-    /**
252
-     * @return string
253
-     */
254
-    public function getText()
255
-    {
256
-        return $this->text;
257
-    }
258
-
259
-    /**
260
-     * @param string $text
261
-     */
262
-    public function setText($text)
263
-    {
264
-        $this->text = $text;
265
-    }
266
-
267
-    /**
268
-     * @return string|null
269
-     */
270
-    public function getJsquestion()
271
-    {
272
-        return $this->jsquestion;
273
-    }
274
-
275
-    /**
276
-     * @param string $jsquestion
277
-     */
278
-    public function setJsquestion($jsquestion)
279
-    {
280
-        $this->jsquestion = $jsquestion;
281
-    }
282
-
283
-    /**
284
-     * @return string
285
-     */
286
-    public function getDefaultAction()
287
-    {
288
-        return $this->defaultaction;
289
-    }
290
-
291
-    /**
292
-     * @param string $defaultAction
293
-     */
294
-    public function setDefaultAction($defaultAction)
295
-    {
296
-        $this->defaultaction = $defaultAction;
297
-    }
298
-
299
-    /**
300
-     * @return bool
301
-     */
302
-    public function getActive()
303
-    {
304
-        return $this->active == 1;
305
-    }
306
-
307
-    /**
308
-     * @param bool $active
309
-     */
310
-    public function setActive($active)
311
-    {
312
-        $this->active = $active ? 1 : 0;
313
-    }
314
-
315
-    /**
316
-     * @return bool
317
-     */
318
-    public function getPreloadOnly()
319
-    {
320
-        return $this->preloadonly == 1;
321
-    }
322
-
323
-    /**
324
-     * @param bool $preloadonly
325
-     */
326
-    public function setPreloadOnly($preloadonly)
327
-    {
328
-        $this->preloadonly = $preloadonly ? 1 : 0;
329
-    }
204
+			);
205
+			$statement->bindValue(':id', $this->id);
206
+			$statement->bindValue(':updateversion', $this->updateversion);
207
+
208
+			$statement->bindValue(':name', $this->name);
209
+			$statement->bindValue(":text", $this->text);
210
+			$statement->bindValue(":jsquestion", $this->jsquestion);
211
+			$statement->bindValue(":defaultaction", $this->defaultaction);
212
+			$statement->bindValue(":active", $this->active);
213
+			$statement->bindValue(":preloadonly", $this->preloadonly);
214
+
215
+			if (!$statement->execute()) {
216
+				throw new Exception($statement->errorInfo());
217
+			}
218
+
219
+			if ($statement->rowCount() !== 1) {
220
+				throw new OptimisticLockFailedException();
221
+			}
222
+
223
+			$this->updateversion++;
224
+		}
225
+	}
226
+
227
+	/**
228
+	 * Override delete() from DataObject
229
+	 */
230
+	public function delete()
231
+	{
232
+		throw new Exception("You shouldn't be doing that, you'll break logs.");
233
+	}
234
+
235
+	/**
236
+	 * @return string
237
+	 */
238
+	public function getName()
239
+	{
240
+		return $this->name;
241
+	}
242
+
243
+	/**
244
+	 * @param string $name
245
+	 */
246
+	public function setName($name)
247
+	{
248
+		$this->name = $name;
249
+	}
250
+
251
+	/**
252
+	 * @return string
253
+	 */
254
+	public function getText()
255
+	{
256
+		return $this->text;
257
+	}
258
+
259
+	/**
260
+	 * @param string $text
261
+	 */
262
+	public function setText($text)
263
+	{
264
+		$this->text = $text;
265
+	}
266
+
267
+	/**
268
+	 * @return string|null
269
+	 */
270
+	public function getJsquestion()
271
+	{
272
+		return $this->jsquestion;
273
+	}
274
+
275
+	/**
276
+	 * @param string $jsquestion
277
+	 */
278
+	public function setJsquestion($jsquestion)
279
+	{
280
+		$this->jsquestion = $jsquestion;
281
+	}
282
+
283
+	/**
284
+	 * @return string
285
+	 */
286
+	public function getDefaultAction()
287
+	{
288
+		return $this->defaultaction;
289
+	}
290
+
291
+	/**
292
+	 * @param string $defaultAction
293
+	 */
294
+	public function setDefaultAction($defaultAction)
295
+	{
296
+		$this->defaultaction = $defaultAction;
297
+	}
298
+
299
+	/**
300
+	 * @return bool
301
+	 */
302
+	public function getActive()
303
+	{
304
+		return $this->active == 1;
305
+	}
306
+
307
+	/**
308
+	 * @param bool $active
309
+	 */
310
+	public function setActive($active)
311
+	{
312
+		$this->active = $active ? 1 : 0;
313
+	}
314
+
315
+	/**
316
+	 * @return bool
317
+	 */
318
+	public function getPreloadOnly()
319
+	{
320
+		return $this->preloadonly == 1;
321
+	}
322
+
323
+	/**
324
+	 * @param bool $preloadonly
325
+	 */
326
+	public function setPreloadOnly($preloadonly)
327
+	{
328
+		$this->preloadonly = $preloadonly ? 1 : 0;
329
+	}
330 330
 }
Please login to merge, or discard this patch.
includes/DataObjects/OAuthToken.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -14,42 +14,42 @@  discard block
 block discarded – undo
14 14
 
15 15
 class OAuthToken extends DataObject
16 16
 {
17
-    /** @var int */
18
-    private $user;
19
-    /** @var string */
20
-    private $token;
21
-    /** @var string */
22
-    private $secret;
23
-    /** @var string */
24
-    private $type;
25
-    /** @var string */
26
-    private $expiry;
27
-
28
-    public function save()
29
-    {
30
-        if ($this->isNew()) {
31
-            // insert
32
-            $statement = $this->dbObject->prepare(<<<SQL
17
+	/** @var int */
18
+	private $user;
19
+	/** @var string */
20
+	private $token;
21
+	/** @var string */
22
+	private $secret;
23
+	/** @var string */
24
+	private $type;
25
+	/** @var string */
26
+	private $expiry;
27
+
28
+	public function save()
29
+	{
30
+		if ($this->isNew()) {
31
+			// insert
32
+			$statement = $this->dbObject->prepare(<<<SQL
33 33
                 INSERT INTO oauthtoken ( user, token, secret, type, expiry )
34 34
                 VALUES ( :user, :token, :secret, :type, :expiry );
35 35
 SQL
36
-            );
37
-            $statement->bindValue(":user", $this->user);
38
-            $statement->bindValue(":token", $this->token);
39
-            $statement->bindValue(":secret", $this->secret);
40
-            $statement->bindValue(":type", $this->type);
41
-            $statement->bindValue(":expiry", $this->expiry);
42
-
43
-            if ($statement->execute()) {
44
-                $this->id = (int)$this->dbObject->lastInsertId();
45
-            }
46
-            else {
47
-                throw new Exception($statement->errorInfo());
48
-            }
49
-        }
50
-        else {
51
-            // update
52
-            $statement = $this->dbObject->prepare(<<<SQL
36
+			);
37
+			$statement->bindValue(":user", $this->user);
38
+			$statement->bindValue(":token", $this->token);
39
+			$statement->bindValue(":secret", $this->secret);
40
+			$statement->bindValue(":type", $this->type);
41
+			$statement->bindValue(":expiry", $this->expiry);
42
+
43
+			if ($statement->execute()) {
44
+				$this->id = (int)$this->dbObject->lastInsertId();
45
+			}
46
+			else {
47
+				throw new Exception($statement->errorInfo());
48
+			}
49
+		}
50
+		else {
51
+			// update
52
+			$statement = $this->dbObject->prepare(<<<SQL
53 53
                 UPDATE oauthtoken
54 54
                 SET   token = :token
55 55
                     , secret = :secret
@@ -58,109 +58,109 @@  discard block
 block discarded – undo
58 58
                     , updateversion = updateversion + 1
59 59
                 WHERE id = :id AND updateversion = :updateversion;
60 60
 SQL
61
-            );
62
-
63
-            $statement->bindValue(':id', $this->id);
64
-            $statement->bindValue(':updateversion', $this->updateversion);
65
-
66
-            $statement->bindValue(":token", $this->token);
67
-            $statement->bindValue(":secret", $this->secret);
68
-            $statement->bindValue(":type", $this->type);
69
-            $statement->bindValue(":expiry", $this->expiry);
70
-
71
-            if (!$statement->execute()) {
72
-                throw new Exception($statement->errorInfo());
73
-            }
74
-
75
-            if ($statement->rowCount() !== 1) {
76
-                throw new OptimisticLockFailedException();
77
-            }
78
-
79
-            $this->updateversion++;
80
-        }
81
-    }
82
-
83
-    #region properties
84
-
85
-    /**
86
-     * @return mixed
87
-     */
88
-    public function getUserId()
89
-    {
90
-        return $this->user;
91
-    }
92
-
93
-    /**
94
-     * @param mixed $user
95
-     */
96
-    public function setUserId($user)
97
-    {
98
-        $this->user = $user;
99
-    }
100
-
101
-    /**
102
-     * @return mixed
103
-     */
104
-    public function getToken()
105
-    {
106
-        return $this->token;
107
-    }
108
-
109
-    /**
110
-     * @param mixed $token
111
-     */
112
-    public function setToken($token)
113
-    {
114
-        $this->token = $token;
115
-    }
116
-
117
-    /**
118
-     * @return mixed
119
-     */
120
-    public function getSecret()
121
-    {
122
-        return $this->secret;
123
-    }
124
-
125
-    /**
126
-     * @param mixed $secret
127
-     */
128
-    public function setSecret($secret)
129
-    {
130
-        $this->secret = $secret;
131
-    }
132
-
133
-    /**
134
-     * @return mixed
135
-     */
136
-    public function getType()
137
-    {
138
-        return $this->type;
139
-    }
140
-
141
-    /**
142
-     * @param mixed $type
143
-     */
144
-    public function setType($type)
145
-    {
146
-        $this->type = $type;
147
-    }
148
-
149
-    /**
150
-     * @return string
151
-     */
152
-    public function getExpiry()
153
-    {
154
-        return $this->expiry;
155
-    }
156
-
157
-    /**
158
-     * @param string $expiry
159
-     */
160
-    public function setExpiry($expiry)
161
-    {
162
-        $this->expiry = $expiry;
163
-    }
164
-    #endregion
61
+			);
62
+
63
+			$statement->bindValue(':id', $this->id);
64
+			$statement->bindValue(':updateversion', $this->updateversion);
65
+
66
+			$statement->bindValue(":token", $this->token);
67
+			$statement->bindValue(":secret", $this->secret);
68
+			$statement->bindValue(":type", $this->type);
69
+			$statement->bindValue(":expiry", $this->expiry);
70
+
71
+			if (!$statement->execute()) {
72
+				throw new Exception($statement->errorInfo());
73
+			}
74
+
75
+			if ($statement->rowCount() !== 1) {
76
+				throw new OptimisticLockFailedException();
77
+			}
78
+
79
+			$this->updateversion++;
80
+		}
81
+	}
82
+
83
+	#region properties
84
+
85
+	/**
86
+	 * @return mixed
87
+	 */
88
+	public function getUserId()
89
+	{
90
+		return $this->user;
91
+	}
92
+
93
+	/**
94
+	 * @param mixed $user
95
+	 */
96
+	public function setUserId($user)
97
+	{
98
+		$this->user = $user;
99
+	}
100
+
101
+	/**
102
+	 * @return mixed
103
+	 */
104
+	public function getToken()
105
+	{
106
+		return $this->token;
107
+	}
108
+
109
+	/**
110
+	 * @param mixed $token
111
+	 */
112
+	public function setToken($token)
113
+	{
114
+		$this->token = $token;
115
+	}
116
+
117
+	/**
118
+	 * @return mixed
119
+	 */
120
+	public function getSecret()
121
+	{
122
+		return $this->secret;
123
+	}
124
+
125
+	/**
126
+	 * @param mixed $secret
127
+	 */
128
+	public function setSecret($secret)
129
+	{
130
+		$this->secret = $secret;
131
+	}
132
+
133
+	/**
134
+	 * @return mixed
135
+	 */
136
+	public function getType()
137
+	{
138
+		return $this->type;
139
+	}
140
+
141
+	/**
142
+	 * @param mixed $type
143
+	 */
144
+	public function setType($type)
145
+	{
146
+		$this->type = $type;
147
+	}
148
+
149
+	/**
150
+	 * @return string
151
+	 */
152
+	public function getExpiry()
153
+	{
154
+		return $this->expiry;
155
+	}
156
+
157
+	/**
158
+	 * @param string $expiry
159
+	 */
160
+	public function setExpiry($expiry)
161
+	{
162
+		$this->expiry = $expiry;
163
+	}
164
+	#endregion
165 165
 
166 166
 }
167 167
\ No newline at end of file
Please login to merge, or discard this patch.
includes/DataObjects/CommunityUser.php 1 patch
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -16,167 +16,167 @@
 block discarded – undo
16 16
  */
17 17
 class CommunityUser extends User
18 18
 {
19
-    public function getId()
20
-    {
21
-        return -1;
22
-    }
23
-
24
-    public function save()
25
-    {
26
-        // Do nothing
27
-    }
28
-
29
-    #region properties
30
-
31
-    /**
32
-     * @return string
33
-     */
34
-    public function getUsername()
35
-    {
36
-        global $communityUsername;
37
-
38
-        return $communityUsername;
39
-    }
40
-
41
-    public function setUsername($username)
42
-    {
43
-    }
44
-
45
-    /**
46
-     * @return string
47
-     */
48
-    public function getEmail()
49
-    {
50
-        global $cDataClearEmail;
51
-
52
-        return $cDataClearEmail;
53
-    }
54
-
55
-    public function setEmail($email)
56
-    {
57
-    }
58
-
59
-    public function getStatus()
60
-    {
61
-        return "Community";
62
-    }
63
-
64
-    public function getOnWikiName()
65
-    {
66
-        return "127.0.0.1";
67
-    }
68
-
69
-    public function setOnWikiName($onWikiName)
70
-    {
71
-    }
72
-
73
-    public function getWelcomeSig()
74
-    {
75
-        return null;
76
-    }
77
-
78
-    public function setWelcomeSig($welcomeSig)
79
-    {
80
-    }
81
-
82
-    public function getLastActive()
83
-    {
84
-        $now = new DateTime();
85
-
86
-        return $now->format("Y-m-d H:i:s");
87
-    }
88
-
89
-    public function getForceLogout()
90
-    {
91
-        return true;
92
-    }
93
-
94
-    public function setForceLogout($forceLogout)
95
-    {
96
-    }
97
-
98
-    /**
99
-     * @param string $status
100
-     */
101
-    public function setStatus($status)
102
-    {
103
-    }
104
-
105
-    public function getWelcomeTemplate()
106
-    {
107
-        return 0;
108
-    }
109
-
110
-    public function setWelcomeTemplate($welcomeTemplate)
111
-    {
112
-    }
113
-
114
-    public function getAbortPref()
115
-    {
116
-        return 0;
117
-    }
118
-
119
-    public function setAbortPref($abortPreference)
120
-    {
121
-    }
122
-
123
-    public function getConfirmationDiff()
124
-    {
125
-        return null;
126
-    }
127
-
128
-    public function setConfirmationDiff($confirmationDiff)
129
-    {
130
-    }
131
-
132
-    public function getEmailSig()
133
-    {
134
-        return null;
135
-    }
136
-
137
-    public function setEmailSig($emailSignature)
138
-    {
139
-    }
140
-
141
-    public function setUseAlternateSkin($useAlternate)
142
-    {
143
-    }
144
-
145
-    #endregion
146
-
147
-    #region user access checks
148
-
149
-    public function isIdentified(IdentificationVerifier $iv)
150
-    {
151
-        return false;
152
-    }
153
-
154
-    public function isSuspended()
155
-    {
156
-        return false;
157
-    }
158
-
159
-    public function isNewUser()
160
-    {
161
-        return false;
162
-    }
163
-
164
-    public function isDeclined()
165
-    {
166
-        return false;
167
-    }
168
-
169
-    public function isCommunityUser()
170
-    {
171
-        return true;
172
-    }
173
-
174
-    #endregion
175
-
176
-    public function getApprovalDate()
177
-    {
178
-        $data = DateTime::createFromFormat("Y-m-d H:i:s", "1970-01-01 00:00:00");
179
-
180
-        return $data;
181
-    }
19
+	public function getId()
20
+	{
21
+		return -1;
22
+	}
23
+
24
+	public function save()
25
+	{
26
+		// Do nothing
27
+	}
28
+
29
+	#region properties
30
+
31
+	/**
32
+	 * @return string
33
+	 */
34
+	public function getUsername()
35
+	{
36
+		global $communityUsername;
37
+
38
+		return $communityUsername;
39
+	}
40
+
41
+	public function setUsername($username)
42
+	{
43
+	}
44
+
45
+	/**
46
+	 * @return string
47
+	 */
48
+	public function getEmail()
49
+	{
50
+		global $cDataClearEmail;
51
+
52
+		return $cDataClearEmail;
53
+	}
54
+
55
+	public function setEmail($email)
56
+	{
57
+	}
58
+
59
+	public function getStatus()
60
+	{
61
+		return "Community";
62
+	}
63
+
64
+	public function getOnWikiName()
65
+	{
66
+		return "127.0.0.1";
67
+	}
68
+
69
+	public function setOnWikiName($onWikiName)
70
+	{
71
+	}
72
+
73
+	public function getWelcomeSig()
74
+	{
75
+		return null;
76
+	}
77
+
78
+	public function setWelcomeSig($welcomeSig)
79
+	{
80
+	}
81
+
82
+	public function getLastActive()
83
+	{
84
+		$now = new DateTime();
85
+
86
+		return $now->format("Y-m-d H:i:s");
87
+	}
88
+
89
+	public function getForceLogout()
90
+	{
91
+		return true;
92
+	}
93
+
94
+	public function setForceLogout($forceLogout)
95
+	{
96
+	}
97
+
98
+	/**
99
+	 * @param string $status
100
+	 */
101
+	public function setStatus($status)
102
+	{
103
+	}
104
+
105
+	public function getWelcomeTemplate()
106
+	{
107
+		return 0;
108
+	}
109
+
110
+	public function setWelcomeTemplate($welcomeTemplate)
111
+	{
112
+	}
113
+
114
+	public function getAbortPref()
115
+	{
116
+		return 0;
117
+	}
118
+
119
+	public function setAbortPref($abortPreference)
120
+	{
121
+	}
122
+
123
+	public function getConfirmationDiff()
124
+	{
125
+		return null;
126
+	}
127
+
128
+	public function setConfirmationDiff($confirmationDiff)
129
+	{
130
+	}
131
+
132
+	public function getEmailSig()
133
+	{
134
+		return null;
135
+	}
136
+
137
+	public function setEmailSig($emailSignature)
138
+	{
139
+	}
140
+
141
+	public function setUseAlternateSkin($useAlternate)
142
+	{
143
+	}
144
+
145
+	#endregion
146
+
147
+	#region user access checks
148
+
149
+	public function isIdentified(IdentificationVerifier $iv)
150
+	{
151
+		return false;
152
+	}
153
+
154
+	public function isSuspended()
155
+	{
156
+		return false;
157
+	}
158
+
159
+	public function isNewUser()
160
+	{
161
+		return false;
162
+	}
163
+
164
+	public function isDeclined()
165
+	{
166
+		return false;
167
+	}
168
+
169
+	public function isCommunityUser()
170
+	{
171
+		return true;
172
+	}
173
+
174
+	#endregion
175
+
176
+	public function getApprovalDate()
177
+	{
178
+		$data = DateTime::createFromFormat("Y-m-d H:i:s", "1970-01-01 00:00:00");
179
+
180
+		return $data;
181
+	}
182 182
 }
Please login to merge, or discard this patch.
includes/DataObjects/Ban.php 1 patch
Indentation   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -19,274 +19,274 @@
 block discarded – undo
19 19
  */
20 20
 class Ban extends DataObject
21 21
 {
22
-    private $type;
23
-    private $target;
24
-    private $user;
25
-    private $reason;
26
-    private $date;
27
-    private $duration;
28
-    private $active;
29
-
30
-    /**
31
-     * Gets all active bans, filtered by the optional target.
32
-     *
33
-     * @param string|null $target
34
-     * @param PdoDatabase $database
35
-     *
36
-     * @return Ban[]
37
-     */
38
-    public static function getActiveBans($target, PdoDatabase $database)
39
-    {
40
-        if ($target !== null) {
41
-            $query = <<<SQL
22
+	private $type;
23
+	private $target;
24
+	private $user;
25
+	private $reason;
26
+	private $date;
27
+	private $duration;
28
+	private $active;
29
+
30
+	/**
31
+	 * Gets all active bans, filtered by the optional target.
32
+	 *
33
+	 * @param string|null $target
34
+	 * @param PdoDatabase $database
35
+	 *
36
+	 * @return Ban[]
37
+	 */
38
+	public static function getActiveBans($target, PdoDatabase $database)
39
+	{
40
+		if ($target !== null) {
41
+			$query = <<<SQL
42 42
 SELECT * FROM ban 
43 43
 WHERE target = :target 
44 44
   AND (duration > UNIX_TIMESTAMP() OR duration is null) 
45 45
   AND active = 1;
46 46
 SQL;
47
-            $statement = $database->prepare($query);
48
-            $statement->bindValue(":target", $target);
49
-        }
50
-        else {
51
-            $query = <<<SQL
47
+			$statement = $database->prepare($query);
48
+			$statement->bindValue(":target", $target);
49
+		}
50
+		else {
51
+			$query = <<<SQL
52 52
 SELECT * FROM ban 
53 53
 WHERE (duration > UNIX_TIMESTAMP() OR duration is null) 
54 54
   AND active = 1;
55 55
 SQL;
56
-            $statement = $database->prepare($query);
57
-        }
58
-
59
-        $statement->execute();
60
-
61
-        $result = array();
62
-
63
-        /** @var Ban $v */
64
-        foreach ($statement->fetchAll(PDO::FETCH_CLASS, get_called_class()) as $v) {
65
-            $v->setDatabase($database);
66
-            $result[] = $v;
67
-        }
68
-
69
-        return $result;
70
-    }
71
-
72
-    /**
73
-     * Gets a ban by it's ID if it's currently active.
74
-     *
75
-     * @param     integer $id
76
-     * @param PdoDatabase $database
77
-     *
78
-     * @return Ban
79
-     */
80
-    public static function getActiveId($id, PdoDatabase $database)
81
-    {
82
-        $statement = $database->prepare(<<<SQL
56
+			$statement = $database->prepare($query);
57
+		}
58
+
59
+		$statement->execute();
60
+
61
+		$result = array();
62
+
63
+		/** @var Ban $v */
64
+		foreach ($statement->fetchAll(PDO::FETCH_CLASS, get_called_class()) as $v) {
65
+			$v->setDatabase($database);
66
+			$result[] = $v;
67
+		}
68
+
69
+		return $result;
70
+	}
71
+
72
+	/**
73
+	 * Gets a ban by it's ID if it's currently active.
74
+	 *
75
+	 * @param     integer $id
76
+	 * @param PdoDatabase $database
77
+	 *
78
+	 * @return Ban
79
+	 */
80
+	public static function getActiveId($id, PdoDatabase $database)
81
+	{
82
+		$statement = $database->prepare(<<<SQL
83 83
 SELECT *
84 84
 FROM ban
85 85
 WHERE id = :id  AND (duration > UNIX_TIMESTAMP() OR duration is null) AND active = 1;
86 86
 SQL
87
-        );
88
-        $statement->bindValue(":id", $id);
89
-
90
-        $statement->execute();
91
-
92
-        $resultObject = $statement->fetchObject(get_called_class());
93
-
94
-        if ($resultObject != false) {
95
-            $resultObject->setDatabase($database);
96
-        }
97
-
98
-        return $resultObject;
99
-    }
100
-
101
-    /**
102
-     * Get all active bans for a target and type.
103
-     *
104
-     * @param string      $target
105
-     * @param string      $type
106
-     * @param PdoDatabase $database
107
-     *
108
-     * @return Ban
109
-     */
110
-    public static function getBanByTarget($target, $type, PdoDatabase $database)
111
-    {
112
-        $query = <<<SQL
87
+		);
88
+		$statement->bindValue(":id", $id);
89
+
90
+		$statement->execute();
91
+
92
+		$resultObject = $statement->fetchObject(get_called_class());
93
+
94
+		if ($resultObject != false) {
95
+			$resultObject->setDatabase($database);
96
+		}
97
+
98
+		return $resultObject;
99
+	}
100
+
101
+	/**
102
+	 * Get all active bans for a target and type.
103
+	 *
104
+	 * @param string      $target
105
+	 * @param string      $type
106
+	 * @param PdoDatabase $database
107
+	 *
108
+	 * @return Ban
109
+	 */
110
+	public static function getBanByTarget($target, $type, PdoDatabase $database)
111
+	{
112
+		$query = <<<SQL
113 113
 SELECT * FROM ban
114 114
 WHERE type = :type
115 115
 	AND target = :target
116 116
 	AND (duration > UNIX_TIMESTAMP() OR duration is null)
117 117
 	AND active = 1;
118 118
 SQL;
119
-        $statement = $database->prepare($query);
120
-        $statement->bindValue(":target", $target);
121
-        $statement->bindValue(":type", $type);
119
+		$statement = $database->prepare($query);
120
+		$statement->bindValue(":target", $target);
121
+		$statement->bindValue(":type", $type);
122 122
 
123
-        $statement->execute();
123
+		$statement->execute();
124 124
 
125
-        $resultObject = $statement->fetchObject(get_called_class());
125
+		$resultObject = $statement->fetchObject(get_called_class());
126 126
 
127
-        if ($resultObject != false) {
128
-            $resultObject->setDatabase($database);
129
-        }
127
+		if ($resultObject != false) {
128
+			$resultObject->setDatabase($database);
129
+		}
130 130
 
131
-        return $resultObject;
132
-    }
131
+		return $resultObject;
132
+	}
133 133
 
134
-    /**
135
-     * @throws Exception
136
-     */
137
-    public function save()
138
-    {
139
-        if ($this->isNew()) {
140
-            // insert
141
-            $statement = $this->dbObject->prepare(<<<SQL
134
+	/**
135
+	 * @throws Exception
136
+	 */
137
+	public function save()
138
+	{
139
+		if ($this->isNew()) {
140
+			// insert
141
+			$statement = $this->dbObject->prepare(<<<SQL
142 142
 INSERT INTO `ban` (type, target, user, reason, date, duration, active)
143 143
 VALUES (:type, :target, :user, :reason, CURRENT_TIMESTAMP(), :duration, :active);
144 144
 SQL
145
-            );
146
-            $statement->bindValue(":type", $this->type);
147
-            $statement->bindValue(":target", $this->target);
148
-            $statement->bindValue(":user", $this->user);
149
-            $statement->bindValue(":reason", $this->reason);
150
-            $statement->bindValue(":duration", $this->duration);
151
-            $statement->bindValue(":active", $this->active);
152
-
153
-            if ($statement->execute()) {
154
-                $this->id = (int)$this->dbObject->lastInsertId();
155
-            }
156
-            else {
157
-                throw new Exception($statement->errorInfo());
158
-            }
159
-        }
160
-        else {
161
-            // update
162
-            $statement = $this->dbObject->prepare(<<<SQL
145
+			);
146
+			$statement->bindValue(":type", $this->type);
147
+			$statement->bindValue(":target", $this->target);
148
+			$statement->bindValue(":user", $this->user);
149
+			$statement->bindValue(":reason", $this->reason);
150
+			$statement->bindValue(":duration", $this->duration);
151
+			$statement->bindValue(":active", $this->active);
152
+
153
+			if ($statement->execute()) {
154
+				$this->id = (int)$this->dbObject->lastInsertId();
155
+			}
156
+			else {
157
+				throw new Exception($statement->errorInfo());
158
+			}
159
+		}
160
+		else {
161
+			// update
162
+			$statement = $this->dbObject->prepare(<<<SQL
163 163
 UPDATE `ban`
164 164
 SET duration = :duration, active = :active, user = :user, updateversion = updateversion + 1
165 165
 WHERE id = :id AND updateversion = :updateversion;
166 166
 SQL
167
-            );
168
-            $statement->bindValue(':id', $this->id);
169
-            $statement->bindValue(':updateversion', $this->updateversion);
170
-
171
-            $statement->bindValue(':duration', $this->duration);
172
-            $statement->bindValue(':active', $this->active);
173
-            $statement->bindValue(':user', $this->user);
174
-
175
-            if (!$statement->execute()) {
176
-                throw new Exception($statement->errorInfo());
177
-            }
178
-
179
-            if ($statement->rowCount() !== 1) {
180
-                throw new OptimisticLockFailedException();
181
-            }
182
-
183
-            $this->updateversion++;
184
-        }
185
-    }
186
-
187
-    /**
188
-     * @return string
189
-     */
190
-    public function getType()
191
-    {
192
-        return $this->type;
193
-    }
194
-
195
-    /**
196
-     * @param string $type
197
-     */
198
-    public function setType($type)
199
-    {
200
-        $this->type = $type;
201
-    }
202
-
203
-    /**
204
-     * @return string
205
-     */
206
-    public function getTarget()
207
-    {
208
-        return $this->target;
209
-    }
210
-
211
-    /**
212
-     * @param string $target
213
-     */
214
-    public function setTarget($target)
215
-    {
216
-        $this->target = $target;
217
-    }
218
-
219
-    /**
220
-     * @return string
221
-     */
222
-    public function getReason()
223
-    {
224
-        return $this->reason;
225
-    }
226
-
227
-    /**
228
-     * @param string $reason
229
-     */
230
-    public function setReason($reason)
231
-    {
232
-        $this->reason = $reason;
233
-    }
234
-
235
-    /**
236
-     * @return mixed
237
-     */
238
-    public function getDate()
239
-    {
240
-        return $this->date;
241
-    }
242
-
243
-    /**
244
-     * @return mixed
245
-     */
246
-    public function getDuration()
247
-    {
248
-        return $this->duration;
249
-    }
250
-
251
-    /**
252
-     * @param mixed $duration
253
-     */
254
-    public function setDuration($duration)
255
-    {
256
-        $this->duration = $duration;
257
-    }
258
-
259
-    /**
260
-     * @return bool
261
-     */
262
-    public function isActive()
263
-    {
264
-        return $this->active == 1;
265
-    }
266
-
267
-    /**
268
-     * @param bool $active
269
-     */
270
-    public function setActive($active)
271
-    {
272
-        $this->active = $active ? 1 : 0;
273
-    }
274
-
275
-    /**
276
-     * @return int
277
-     */
278
-    public function getUser()
279
-    {
280
-        return $this->user;
281
-    }
282
-
283
-    /**
284
-     * @param int $user UserID of user who is setting the ban
285
-     *
286
-     * @throws Exception
287
-     */
288
-    public function setUser($user)
289
-    {
290
-        $this->user = $user;
291
-    }
167
+			);
168
+			$statement->bindValue(':id', $this->id);
169
+			$statement->bindValue(':updateversion', $this->updateversion);
170
+
171
+			$statement->bindValue(':duration', $this->duration);
172
+			$statement->bindValue(':active', $this->active);
173
+			$statement->bindValue(':user', $this->user);
174
+
175
+			if (!$statement->execute()) {
176
+				throw new Exception($statement->errorInfo());
177
+			}
178
+
179
+			if ($statement->rowCount() !== 1) {
180
+				throw new OptimisticLockFailedException();
181
+			}
182
+
183
+			$this->updateversion++;
184
+		}
185
+	}
186
+
187
+	/**
188
+	 * @return string
189
+	 */
190
+	public function getType()
191
+	{
192
+		return $this->type;
193
+	}
194
+
195
+	/**
196
+	 * @param string $type
197
+	 */
198
+	public function setType($type)
199
+	{
200
+		$this->type = $type;
201
+	}
202
+
203
+	/**
204
+	 * @return string
205
+	 */
206
+	public function getTarget()
207
+	{
208
+		return $this->target;
209
+	}
210
+
211
+	/**
212
+	 * @param string $target
213
+	 */
214
+	public function setTarget($target)
215
+	{
216
+		$this->target = $target;
217
+	}
218
+
219
+	/**
220
+	 * @return string
221
+	 */
222
+	public function getReason()
223
+	{
224
+		return $this->reason;
225
+	}
226
+
227
+	/**
228
+	 * @param string $reason
229
+	 */
230
+	public function setReason($reason)
231
+	{
232
+		$this->reason = $reason;
233
+	}
234
+
235
+	/**
236
+	 * @return mixed
237
+	 */
238
+	public function getDate()
239
+	{
240
+		return $this->date;
241
+	}
242
+
243
+	/**
244
+	 * @return mixed
245
+	 */
246
+	public function getDuration()
247
+	{
248
+		return $this->duration;
249
+	}
250
+
251
+	/**
252
+	 * @param mixed $duration
253
+	 */
254
+	public function setDuration($duration)
255
+	{
256
+		$this->duration = $duration;
257
+	}
258
+
259
+	/**
260
+	 * @return bool
261
+	 */
262
+	public function isActive()
263
+	{
264
+		return $this->active == 1;
265
+	}
266
+
267
+	/**
268
+	 * @param bool $active
269
+	 */
270
+	public function setActive($active)
271
+	{
272
+		$this->active = $active ? 1 : 0;
273
+	}
274
+
275
+	/**
276
+	 * @return int
277
+	 */
278
+	public function getUser()
279
+	{
280
+		return $this->user;
281
+	}
282
+
283
+	/**
284
+	 * @param int $user UserID of user who is setting the ban
285
+	 *
286
+	 * @throws Exception
287
+	 */
288
+	public function setUser($user)
289
+	{
290
+		$this->user = $user;
291
+	}
292 292
 }
Please login to merge, or discard this patch.
includes/Validation/ValidationError.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -12,98 +12,98 @@
 block discarded – undo
12 12
 
13 13
 class ValidationError
14 14
 {
15
-    const NAME_EMPTY = "name_empty";
16
-    const NAME_EXISTS = "name_exists";
17
-    const NAME_EXISTS_SUL = "name_exists_sul";
18
-    const NAME_NUMONLY = "name_numonly";
19
-    const NAME_INVALIDCHAR = "name_invalidchar";
20
-    const NAME_SANITISED = "name_sanitised";
21
-    const EMAIL_EMPTY = "email_empty";
22
-    const EMAIL_WIKIMEDIA = "email_wikimedia";
23
-    const EMAIL_INVALID = "email_invalid";
24
-    const EMAIL_MISMATCH = "email_mismatch";
25
-    const OPEN_REQUEST_NAME = "open_request_name";
26
-    const BANNED = "banned";
27
-    const BANNED_TOR = "banned_tor";
28
-    /**
29
-     * @var array Error text for the above
30
-     */
31
-    private static $errorText = array(
32
-        self::NAME_EMPTY        => 'You\'ve not chosen a username!',
33
-        self::NAME_EXISTS       => 'I\'m sorry, but the username you selected is already taken. Please try another. '
34
-            . 'Please note that Wikipedia automatically capitalizes the first letter of any user name, therefore '
35
-            . '[[User:example]] would become [[User:Example]].',
36
-        self::NAME_EXISTS_SUL   => 'I\'m sorry, but the username you selected is already taken. Please try another. '
37
-            . 'Please note that Wikipedia automatically capitalizes the first letter of any user name, therefore '
38
-            . '[[User:example]] would become [[User:Example]].',
39
-        self::NAME_NUMONLY      => 'The username you chose is invalid: it consists entirely of numbers. Please retry '
40
-            . 'with a valid username.',
41
-        self::NAME_INVALIDCHAR  => 'There appears to be an invalid character in your username. Please note that the '
42
-            . 'following characters are not allowed: <code># @ / &lt; &gt; [ ] | { }</code>',
43
-        self::NAME_SANITISED    => 'Your requested username has been automatically adjusted due to technical '
44
-            . 'restrictions. Underscores have been replaced with spaces, and the first character has been capitalised.',
45
-        self::EMAIL_EMPTY       => 'You need to supply an email address.',
46
-        self::EMAIL_WIKIMEDIA   => 'Please provide your email address here.',
47
-        self::EMAIL_INVALID     => 'Invalid E-mail address supplied. Please check you entered it correctly.',
48
-        self::EMAIL_MISMATCH    => 'The email addresses you entered do not match. Please try again.',
49
-        self::OPEN_REQUEST_NAME => 'There is already an open request with this name in this system.',
50
-        self::BANNED            => 'Sorry, you are currently banned from requesting accounts using this tool.',
51
-        self::BANNED_TOR        => 'Tor exit nodes are currently banned from using this tool due to excessive abuse. '
52
-            . 'Please note that Tor is also currently banned from editing Wikipedia.',
53
-    );
54
-    /**
55
-     * Summary of $errorCode
56
-     * @var string
57
-     */
58
-    private $errorCode;
59
-    /**
60
-     * Summary of $isError
61
-     * @var bool
62
-     */
63
-    private $isError;
15
+	const NAME_EMPTY = "name_empty";
16
+	const NAME_EXISTS = "name_exists";
17
+	const NAME_EXISTS_SUL = "name_exists_sul";
18
+	const NAME_NUMONLY = "name_numonly";
19
+	const NAME_INVALIDCHAR = "name_invalidchar";
20
+	const NAME_SANITISED = "name_sanitised";
21
+	const EMAIL_EMPTY = "email_empty";
22
+	const EMAIL_WIKIMEDIA = "email_wikimedia";
23
+	const EMAIL_INVALID = "email_invalid";
24
+	const EMAIL_MISMATCH = "email_mismatch";
25
+	const OPEN_REQUEST_NAME = "open_request_name";
26
+	const BANNED = "banned";
27
+	const BANNED_TOR = "banned_tor";
28
+	/**
29
+	 * @var array Error text for the above
30
+	 */
31
+	private static $errorText = array(
32
+		self::NAME_EMPTY        => 'You\'ve not chosen a username!',
33
+		self::NAME_EXISTS       => 'I\'m sorry, but the username you selected is already taken. Please try another. '
34
+			. 'Please note that Wikipedia automatically capitalizes the first letter of any user name, therefore '
35
+			. '[[User:example]] would become [[User:Example]].',
36
+		self::NAME_EXISTS_SUL   => 'I\'m sorry, but the username you selected is already taken. Please try another. '
37
+			. 'Please note that Wikipedia automatically capitalizes the first letter of any user name, therefore '
38
+			. '[[User:example]] would become [[User:Example]].',
39
+		self::NAME_NUMONLY      => 'The username you chose is invalid: it consists entirely of numbers. Please retry '
40
+			. 'with a valid username.',
41
+		self::NAME_INVALIDCHAR  => 'There appears to be an invalid character in your username. Please note that the '
42
+			. 'following characters are not allowed: <code># @ / &lt; &gt; [ ] | { }</code>',
43
+		self::NAME_SANITISED    => 'Your requested username has been automatically adjusted due to technical '
44
+			. 'restrictions. Underscores have been replaced with spaces, and the first character has been capitalised.',
45
+		self::EMAIL_EMPTY       => 'You need to supply an email address.',
46
+		self::EMAIL_WIKIMEDIA   => 'Please provide your email address here.',
47
+		self::EMAIL_INVALID     => 'Invalid E-mail address supplied. Please check you entered it correctly.',
48
+		self::EMAIL_MISMATCH    => 'The email addresses you entered do not match. Please try again.',
49
+		self::OPEN_REQUEST_NAME => 'There is already an open request with this name in this system.',
50
+		self::BANNED            => 'Sorry, you are currently banned from requesting accounts using this tool.',
51
+		self::BANNED_TOR        => 'Tor exit nodes are currently banned from using this tool due to excessive abuse. '
52
+			. 'Please note that Tor is also currently banned from editing Wikipedia.',
53
+	);
54
+	/**
55
+	 * Summary of $errorCode
56
+	 * @var string
57
+	 */
58
+	private $errorCode;
59
+	/**
60
+	 * Summary of $isError
61
+	 * @var bool
62
+	 */
63
+	private $isError;
64 64
 
65
-    /**
66
-     * Summary of __construct
67
-     *
68
-     * @param string $errorCode
69
-     * @param bool   $isError
70
-     */
71
-    public function __construct($errorCode, $isError = true)
72
-    {
73
-        $this->errorCode = $errorCode;
74
-        $this->isError = $isError;
75
-    }
65
+	/**
66
+	 * Summary of __construct
67
+	 *
68
+	 * @param string $errorCode
69
+	 * @param bool   $isError
70
+	 */
71
+	public function __construct($errorCode, $isError = true)
72
+	{
73
+		$this->errorCode = $errorCode;
74
+		$this->isError = $isError;
75
+	}
76 76
 
77
-    /**
78
-     * Summary of getErrorCode
79
-     * @return string
80
-     */
81
-    public function getErrorCode()
82
-    {
83
-        return $this->errorCode;
84
-    }
77
+	/**
78
+	 * Summary of getErrorCode
79
+	 * @return string
80
+	 */
81
+	public function getErrorCode()
82
+	{
83
+		return $this->errorCode;
84
+	}
85 85
 
86
-    /**
87
-     * @return string
88
-     * @throws Exception
89
-     */
90
-    public function getErrorMessage()
91
-    {
92
-        $text = self::$errorText[$this->errorCode];
86
+	/**
87
+	 * @return string
88
+	 * @throws Exception
89
+	 */
90
+	public function getErrorMessage()
91
+	{
92
+		$text = self::$errorText[$this->errorCode];
93 93
 
94
-        if ($text == null) {
95
-            throw new Exception('Unknown validation error');
96
-        }
94
+		if ($text == null) {
95
+			throw new Exception('Unknown validation error');
96
+		}
97 97
 
98
-        return $text;
99
-    }
98
+		return $text;
99
+	}
100 100
 
101
-    /**
102
-     * Summary of isError
103
-     * @return bool
104
-     */
105
-    public function isError()
106
-    {
107
-        return $this->isError;
108
-    }
101
+	/**
102
+	 * Summary of isError
103
+	 * @return bool
104
+	 */
105
+	public function isError()
106
+	{
107
+		return $this->isError;
108
+	}
109 109
 }
Please login to merge, or discard this patch.
includes/Background/Task/WelcomeUserTask.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -20,73 +20,73 @@
 block discarded – undo
20 20
 
21 21
 class WelcomeUserTask extends BackgroundTaskBase
22 22
 {
23
-    public static function enqueue(User $triggerUser, Request $request, PdoDatabase $database)
24
-    {
25
-        $job = new JobQueue();
26
-        $job->setDatabase($database);
27
-        $job->setTask(WelcomeUserTask::class);
28
-        $job->setRequest($request->getId());
29
-        $job->setTriggerUserId($triggerUser->getId());
30
-        $job->save();
31
-    }
32
-
33
-    public function execute()
34
-    {
35
-        $database = $this->getDatabase();
36
-        $request = $this->getRequest();
37
-        $user = $this->getTriggerUser();
38
-
39
-        if ($user->getWelcomeTemplate() === null) {
40
-            $this->markFailed('Welcome template not specified');
41
-
42
-            return;
43
-        }
44
-
45
-        /** @var WelcomeTemplate $template */
46
-        $template = WelcomeTemplate::getById($user->getWelcomeTemplate(), $database);
47
-
48
-        if ($template === false) {
49
-            $this->markFailed('Welcome template missing');
50
-
51
-            return;
52
-        }
53
-
54
-        $oauth = new OAuthUserHelper($user, $database, $this->getOauthProtocolHelper(),
55
-            $this->getSiteConfiguration());
56
-        $mediaWikiHelper = new MediaWikiHelper($oauth, $this->getSiteConfiguration());
57
-
58
-        if ($request->getStatus() !== RequestStatus::CLOSED) {
59
-            $this->markFailed('Request is currently open');
60
-
61
-            return;
62
-        }
63
-
64
-        if (!$mediaWikiHelper->checkAccountExists($request->getName())){
65
-            $this->markFailed('Account does not exist!');
66
-
67
-            return;
68
-        }
69
-
70
-        $this->performWelcome($template, $request, $mediaWikiHelper);
71
-        $this->markComplete();
72
-    }
73
-
74
-    /**
75
-     * Performs the welcome
76
-     *
77
-     * @param WelcomeTemplate $template
78
-     * @param Request         $request
79
-     * @param MediaWikiHelper $mediaWikiHelper
80
-     */
81
-    private function performWelcome(
82
-        WelcomeTemplate $template,
83
-        Request $request,
84
-        MediaWikiHelper $mediaWikiHelper
85
-    ) {
86
-        $templateText = $template->getBotCode();
87
-        $templateText = str_replace('$signature', '~~~~', $templateText);
88
-        $templateText = str_replace('$username', $request->getName(), $templateText);
89
-
90
-        $mediaWikiHelper->addTalkPageMessage($request->getName(), 'Welcome!', 'Welcoming user created through [[WP:ACC]]', $templateText);
91
-    }
23
+	public static function enqueue(User $triggerUser, Request $request, PdoDatabase $database)
24
+	{
25
+		$job = new JobQueue();
26
+		$job->setDatabase($database);
27
+		$job->setTask(WelcomeUserTask::class);
28
+		$job->setRequest($request->getId());
29
+		$job->setTriggerUserId($triggerUser->getId());
30
+		$job->save();
31
+	}
32
+
33
+	public function execute()
34
+	{
35
+		$database = $this->getDatabase();
36
+		$request = $this->getRequest();
37
+		$user = $this->getTriggerUser();
38
+
39
+		if ($user->getWelcomeTemplate() === null) {
40
+			$this->markFailed('Welcome template not specified');
41
+
42
+			return;
43
+		}
44
+
45
+		/** @var WelcomeTemplate $template */
46
+		$template = WelcomeTemplate::getById($user->getWelcomeTemplate(), $database);
47
+
48
+		if ($template === false) {
49
+			$this->markFailed('Welcome template missing');
50
+
51
+			return;
52
+		}
53
+
54
+		$oauth = new OAuthUserHelper($user, $database, $this->getOauthProtocolHelper(),
55
+			$this->getSiteConfiguration());
56
+		$mediaWikiHelper = new MediaWikiHelper($oauth, $this->getSiteConfiguration());
57
+
58
+		if ($request->getStatus() !== RequestStatus::CLOSED) {
59
+			$this->markFailed('Request is currently open');
60
+
61
+			return;
62
+		}
63
+
64
+		if (!$mediaWikiHelper->checkAccountExists($request->getName())){
65
+			$this->markFailed('Account does not exist!');
66
+
67
+			return;
68
+		}
69
+
70
+		$this->performWelcome($template, $request, $mediaWikiHelper);
71
+		$this->markComplete();
72
+	}
73
+
74
+	/**
75
+	 * Performs the welcome
76
+	 *
77
+	 * @param WelcomeTemplate $template
78
+	 * @param Request         $request
79
+	 * @param MediaWikiHelper $mediaWikiHelper
80
+	 */
81
+	private function performWelcome(
82
+		WelcomeTemplate $template,
83
+		Request $request,
84
+		MediaWikiHelper $mediaWikiHelper
85
+	) {
86
+		$templateText = $template->getBotCode();
87
+		$templateText = str_replace('$signature', '~~~~', $templateText);
88
+		$templateText = str_replace('$username', $request->getName(), $templateText);
89
+
90
+		$mediaWikiHelper->addTalkPageMessage($request->getName(), 'Welcome!', 'Welcoming user created through [[WP:ACC]]', $templateText);
91
+	}
92 92
 }
93 93
\ No newline at end of file
Please login to merge, or discard this patch.