Failed Conditions
Pull Request — newinternal-bugfixing (#286)
by Simon
06:57 queued 03:32
created
includes/DataObjects/RDnsCache.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -19,110 +19,110 @@
 block discarded – undo
19 19
  */
20 20
 class RDnsCache extends DataObject
21 21
 {
22
-    private $address;
23
-    private $data;
24
-    private $creation;
25
-
26
-    /**
27
-     * @param string      $address
28
-     * @param PdoDatabase $database
29
-     *
30
-     * @return RDnsCache|false
31
-     */
32
-    public static function getByAddress($address, PdoDatabase $database)
33
-    {
34
-        // @todo add cache invalidation (timestamp?)
35
-        $statement = $database->prepare("SELECT * FROM rdnscache WHERE address = :id LIMIT 1;");
36
-        $statement->bindValue(":id", $address);
37
-
38
-        $statement->execute();
39
-
40
-        $resultObject = $statement->fetchObject(get_called_class());
41
-
42
-        if ($resultObject != false) {
43
-            $resultObject->setDatabase($database);
44
-        }
45
-
46
-        return $resultObject;
47
-    }
48
-
49
-    public function save()
50
-    {
51
-        if ($this->isNew()) {
52
-            // insert
53
-            $statement = $this->dbObject->prepare(<<<SQL
22
+	private $address;
23
+	private $data;
24
+	private $creation;
25
+
26
+	/**
27
+	 * @param string      $address
28
+	 * @param PdoDatabase $database
29
+	 *
30
+	 * @return RDnsCache|false
31
+	 */
32
+	public static function getByAddress($address, PdoDatabase $database)
33
+	{
34
+		// @todo add cache invalidation (timestamp?)
35
+		$statement = $database->prepare("SELECT * FROM rdnscache WHERE address = :id LIMIT 1;");
36
+		$statement->bindValue(":id", $address);
37
+
38
+		$statement->execute();
39
+
40
+		$resultObject = $statement->fetchObject(get_called_class());
41
+
42
+		if ($resultObject != false) {
43
+			$resultObject->setDatabase($database);
44
+		}
45
+
46
+		return $resultObject;
47
+	}
48
+
49
+	public function save()
50
+	{
51
+		if ($this->isNew()) {
52
+			// insert
53
+			$statement = $this->dbObject->prepare(<<<SQL
54 54
 INSERT INTO `rdnscache` (address, data) VALUES (:address, :data);
55 55
 SQL
56
-            );
57
-            $statement->bindValue(":address", $this->address);
58
-            $statement->bindValue(":data", $this->data);
59
-
60
-            if ($statement->execute()) {
61
-                $this->id = (int)$this->dbObject->lastInsertId();
62
-            }
63
-            else {
64
-                throw new Exception($statement->errorInfo());
65
-            }
66
-        }
67
-        else {
68
-            // update
69
-            $statement = $this->dbObject->prepare(<<<SQL
56
+			);
57
+			$statement->bindValue(":address", $this->address);
58
+			$statement->bindValue(":data", $this->data);
59
+
60
+			if ($statement->execute()) {
61
+				$this->id = (int)$this->dbObject->lastInsertId();
62
+			}
63
+			else {
64
+				throw new Exception($statement->errorInfo());
65
+			}
66
+		}
67
+		else {
68
+			// update
69
+			$statement = $this->dbObject->prepare(<<<SQL
70 70
 UPDATE `rdnscache`
71 71
 SET address = :address, data = :data, updateversion = updateversion + 1
72 72
 WHERE id = :id AND updateversion = :updateversion
73 73
 LIMIT 1;
74 74
 SQL
75
-            );
76
-
77
-            $statement->bindValue(':id', $this->id);
78
-            $statement->bindValue(':updateversion', $this->updateversion);
79
-
80
-            $statement->bindValue(':address', $this->address);
81
-            $statement->bindValue(':data', $this->data);
82
-
83
-            if (!$statement->execute()) {
84
-                throw new Exception($statement->errorInfo());
85
-            }
86
-
87
-            if ($statement->rowCount() !== 1) {
88
-                throw new OptimisticLockFailedException();
89
-            }
90
-
91
-            $this->updateversion++;
92
-        }
93
-    }
94
-
95
-    public function getAddress()
96
-    {
97
-        return $this->address;
98
-    }
99
-
100
-    /**
101
-     * @param string $address
102
-     */
103
-    public function setAddress($address)
104
-    {
105
-        $this->address = $address;
106
-    }
107
-
108
-    /**
109
-     * @return string
110
-     */
111
-    public function getData()
112
-    {
113
-        return unserialize($this->data);
114
-    }
115
-
116
-    public function setData($data)
117
-    {
118
-        $this->data = serialize($data);
119
-    }
120
-
121
-    /**
122
-     * @return DateTimeImmutable
123
-     */
124
-    public function getCreation()
125
-    {
126
-        return new DateTimeImmutable($this->creation);
127
-    }
75
+			);
76
+
77
+			$statement->bindValue(':id', $this->id);
78
+			$statement->bindValue(':updateversion', $this->updateversion);
79
+
80
+			$statement->bindValue(':address', $this->address);
81
+			$statement->bindValue(':data', $this->data);
82
+
83
+			if (!$statement->execute()) {
84
+				throw new Exception($statement->errorInfo());
85
+			}
86
+
87
+			if ($statement->rowCount() !== 1) {
88
+				throw new OptimisticLockFailedException();
89
+			}
90
+
91
+			$this->updateversion++;
92
+		}
93
+	}
94
+
95
+	public function getAddress()
96
+	{
97
+		return $this->address;
98
+	}
99
+
100
+	/**
101
+	 * @param string $address
102
+	 */
103
+	public function setAddress($address)
104
+	{
105
+		$this->address = $address;
106
+	}
107
+
108
+	/**
109
+	 * @return string
110
+	 */
111
+	public function getData()
112
+	{
113
+		return unserialize($this->data);
114
+	}
115
+
116
+	public function setData($data)
117
+	{
118
+		$this->data = serialize($data);
119
+	}
120
+
121
+	/**
122
+	 * @return DateTimeImmutable
123
+	 */
124
+	public function getCreation()
125
+	{
126
+		return new DateTimeImmutable($this->creation);
127
+	}
128 128
 }
Please login to merge, or discard this patch.
includes/DataObjects/Notification.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -22,73 +22,73 @@
 block discarded – undo
22 22
  */
23 23
 class Notification extends DataObject
24 24
 {
25
-    private $date;
26
-    private $type;
27
-    private $text;
25
+	private $date;
26
+	private $type;
27
+	private $text;
28 28
 
29
-    public function delete()
30
-    {
31
-        throw new Exception("You shouldn't be doing this...");
32
-    }
29
+	public function delete()
30
+	{
31
+		throw new Exception("You shouldn't be doing this...");
32
+	}
33 33
 
34
-    public function save()
35
-    {
36
-        if ($this->isNew()) {
37
-            // insert
38
-            $statement = $this->dbObject->prepare("INSERT INTO notification ( type, text ) VALUES ( :type, :text );");
39
-            $statement->bindValue(":type", $this->type);
40
-            $statement->bindValue(":text", $this->text);
34
+	public function save()
35
+	{
36
+		if ($this->isNew()) {
37
+			// insert
38
+			$statement = $this->dbObject->prepare("INSERT INTO notification ( type, text ) VALUES ( :type, :text );");
39
+			$statement->bindValue(":type", $this->type);
40
+			$statement->bindValue(":text", $this->text);
41 41
 
42
-            if ($statement->execute()) {
43
-                $this->id = (int)$this->dbObject->lastInsertId();
44
-            }
45
-            else {
46
-                throw new Exception($statement->errorInfo());
47
-            }
48
-        }
49
-        else {
50
-            throw new Exception("You shouldn't be doing this...");
51
-        }
52
-    }
42
+			if ($statement->execute()) {
43
+				$this->id = (int)$this->dbObject->lastInsertId();
44
+			}
45
+			else {
46
+				throw new Exception($statement->errorInfo());
47
+			}
48
+		}
49
+		else {
50
+			throw new Exception("You shouldn't be doing this...");
51
+		}
52
+	}
53 53
 
54
-    public function getDate()
55
-    {
56
-        return new DateTimeImmutable($this->date);
57
-    }
54
+	public function getDate()
55
+	{
56
+		return new DateTimeImmutable($this->date);
57
+	}
58 58
 
59
-    /**
60
-     * @return int
61
-     */
62
-    public function getType()
63
-    {
64
-        return $this->type;
65
-    }
59
+	/**
60
+	 * @return int
61
+	 */
62
+	public function getType()
63
+	{
64
+		return $this->type;
65
+	}
66 66
 
67
-    /**
68
-     * @return string
69
-     */
70
-    public function getText()
71
-    {
72
-        return $this->text;
73
-    }
67
+	/**
68
+	 * @return string
69
+	 */
70
+	public function getText()
71
+	{
72
+		return $this->text;
73
+	}
74 74
 
75
-    /**
76
-     * Summary of setType
77
-     *
78
-     * @param int $type
79
-     */
80
-    public function setType($type)
81
-    {
82
-        $this->type = $type;
83
-    }
75
+	/**
76
+	 * Summary of setType
77
+	 *
78
+	 * @param int $type
79
+	 */
80
+	public function setType($type)
81
+	{
82
+		$this->type = $type;
83
+	}
84 84
 
85
-    /**
86
-     * Summary of setText
87
-     *
88
-     * @param string $text
89
-     */
90
-    public function setText($text)
91
-    {
92
-        $this->text = $text;
93
-    }
85
+	/**
86
+	 * Summary of setText
87
+	 *
88
+	 * @param string $text
89
+	 */
90
+	public function setText($text)
91
+	{
92
+		$this->text = $text;
93
+	}
94 94
 }
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,268 +19,268 @@
 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 WHERE target = :target AND (duration > UNIX_TIMESTAMP() OR duration = -1) AND active = 1;
43 43
 SQL;
44
-            $statement = $database->prepare($query);
45
-            $statement->bindValue(":target", $target);
46
-        }
47
-        else {
48
-            $query = "SELECT * FROM ban WHERE (duration > UNIX_TIMESTAMP() OR duration = -1) AND active = 1;";
49
-            $statement = $database->prepare($query);
50
-        }
51
-
52
-        $statement->execute();
53
-
54
-        $result = array();
55
-
56
-        /** @var Ban $v */
57
-        foreach ($statement->fetchAll(PDO::FETCH_CLASS, get_called_class()) as $v) {
58
-            $v->setDatabase($database);
59
-            $result[] = $v;
60
-        }
61
-
62
-        return $result;
63
-    }
64
-
65
-    /**
66
-     * Gets a ban by it's ID if it's currently active.
67
-     *
68
-     * @param     integer $id
69
-     * @param PdoDatabase $database
70
-     *
71
-     * @return Ban
72
-     */
73
-    public static function getActiveId($id, PdoDatabase $database)
74
-    {
75
-        $statement = $database->prepare(<<<SQL
44
+			$statement = $database->prepare($query);
45
+			$statement->bindValue(":target", $target);
46
+		}
47
+		else {
48
+			$query = "SELECT * FROM ban WHERE (duration > UNIX_TIMESTAMP() OR duration = -1) AND active = 1;";
49
+			$statement = $database->prepare($query);
50
+		}
51
+
52
+		$statement->execute();
53
+
54
+		$result = array();
55
+
56
+		/** @var Ban $v */
57
+		foreach ($statement->fetchAll(PDO::FETCH_CLASS, get_called_class()) as $v) {
58
+			$v->setDatabase($database);
59
+			$result[] = $v;
60
+		}
61
+
62
+		return $result;
63
+	}
64
+
65
+	/**
66
+	 * Gets a ban by it's ID if it's currently active.
67
+	 *
68
+	 * @param     integer $id
69
+	 * @param PdoDatabase $database
70
+	 *
71
+	 * @return Ban
72
+	 */
73
+	public static function getActiveId($id, PdoDatabase $database)
74
+	{
75
+		$statement = $database->prepare(<<<SQL
76 76
 SELECT *
77 77
 FROM ban
78 78
 WHERE id = :id  AND (duration > UNIX_TIMESTAMP() OR duration = -1) AND active = 1;
79 79
 SQL
80
-        );
81
-        $statement->bindValue(":id", $id);
82
-
83
-        $statement->execute();
84
-
85
-        $resultObject = $statement->fetchObject(get_called_class());
86
-
87
-        if ($resultObject != false) {
88
-            $resultObject->setDatabase($database);
89
-        }
90
-
91
-        return $resultObject;
92
-    }
93
-
94
-    /**
95
-     * Get all active bans for a target and type.
96
-     *
97
-     * @param string      $target
98
-     * @param string      $type
99
-     * @param PdoDatabase $database
100
-     *
101
-     * @return Ban
102
-     */
103
-    public static function getBanByTarget($target, $type, PdoDatabase $database)
104
-    {
105
-        $query = <<<SQL
80
+		);
81
+		$statement->bindValue(":id", $id);
82
+
83
+		$statement->execute();
84
+
85
+		$resultObject = $statement->fetchObject(get_called_class());
86
+
87
+		if ($resultObject != false) {
88
+			$resultObject->setDatabase($database);
89
+		}
90
+
91
+		return $resultObject;
92
+	}
93
+
94
+	/**
95
+	 * Get all active bans for a target and type.
96
+	 *
97
+	 * @param string      $target
98
+	 * @param string      $type
99
+	 * @param PdoDatabase $database
100
+	 *
101
+	 * @return Ban
102
+	 */
103
+	public static function getBanByTarget($target, $type, PdoDatabase $database)
104
+	{
105
+		$query = <<<SQL
106 106
 SELECT * FROM ban
107 107
 WHERE type = :type
108 108
 	AND target = :target
109 109
 	AND (duration > UNIX_TIMESTAMP() OR duration = -1)
110 110
 	AND active = 1;
111 111
 SQL;
112
-        $statement = $database->prepare($query);
113
-        $statement->bindValue(":target", $target);
114
-        $statement->bindValue(":type", $type);
112
+		$statement = $database->prepare($query);
113
+		$statement->bindValue(":target", $target);
114
+		$statement->bindValue(":type", $type);
115 115
 
116
-        $statement->execute();
116
+		$statement->execute();
117 117
 
118
-        $resultObject = $statement->fetchObject(get_called_class());
118
+		$resultObject = $statement->fetchObject(get_called_class());
119 119
 
120
-        if ($resultObject != false) {
121
-            $resultObject->setDatabase($database);
122
-        }
120
+		if ($resultObject != false) {
121
+			$resultObject->setDatabase($database);
122
+		}
123 123
 
124
-        return $resultObject;
125
-    }
124
+		return $resultObject;
125
+	}
126 126
 
127
-    /**
128
-     * @throws Exception
129
-     */
130
-    public function save()
131
-    {
132
-        if ($this->isNew()) {
133
-            // insert
134
-            $statement = $this->dbObject->prepare(<<<SQL
127
+	/**
128
+	 * @throws Exception
129
+	 */
130
+	public function save()
131
+	{
132
+		if ($this->isNew()) {
133
+			// insert
134
+			$statement = $this->dbObject->prepare(<<<SQL
135 135
 INSERT INTO `ban` (type, target, user, reason, date, duration, active)
136 136
 VALUES (:type, :target, :user, :reason, CURRENT_TIMESTAMP(), :duration, :active);
137 137
 SQL
138
-            );
139
-            $statement->bindValue(":type", $this->type);
140
-            $statement->bindValue(":target", $this->target);
141
-            $statement->bindValue(":user", $this->user);
142
-            $statement->bindValue(":reason", $this->reason);
143
-            $statement->bindValue(":duration", $this->duration);
144
-            $statement->bindValue(":active", $this->active);
145
-
146
-            if ($statement->execute()) {
147
-                $this->id = (int)$this->dbObject->lastInsertId();
148
-            }
149
-            else {
150
-                throw new Exception($statement->errorInfo());
151
-            }
152
-        }
153
-        else {
154
-            // update
155
-            $statement = $this->dbObject->prepare(<<<SQL
138
+			);
139
+			$statement->bindValue(":type", $this->type);
140
+			$statement->bindValue(":target", $this->target);
141
+			$statement->bindValue(":user", $this->user);
142
+			$statement->bindValue(":reason", $this->reason);
143
+			$statement->bindValue(":duration", $this->duration);
144
+			$statement->bindValue(":active", $this->active);
145
+
146
+			if ($statement->execute()) {
147
+				$this->id = (int)$this->dbObject->lastInsertId();
148
+			}
149
+			else {
150
+				throw new Exception($statement->errorInfo());
151
+			}
152
+		}
153
+		else {
154
+			// update
155
+			$statement = $this->dbObject->prepare(<<<SQL
156 156
 UPDATE `ban`
157 157
 SET duration = :duration, active = :active, user = :user, updateversion = updateversion + 1
158 158
 WHERE id = :id AND updateversion = :updateversion
159 159
 LIMIT 1;
160 160
 SQL
161
-            );
162
-            $statement->bindValue(':id', $this->id);
163
-            $statement->bindValue(':updateversion', $this->updateversion);
164
-
165
-            $statement->bindValue(':duration', $this->duration);
166
-            $statement->bindValue(':active', $this->active);
167
-            $statement->bindValue(':user', $this->user);
168
-
169
-            if (!$statement->execute()) {
170
-                throw new Exception($statement->errorInfo());
171
-            }
172
-
173
-            if ($statement->rowCount() !== 1) {
174
-                throw new OptimisticLockFailedException();
175
-            }
176
-
177
-            $this->updateversion++;
178
-        }
179
-    }
180
-
181
-    /**
182
-     * @return string
183
-     */
184
-    public function getType()
185
-    {
186
-        return $this->type;
187
-    }
188
-
189
-    /**
190
-     * @param string $type
191
-     */
192
-    public function setType($type)
193
-    {
194
-        $this->type = $type;
195
-    }
196
-
197
-    /**
198
-     * @return string
199
-     */
200
-    public function getTarget()
201
-    {
202
-        return $this->target;
203
-    }
204
-
205
-    /**
206
-     * @param string $target
207
-     */
208
-    public function setTarget($target)
209
-    {
210
-        $this->target = $target;
211
-    }
212
-
213
-    /**
214
-     * @return string
215
-     */
216
-    public function getReason()
217
-    {
218
-        return $this->reason;
219
-    }
220
-
221
-    /**
222
-     * @param string $reason
223
-     */
224
-    public function setReason($reason)
225
-    {
226
-        $this->reason = $reason;
227
-    }
228
-
229
-    /**
230
-     * @return mixed
231
-     */
232
-    public function getDate()
233
-    {
234
-        return $this->date;
235
-    }
236
-
237
-    /**
238
-     * @return mixed
239
-     */
240
-    public function getDuration()
241
-    {
242
-        return $this->duration;
243
-    }
244
-
245
-    /**
246
-     * @param mixed $duration
247
-     */
248
-    public function setDuration($duration)
249
-    {
250
-        $this->duration = $duration;
251
-    }
252
-
253
-    /**
254
-     * @return bool
255
-     */
256
-    public function isActive()
257
-    {
258
-        return $this->active == 1;
259
-    }
260
-
261
-    /**
262
-     * @param bool $active
263
-     */
264
-    public function setActive($active)
265
-    {
266
-        $this->active = $active ? 1 : 0;
267
-    }
268
-
269
-    /**
270
-     * @return int
271
-     */
272
-    public function getUser()
273
-    {
274
-        return $this->user;
275
-    }
276
-
277
-    /**
278
-     * @param int $user UserID of user who is setting the ban
279
-     *
280
-     * @throws Exception
281
-     */
282
-    public function setUser($user)
283
-    {
284
-        $this->user = $user;
285
-    }
161
+			);
162
+			$statement->bindValue(':id', $this->id);
163
+			$statement->bindValue(':updateversion', $this->updateversion);
164
+
165
+			$statement->bindValue(':duration', $this->duration);
166
+			$statement->bindValue(':active', $this->active);
167
+			$statement->bindValue(':user', $this->user);
168
+
169
+			if (!$statement->execute()) {
170
+				throw new Exception($statement->errorInfo());
171
+			}
172
+
173
+			if ($statement->rowCount() !== 1) {
174
+				throw new OptimisticLockFailedException();
175
+			}
176
+
177
+			$this->updateversion++;
178
+		}
179
+	}
180
+
181
+	/**
182
+	 * @return string
183
+	 */
184
+	public function getType()
185
+	{
186
+		return $this->type;
187
+	}
188
+
189
+	/**
190
+	 * @param string $type
191
+	 */
192
+	public function setType($type)
193
+	{
194
+		$this->type = $type;
195
+	}
196
+
197
+	/**
198
+	 * @return string
199
+	 */
200
+	public function getTarget()
201
+	{
202
+		return $this->target;
203
+	}
204
+
205
+	/**
206
+	 * @param string $target
207
+	 */
208
+	public function setTarget($target)
209
+	{
210
+		$this->target = $target;
211
+	}
212
+
213
+	/**
214
+	 * @return string
215
+	 */
216
+	public function getReason()
217
+	{
218
+		return $this->reason;
219
+	}
220
+
221
+	/**
222
+	 * @param string $reason
223
+	 */
224
+	public function setReason($reason)
225
+	{
226
+		$this->reason = $reason;
227
+	}
228
+
229
+	/**
230
+	 * @return mixed
231
+	 */
232
+	public function getDate()
233
+	{
234
+		return $this->date;
235
+	}
236
+
237
+	/**
238
+	 * @return mixed
239
+	 */
240
+	public function getDuration()
241
+	{
242
+		return $this->duration;
243
+	}
244
+
245
+	/**
246
+	 * @param mixed $duration
247
+	 */
248
+	public function setDuration($duration)
249
+	{
250
+		$this->duration = $duration;
251
+	}
252
+
253
+	/**
254
+	 * @return bool
255
+	 */
256
+	public function isActive()
257
+	{
258
+		return $this->active == 1;
259
+	}
260
+
261
+	/**
262
+	 * @param bool $active
263
+	 */
264
+	public function setActive($active)
265
+	{
266
+		$this->active = $active ? 1 : 0;
267
+	}
268
+
269
+	/**
270
+	 * @return int
271
+	 */
272
+	public function getUser()
273
+	{
274
+		return $this->user;
275
+	}
276
+
277
+	/**
278
+	 * @param int $user UserID of user who is setting the ban
279
+	 *
280
+	 * @throws Exception
281
+	 */
282
+	public function setUser($user)
283
+	{
284
+		$this->user = $user;
285
+	}
286 286
 }
Please login to merge, or discard this patch.
includes/DataObjects/SiteNotice.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -20,75 +20,75 @@
 block discarded – undo
20 20
  */
21 21
 class SiteNotice extends DataObject
22 22
 {
23
-    /** @var string */
24
-    private $content;
23
+	/** @var string */
24
+	private $content;
25 25
 
26
-    /**
27
-     * Get a message.
28
-     *
29
-     * @param PdoDatabase $database
30
-     *
31
-     * @return string The content for display
32
-     */
33
-    public static function get(PdoDatabase $database)
34
-    {
35
-        /** @var SiteNotice $message */
36
-        $message = self::getById(1, $database);
26
+	/**
27
+	 * Get a message.
28
+	 *
29
+	 * @param PdoDatabase $database
30
+	 *
31
+	 * @return string The content for display
32
+	 */
33
+	public static function get(PdoDatabase $database)
34
+	{
35
+		/** @var SiteNotice $message */
36
+		$message = self::getById(1, $database);
37 37
 
38
-        return $message->getContent();
39
-    }
38
+		return $message->getContent();
39
+	}
40 40
 
41
-    /**
42
-     * Saves the object
43
-     * @throws Exception
44
-     */
45
-    public function save()
46
-    {
47
-        if ($this->isNew()) {
48
-            // insert
49
-            throw new Exception('Not allowed to create new site notice object');
50
-        }
51
-        else {
52
-            // update
53
-            $statement = $this->dbObject->prepare(<<<SQL
41
+	/**
42
+	 * Saves the object
43
+	 * @throws Exception
44
+	 */
45
+	public function save()
46
+	{
47
+		if ($this->isNew()) {
48
+			// insert
49
+			throw new Exception('Not allowed to create new site notice object');
50
+		}
51
+		else {
52
+			// update
53
+			$statement = $this->dbObject->prepare(<<<SQL
54 54
 UPDATE sitenotice
55 55
 SET content = :content, updateversion = updateversion + 1
56 56
 WHERE updateversion = :updateversion
57 57
 LIMIT 1;
58 58
 SQL
59
-            );
60
-            $statement->bindValue(':updateversion', $this->updateversion);
59
+			);
60
+			$statement->bindValue(':updateversion', $this->updateversion);
61 61
 
62
-            $statement->bindValue(':content', $this->content);
62
+			$statement->bindValue(':content', $this->content);
63 63
 
64
-            if (!$statement->execute()) {
65
-                throw new Exception($statement->errorInfo());
66
-            }
64
+			if (!$statement->execute()) {
65
+				throw new Exception($statement->errorInfo());
66
+			}
67 67
 
68
-            if ($statement->rowCount() !== 1) {
69
-                throw new OptimisticLockFailedException();
70
-            }
68
+			if ($statement->rowCount() !== 1) {
69
+				throw new OptimisticLockFailedException();
70
+			}
71 71
 
72
-            $this->updateversion++;
73
-        }
74
-    }
72
+			$this->updateversion++;
73
+		}
74
+	}
75 75
 
76
-    /**
77
-     * Gets the content of the message
78
-     * @return string
79
-     */
80
-    public function getContent()
81
-    {
82
-        return $this->content;
83
-    }
76
+	/**
77
+	 * Gets the content of the message
78
+	 * @return string
79
+	 */
80
+	public function getContent()
81
+	{
82
+		return $this->content;
83
+	}
84 84
 
85
-    /**
86
-     * Sets the content of the message
87
-     *
88
-     * @param string $content
89
-     */
90
-    public function setContent($content)
91
-    {
92
-        $this->content = $content;
93
-    }
85
+	/**
86
+	 * Sets the content of the message
87
+	 *
88
+	 * @param string $content
89
+	 */
90
+	public function setContent($content)
91
+	{
92
+		$this->content = $content;
93
+	}
94 94
 }
Please login to merge, or discard this patch.
includes/DataObjects/Request.php 2 patches
Indentation   +348 added lines, -348 removed lines patch added patch discarded remove patch
@@ -21,30 +21,30 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class Request extends DataObject
23 23
 {
24
-    private $email;
25
-    private $ip;
26
-    private $name;
27
-    /** @var string|null */
28
-    private $comment;
29
-    private $status = "Open";
30
-    private $date;
31
-    private $emailsent = 0;
32
-    private $emailconfirm;
33
-    /** @var int|null */
34
-    private $reserved = null;
35
-    private $useragent;
36
-    private $forwardedip;
37
-    private $hasComments = false;
38
-    private $hasCommentsResolved = false;
39
-
40
-    /**
41
-     * @throws Exception
42
-     */
43
-    public function save()
44
-    {
45
-        if ($this->isNew()) {
46
-            // insert
47
-            $statement = $this->dbObject->prepare(<<<SQL
24
+	private $email;
25
+	private $ip;
26
+	private $name;
27
+	/** @var string|null */
28
+	private $comment;
29
+	private $status = "Open";
30
+	private $date;
31
+	private $emailsent = 0;
32
+	private $emailconfirm;
33
+	/** @var int|null */
34
+	private $reserved = null;
35
+	private $useragent;
36
+	private $forwardedip;
37
+	private $hasComments = false;
38
+	private $hasCommentsResolved = false;
39
+
40
+	/**
41
+	 * @throws Exception
42
+	 */
43
+	public function save()
44
+	{
45
+		if ($this->isNew()) {
46
+			// insert
47
+			$statement = $this->dbObject->prepare(<<<SQL
48 48
 INSERT INTO `request` (
49 49
 	email, ip, name, comment, status, date, emailsent,
50 50
 	emailconfirm, reserved, useragent, forwardedip
@@ -53,28 +53,28 @@  discard block
 block discarded – undo
53 53
 	:emailconfirm, :reserved, :useragent, :forwardedip
54 54
 );
55 55
 SQL
56
-            );
57
-            $statement->bindValue(':email', $this->email);
58
-            $statement->bindValue(':ip', $this->ip);
59
-            $statement->bindValue(':name', $this->name);
60
-            $statement->bindValue(':comment', $this->comment);
61
-            $statement->bindValue(':status', $this->status);
62
-            $statement->bindValue(':emailsent', $this->emailsent);
63
-            $statement->bindValue(':emailconfirm', $this->emailconfirm);
64
-            $statement->bindValue(':reserved', $this->reserved);
65
-            $statement->bindValue(':useragent', $this->useragent);
66
-            $statement->bindValue(':forwardedip', $this->forwardedip);
67
-
68
-            if ($statement->execute()) {
69
-                $this->id = (int)$this->dbObject->lastInsertId();
70
-            }
71
-            else {
72
-                throw new Exception($statement->errorInfo());
73
-            }
74
-        }
75
-        else {
76
-            // update
77
-            $statement = $this->dbObject->prepare(<<<SQL
56
+			);
57
+			$statement->bindValue(':email', $this->email);
58
+			$statement->bindValue(':ip', $this->ip);
59
+			$statement->bindValue(':name', $this->name);
60
+			$statement->bindValue(':comment', $this->comment);
61
+			$statement->bindValue(':status', $this->status);
62
+			$statement->bindValue(':emailsent', $this->emailsent);
63
+			$statement->bindValue(':emailconfirm', $this->emailconfirm);
64
+			$statement->bindValue(':reserved', $this->reserved);
65
+			$statement->bindValue(':useragent', $this->useragent);
66
+			$statement->bindValue(':forwardedip', $this->forwardedip);
67
+
68
+			if ($statement->execute()) {
69
+				$this->id = (int)$this->dbObject->lastInsertId();
70
+			}
71
+			else {
72
+				throw new Exception($statement->errorInfo());
73
+			}
74
+		}
75
+		else {
76
+			// update
77
+			$statement = $this->dbObject->prepare(<<<SQL
78 78
 UPDATE `request` SET
79 79
 	status = :status,
80 80
 	emailsent = :emailsent,
@@ -84,241 +84,241 @@  discard block
 block discarded – undo
84 84
 WHERE id = :id AND updateversion = :updateversion
85 85
 LIMIT 1;
86 86
 SQL
87
-            );
88
-
89
-            $statement->bindValue(':id', $this->id);
90
-            $statement->bindValue(':updateversion', $this->updateversion);
91
-
92
-            $statement->bindValue(':status', $this->status);
93
-            $statement->bindValue(':emailsent', $this->emailsent);
94
-            $statement->bindValue(':emailconfirm', $this->emailconfirm);
95
-            $statement->bindValue(':reserved', $this->reserved);
96
-
97
-            if (!$statement->execute()) {
98
-                throw new Exception($statement->errorInfo());
99
-            }
100
-
101
-            if ($statement->rowCount() !== 1) {
102
-                throw new OptimisticLockFailedException();
103
-            }
104
-
105
-            $this->updateversion++;
106
-        }
107
-    }
108
-
109
-    /**
110
-     * @return string
111
-     */
112
-    public function getIp()
113
-    {
114
-        return $this->ip;
115
-    }
116
-
117
-    /**
118
-     * @param string $ip
119
-     */
120
-    public function setIp($ip)
121
-    {
122
-        $this->ip = $ip;
123
-    }
124
-
125
-    /**
126
-     * @return string
127
-     */
128
-    public function getName()
129
-    {
130
-        return $this->name;
131
-    }
132
-
133
-    /**
134
-     * @param string $name
135
-     */
136
-    public function setName($name)
137
-    {
138
-        $this->name = $name;
139
-    }
140
-
141
-    /**
142
-     * @return string|null
143
-     */
144
-    public function getComment()
145
-    {
146
-        return $this->comment;
147
-    }
148
-
149
-    /**
150
-     * @param string $comment
151
-     */
152
-    public function setComment($comment)
153
-    {
154
-        $this->comment = $comment;
155
-    }
156
-
157
-    /**
158
-     * @return string
159
-     */
160
-    public function getStatus()
161
-    {
162
-        return $this->status;
163
-    }
164
-
165
-    /**
166
-     * @param string $status
167
-     */
168
-    public function setStatus($status)
169
-    {
170
-        $this->status = $status;
171
-    }
172
-
173
-    /**
174
-     * Returns the time the request was first submitted
175
-     *
176
-     * @return DateTimeImmutable
177
-     */
178
-    public function getDate()
179
-    {
180
-        return new DateTimeImmutable($this->date);
181
-    }
182
-
183
-    /**
184
-     * @return bool
185
-     */
186
-    public function getEmailSent()
187
-    {
188
-        return $this->emailsent == "1";
189
-    }
190
-
191
-    /**
192
-     * @param bool $emailSent
193
-     */
194
-    public function setEmailSent($emailSent)
195
-    {
196
-        $this->emailsent = $emailSent ? 1 : 0;
197
-    }
198
-
199
-    /**
200
-     * @return int|null
201
-     */
202
-    public function getReserved()
203
-    {
204
-        return $this->reserved;
205
-    }
206
-
207
-    /**
208
-     * @param int|null $reserved
209
-     */
210
-    public function setReserved($reserved)
211
-    {
212
-        $this->reserved = $reserved;
213
-    }
214
-
215
-    /**
216
-     * @return string
217
-     */
218
-    public function getUserAgent()
219
-    {
220
-        return $this->useragent;
221
-    }
222
-
223
-    /**
224
-     * @param string $useragent
225
-     */
226
-    public function setUserAgent($useragent)
227
-    {
228
-        $this->useragent = $useragent;
229
-    }
230
-
231
-    /**
232
-     * @return string|null
233
-     */
234
-    public function getForwardedIp()
235
-    {
236
-        return $this->forwardedip;
237
-    }
238
-
239
-    /**
240
-     * @param string|null $forwardedip
241
-     */
242
-    public function setForwardedIp($forwardedip)
243
-    {
244
-        $this->forwardedip = $forwardedip;
245
-    }
246
-
247
-    /**
248
-     * @return bool
249
-     */
250
-    public function hasComments()
251
-    {
252
-        if ($this->hasCommentsResolved) {
253
-            return $this->hasComments;
254
-        }
255
-
256
-        if ($this->comment != "") {
257
-            $this->hasComments = true;
258
-            $this->hasCommentsResolved = true;
259
-
260
-            return true;
261
-        }
262
-
263
-        $commentsQuery = $this->dbObject->prepare("SELECT COUNT(*) AS num FROM comment WHERE request = :id;");
264
-        $commentsQuery->bindValue(":id", $this->id);
265
-
266
-        $commentsQuery->execute();
267
-
268
-        $this->hasComments = ($commentsQuery->fetchColumn() != 0);
269
-        $this->hasCommentsResolved = true;
270
-
271
-        return $this->hasComments;
272
-    }
273
-
274
-    /**
275
-     * @return string
276
-     */
277
-    public function getEmailConfirm()
278
-    {
279
-        return $this->emailconfirm;
280
-    }
281
-
282
-    /**
283
-     * @param string $emailconfirm
284
-     */
285
-    public function setEmailConfirm($emailconfirm)
286
-    {
287
-        $this->emailconfirm = $emailconfirm;
288
-    }
289
-
290
-    public function generateEmailConfirmationHash()
291
-    {
292
-        $this->emailconfirm = bin2hex(openssl_random_pseudo_bytes(16));
293
-    }
294
-
295
-    /**
296
-     * @return string|null
297
-     */
298
-    public function getEmail()
299
-    {
300
-        return $this->email;
301
-    }
302
-
303
-    /**
304
-     * @param string|null $email
305
-     */
306
-    public function setEmail($email)
307
-    {
308
-        $this->email = $email;
309
-    }
310
-
311
-    /**
312
-     * @return string
313
-     * @throws Exception
314
-     */
315
-    public function getClosureReason()
316
-    {
317
-        if ($this->status != 'Closed') {
318
-            throw new Exception("Can't get closure reason for open request.");
319
-        }
320
-
321
-        $statement = $this->dbObject->prepare(<<<SQL
87
+			);
88
+
89
+			$statement->bindValue(':id', $this->id);
90
+			$statement->bindValue(':updateversion', $this->updateversion);
91
+
92
+			$statement->bindValue(':status', $this->status);
93
+			$statement->bindValue(':emailsent', $this->emailsent);
94
+			$statement->bindValue(':emailconfirm', $this->emailconfirm);
95
+			$statement->bindValue(':reserved', $this->reserved);
96
+
97
+			if (!$statement->execute()) {
98
+				throw new Exception($statement->errorInfo());
99
+			}
100
+
101
+			if ($statement->rowCount() !== 1) {
102
+				throw new OptimisticLockFailedException();
103
+			}
104
+
105
+			$this->updateversion++;
106
+		}
107
+	}
108
+
109
+	/**
110
+	 * @return string
111
+	 */
112
+	public function getIp()
113
+	{
114
+		return $this->ip;
115
+	}
116
+
117
+	/**
118
+	 * @param string $ip
119
+	 */
120
+	public function setIp($ip)
121
+	{
122
+		$this->ip = $ip;
123
+	}
124
+
125
+	/**
126
+	 * @return string
127
+	 */
128
+	public function getName()
129
+	{
130
+		return $this->name;
131
+	}
132
+
133
+	/**
134
+	 * @param string $name
135
+	 */
136
+	public function setName($name)
137
+	{
138
+		$this->name = $name;
139
+	}
140
+
141
+	/**
142
+	 * @return string|null
143
+	 */
144
+	public function getComment()
145
+	{
146
+		return $this->comment;
147
+	}
148
+
149
+	/**
150
+	 * @param string $comment
151
+	 */
152
+	public function setComment($comment)
153
+	{
154
+		$this->comment = $comment;
155
+	}
156
+
157
+	/**
158
+	 * @return string
159
+	 */
160
+	public function getStatus()
161
+	{
162
+		return $this->status;
163
+	}
164
+
165
+	/**
166
+	 * @param string $status
167
+	 */
168
+	public function setStatus($status)
169
+	{
170
+		$this->status = $status;
171
+	}
172
+
173
+	/**
174
+	 * Returns the time the request was first submitted
175
+	 *
176
+	 * @return DateTimeImmutable
177
+	 */
178
+	public function getDate()
179
+	{
180
+		return new DateTimeImmutable($this->date);
181
+	}
182
+
183
+	/**
184
+	 * @return bool
185
+	 */
186
+	public function getEmailSent()
187
+	{
188
+		return $this->emailsent == "1";
189
+	}
190
+
191
+	/**
192
+	 * @param bool $emailSent
193
+	 */
194
+	public function setEmailSent($emailSent)
195
+	{
196
+		$this->emailsent = $emailSent ? 1 : 0;
197
+	}
198
+
199
+	/**
200
+	 * @return int|null
201
+	 */
202
+	public function getReserved()
203
+	{
204
+		return $this->reserved;
205
+	}
206
+
207
+	/**
208
+	 * @param int|null $reserved
209
+	 */
210
+	public function setReserved($reserved)
211
+	{
212
+		$this->reserved = $reserved;
213
+	}
214
+
215
+	/**
216
+	 * @return string
217
+	 */
218
+	public function getUserAgent()
219
+	{
220
+		return $this->useragent;
221
+	}
222
+
223
+	/**
224
+	 * @param string $useragent
225
+	 */
226
+	public function setUserAgent($useragent)
227
+	{
228
+		$this->useragent = $useragent;
229
+	}
230
+
231
+	/**
232
+	 * @return string|null
233
+	 */
234
+	public function getForwardedIp()
235
+	{
236
+		return $this->forwardedip;
237
+	}
238
+
239
+	/**
240
+	 * @param string|null $forwardedip
241
+	 */
242
+	public function setForwardedIp($forwardedip)
243
+	{
244
+		$this->forwardedip = $forwardedip;
245
+	}
246
+
247
+	/**
248
+	 * @return bool
249
+	 */
250
+	public function hasComments()
251
+	{
252
+		if ($this->hasCommentsResolved) {
253
+			return $this->hasComments;
254
+		}
255
+
256
+		if ($this->comment != "") {
257
+			$this->hasComments = true;
258
+			$this->hasCommentsResolved = true;
259
+
260
+			return true;
261
+		}
262
+
263
+		$commentsQuery = $this->dbObject->prepare("SELECT COUNT(*) AS num FROM comment WHERE request = :id;");
264
+		$commentsQuery->bindValue(":id", $this->id);
265
+
266
+		$commentsQuery->execute();
267
+
268
+		$this->hasComments = ($commentsQuery->fetchColumn() != 0);
269
+		$this->hasCommentsResolved = true;
270
+
271
+		return $this->hasComments;
272
+	}
273
+
274
+	/**
275
+	 * @return string
276
+	 */
277
+	public function getEmailConfirm()
278
+	{
279
+		return $this->emailconfirm;
280
+	}
281
+
282
+	/**
283
+	 * @param string $emailconfirm
284
+	 */
285
+	public function setEmailConfirm($emailconfirm)
286
+	{
287
+		$this->emailconfirm = $emailconfirm;
288
+	}
289
+
290
+	public function generateEmailConfirmationHash()
291
+	{
292
+		$this->emailconfirm = bin2hex(openssl_random_pseudo_bytes(16));
293
+	}
294
+
295
+	/**
296
+	 * @return string|null
297
+	 */
298
+	public function getEmail()
299
+	{
300
+		return $this->email;
301
+	}
302
+
303
+	/**
304
+	 * @param string|null $email
305
+	 */
306
+	public function setEmail($email)
307
+	{
308
+		$this->email = $email;
309
+	}
310
+
311
+	/**
312
+	 * @return string
313
+	 * @throws Exception
314
+	 */
315
+	public function getClosureReason()
316
+	{
317
+		if ($this->status != 'Closed') {
318
+			throw new Exception("Can't get closure reason for open request.");
319
+		}
320
+
321
+		$statement = $this->dbObject->prepare(<<<SQL
322 322
 SELECT closes.mail_desc
323 323
 FROM log
324 324
 INNER JOIN closes ON log.action = closes.closes
@@ -328,25 +328,25 @@  discard block
 block discarded – undo
328 328
 ORDER BY log.timestamp DESC
329 329
 LIMIT 1;
330 330
 SQL
331
-        );
331
+		);
332 332
 
333
-        $statement->bindValue(":requestId", $this->id);
334
-        $statement->execute();
335
-        $reason = $statement->fetchColumn();
333
+		$statement->bindValue(":requestId", $this->id);
334
+		$statement->execute();
335
+		$reason = $statement->fetchColumn();
336 336
 
337
-        return $reason;
338
-    }
337
+		return $reason;
338
+	}
339 339
 
340
-    /**
341
-     * Gets a value indicating whether the request was closed as created or not.
342
-     */
343
-    public function getWasCreated()
344
-    {
345
-        if ($this->status != 'Closed') {
346
-            throw new Exception("Can't get closure reason for open request.");
347
-        }
340
+	/**
341
+	 * Gets a value indicating whether the request was closed as created or not.
342
+	 */
343
+	public function getWasCreated()
344
+	{
345
+		if ($this->status != 'Closed') {
346
+			throw new Exception("Can't get closure reason for open request.");
347
+		}
348 348
 
349
-        $statement = $this->dbObject->prepare(<<<SQL
349
+		$statement = $this->dbObject->prepare(<<<SQL
350 350
 SELECT emailtemplate.oncreated, log.action
351 351
 FROM log
352 352
 LEFT JOIN emailtemplate ON CONCAT('Closed ', emailtemplate.id) = log.action
@@ -356,60 +356,60 @@  discard block
 block discarded – undo
356 356
 ORDER BY log.timestamp DESC
357 357
 LIMIT 1;
358 358
 SQL
359
-        );
360
-
361
-        $statement->bindValue(":requestId", $this->id);
362
-        $statement->execute();
363
-        $onCreated = $statement->fetchColumn(0);
364
-        $logAction = $statement->fetchColumn(1);
365
-        $statement->closeCursor();
366
-
367
-        if ($onCreated === null) {
368
-            return $logAction === "Closed custom-y";
369
-        }
370
-
371
-        return (bool)$onCreated;
372
-    }
373
-
374
-    /**
375
-     * @return DateTime
376
-     */
377
-    public function getClosureDate()
378
-    {
379
-        $logQuery = $this->dbObject->prepare(<<<SQL
359
+		);
360
+
361
+		$statement->bindValue(":requestId", $this->id);
362
+		$statement->execute();
363
+		$onCreated = $statement->fetchColumn(0);
364
+		$logAction = $statement->fetchColumn(1);
365
+		$statement->closeCursor();
366
+
367
+		if ($onCreated === null) {
368
+			return $logAction === "Closed custom-y";
369
+		}
370
+
371
+		return (bool)$onCreated;
372
+	}
373
+
374
+	/**
375
+	 * @return DateTime
376
+	 */
377
+	public function getClosureDate()
378
+	{
379
+		$logQuery = $this->dbObject->prepare(<<<SQL
380 380
 SELECT timestamp FROM log
381 381
 WHERE objectid = :request AND objecttype = 'Request' AND action LIKE 'Closed%'
382 382
 ORDER BY timestamp DESC LIMIT 1;
383 383
 SQL
384
-        );
385
-        $logQuery->bindValue(":request", $this->getId());
386
-        $logQuery->execute();
387
-        $logTime = $logQuery->fetchColumn();
388
-        $logQuery->closeCursor();
389
-
390
-        return new DateTime($logTime);
391
-    }
392
-
393
-    /**
394
-     * Returns a hash based on data within this request which can be generated easily from the data to be used to reveal
395
-     * data to unauthorised* users.
396
-     *
397
-     * *:Not tool admins, check users, or the reserving user.
398
-     *
399
-     * @return string
400
-     *
401
-     * @todo future work to make invalidation better. Possibly move to the database and invalidate on relevant events?
402
-     *       Maybe depend on the last logged action timestamp?
403
-     */
404
-    public function getRevealHash()
405
-    {
406
-        $data = $this->id         // unique per request
407
-            . '|' . $this->ip           // }
408
-            . '|' . $this->forwardedip  // } private data not known to those without access
409
-            . '|' . $this->useragent    // }
410
-            . '|' . $this->email        // }
411
-            . '|' . $this->status;      // to rudimentarily invalidate the token on status change
412
-
413
-        return hash('sha256', $data);
414
-    }
384
+		);
385
+		$logQuery->bindValue(":request", $this->getId());
386
+		$logQuery->execute();
387
+		$logTime = $logQuery->fetchColumn();
388
+		$logQuery->closeCursor();
389
+
390
+		return new DateTime($logTime);
391
+	}
392
+
393
+	/**
394
+	 * Returns a hash based on data within this request which can be generated easily from the data to be used to reveal
395
+	 * data to unauthorised* users.
396
+	 *
397
+	 * *:Not tool admins, check users, or the reserving user.
398
+	 *
399
+	 * @return string
400
+	 *
401
+	 * @todo future work to make invalidation better. Possibly move to the database and invalidate on relevant events?
402
+	 *       Maybe depend on the last logged action timestamp?
403
+	 */
404
+	public function getRevealHash()
405
+	{
406
+		$data = $this->id         // unique per request
407
+			. '|' . $this->ip           // }
408
+			. '|' . $this->forwardedip  // } private data not known to those without access
409
+			. '|' . $this->useragent    // }
410
+			. '|' . $this->email        // }
411
+			. '|' . $this->status;      // to rudimentarily invalidate the token on status change
412
+
413
+		return hash('sha256', $data);
414
+	}
415 415
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -404,11 +404,11 @@
 block discarded – undo
404 404
     public function getRevealHash()
405 405
     {
406 406
         $data = $this->id         // unique per request
407
-            . '|' . $this->ip           // }
408
-            . '|' . $this->forwardedip  // } private data not known to those without access
409
-            . '|' . $this->useragent    // }
410
-            . '|' . $this->email        // }
411
-            . '|' . $this->status;      // to rudimentarily invalidate the token on status change
407
+            . '|'.$this->ip           // }
408
+            . '|'.$this->forwardedip  // } private data not known to those without access
409
+            . '|'.$this->useragent    // }
410
+            . '|'.$this->email        // }
411
+            . '|'.$this->status; // to rudimentarily invalidate the token on status change
412 412
 
413 413
         return hash('sha256', $data);
414 414
     }
Please login to merge, or discard this patch.
includes/DataObjects/AntiSpoofCache.php 1 patch
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -18,101 +18,101 @@
 block discarded – undo
18 18
  */
19 19
 class AntiSpoofCache extends DataObject
20 20
 {
21
-    /** @var string */
22
-    protected $username;
23
-    /** @var string */
24
-    protected $data;
25
-    /** @var string */
26
-    protected $timestamp;
27
-
28
-    /**
29
-     * @param   string    $username
30
-     * @param PdoDatabase $database
31
-     *
32
-     * @return AntiSpoofCache|false
33
-     */
34
-    public static function getByUsername($username, PdoDatabase $database)
35
-    {
36
-        $statement = $database->prepare(<<<SQL
21
+	/** @var string */
22
+	protected $username;
23
+	/** @var string */
24
+	protected $data;
25
+	/** @var string */
26
+	protected $timestamp;
27
+
28
+	/**
29
+	 * @param   string    $username
30
+	 * @param PdoDatabase $database
31
+	 *
32
+	 * @return AntiSpoofCache|false
33
+	 */
34
+	public static function getByUsername($username, PdoDatabase $database)
35
+	{
36
+		$statement = $database->prepare(<<<SQL
37 37
 SELECT *
38 38
 FROM antispoofcache
39 39
 WHERE username = :id AND timestamp > date_sub(now(), INTERVAL 3 HOUR)
40 40
 LIMIT 1
41 41
 SQL
42
-        );
43
-        $statement->bindValue(":id", $username);
44
-
45
-        $statement->execute();
46
-
47
-        $resultObject = $statement->fetchObject(get_called_class());
48
-
49
-        if ($resultObject != false) {
50
-            $resultObject->setDatabase($database);
51
-        }
52
-
53
-        return $resultObject;
54
-    }
55
-
56
-    /**
57
-     * @return string
58
-     */
59
-    public function getUsername()
60
-    {
61
-        return $this->username;
62
-    }
63
-
64
-    /**
65
-     * @param string $username
66
-     */
67
-    public function setUsername($username)
68
-    {
69
-        $this->username = $username;
70
-    }
71
-
72
-    /**
73
-     * @return string
74
-     */
75
-    public function getData()
76
-    {
77
-        return $this->data;
78
-    }
79
-
80
-    /**
81
-     * @param string $data
82
-     */
83
-    public function setData($data)
84
-    {
85
-        $this->data = $data;
86
-    }
87
-
88
-    /**
89
-     * @return DateTimeImmutable
90
-     */
91
-    public function getTimestamp()
92
-    {
93
-        return new DateTimeImmutable($this->timestamp);
94
-    }
95
-
96
-    /**
97
-     * @throws Exception
98
-     */
99
-    public function save()
100
-    {
101
-        if ($this->isNew()) {
102
-            // insert
103
-            // clear old data first
104
-            $this->dbObject->exec("DELETE FROM antispoofcache WHERE timestamp < date_sub(now(), INTERVAL 3 HOUR);");
105
-
106
-            $statement = $this->dbObject->prepare("INSERT INTO antispoofcache (username, data) VALUES (:username, :data);");
107
-            $statement->bindValue(":username", $this->username);
108
-            $statement->bindValue(":data", $this->data);
109
-
110
-            if ($statement->execute()) {
111
-                $this->id = (int)$this->dbObject->lastInsertId();
112
-            }
113
-            else {
114
-                throw new Exception($statement->errorInfo());
115
-            }
116
-        }
117
-    }
42
+		);
43
+		$statement->bindValue(":id", $username);
44
+
45
+		$statement->execute();
46
+
47
+		$resultObject = $statement->fetchObject(get_called_class());
48
+
49
+		if ($resultObject != false) {
50
+			$resultObject->setDatabase($database);
51
+		}
52
+
53
+		return $resultObject;
54
+	}
55
+
56
+	/**
57
+	 * @return string
58
+	 */
59
+	public function getUsername()
60
+	{
61
+		return $this->username;
62
+	}
63
+
64
+	/**
65
+	 * @param string $username
66
+	 */
67
+	public function setUsername($username)
68
+	{
69
+		$this->username = $username;
70
+	}
71
+
72
+	/**
73
+	 * @return string
74
+	 */
75
+	public function getData()
76
+	{
77
+		return $this->data;
78
+	}
79
+
80
+	/**
81
+	 * @param string $data
82
+	 */
83
+	public function setData($data)
84
+	{
85
+		$this->data = $data;
86
+	}
87
+
88
+	/**
89
+	 * @return DateTimeImmutable
90
+	 */
91
+	public function getTimestamp()
92
+	{
93
+		return new DateTimeImmutable($this->timestamp);
94
+	}
95
+
96
+	/**
97
+	 * @throws Exception
98
+	 */
99
+	public function save()
100
+	{
101
+		if ($this->isNew()) {
102
+			// insert
103
+			// clear old data first
104
+			$this->dbObject->exec("DELETE FROM antispoofcache WHERE timestamp < date_sub(now(), INTERVAL 3 HOUR);");
105
+
106
+			$statement = $this->dbObject->prepare("INSERT INTO antispoofcache (username, data) VALUES (:username, :data);");
107
+			$statement->bindValue(":username", $this->username);
108
+			$statement->bindValue(":data", $this->data);
109
+
110
+			if ($statement->execute()) {
111
+				$this->id = (int)$this->dbObject->lastInsertId();
112
+			}
113
+			else {
114
+				throw new Exception($statement->errorInfo());
115
+			}
116
+		}
117
+	}
118 118
 }
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,
@@ -202,130 +202,130 @@  discard block
 block discarded – undo
202 202
 WHERE id = :id AND updateversion = :updateversion
203 203
 LIMIT 1;
204 204
 SQL
205
-            );
206
-            $statement->bindValue(':id', $this->id);
207
-            $statement->bindValue(':updateversion', $this->updateversion);
208
-
209
-            $statement->bindValue(':name', $this->name);
210
-            $statement->bindValue(":text", $this->text);
211
-            $statement->bindValue(":jsquestion", $this->jsquestion);
212
-            $statement->bindValue(":defaultaction", $this->defaultaction);
213
-            $statement->bindValue(":active", $this->active);
214
-            $statement->bindValue(":preloadonly", $this->preloadonly);
215
-
216
-            if (!$statement->execute()) {
217
-                throw new Exception($statement->errorInfo());
218
-            }
219
-
220
-            if ($statement->rowCount() !== 1) {
221
-                throw new OptimisticLockFailedException();
222
-            }
223
-
224
-            $this->updateversion++;
225
-        }
226
-    }
227
-
228
-    /**
229
-     * Override delete() from DataObject
230
-     */
231
-    public function delete()
232
-    {
233
-        throw new Exception("You shouldn't be doing that, you'll break logs.");
234
-    }
235
-
236
-    /**
237
-     * @return string
238
-     */
239
-    public function getName()
240
-    {
241
-        return $this->name;
242
-    }
243
-
244
-    /**
245
-     * @param string $name
246
-     */
247
-    public function setName($name)
248
-    {
249
-        $this->name = $name;
250
-    }
251
-
252
-    /**
253
-     * @return string
254
-     */
255
-    public function getText()
256
-    {
257
-        return $this->text;
258
-    }
259
-
260
-    /**
261
-     * @param string $text
262
-     */
263
-    public function setText($text)
264
-    {
265
-        $this->text = $text;
266
-    }
267
-
268
-    /**
269
-     * @return string|null
270
-     */
271
-    public function getJsquestion()
272
-    {
273
-        return $this->jsquestion;
274
-    }
275
-
276
-    /**
277
-     * @param string $jsquestion
278
-     */
279
-    public function setJsquestion($jsquestion)
280
-    {
281
-        $this->jsquestion = $jsquestion;
282
-    }
283
-
284
-    /**
285
-     * @return string
286
-     */
287
-    public function getDefaultAction()
288
-    {
289
-        return $this->defaultaction;
290
-    }
291
-
292
-    /**
293
-     * @param string $defaultAction
294
-     */
295
-    public function setDefaultAction($defaultAction)
296
-    {
297
-        $this->defaultaction = $defaultAction;
298
-    }
299
-
300
-    /**
301
-     * @return bool
302
-     */
303
-    public function getActive()
304
-    {
305
-        return $this->active == 1;
306
-    }
307
-
308
-    /**
309
-     * @param bool $active
310
-     */
311
-    public function setActive($active)
312
-    {
313
-        $this->active = $active ? 1 : 0;
314
-    }
315
-
316
-    /**
317
-     * @return bool
318
-     */
319
-    public function getPreloadOnly()
320
-    {
321
-        return $this->preloadonly == 1;
322
-    }
323
-
324
-    /**
325
-     * @param bool $preloadonly
326
-     */
327
-    public function setPreloadOnly($preloadonly)
328
-    {
329
-        $this->preloadonly = $preloadonly ? 1 : 0;
330
-    }
205
+			);
206
+			$statement->bindValue(':id', $this->id);
207
+			$statement->bindValue(':updateversion', $this->updateversion);
208
+
209
+			$statement->bindValue(':name', $this->name);
210
+			$statement->bindValue(":text", $this->text);
211
+			$statement->bindValue(":jsquestion", $this->jsquestion);
212
+			$statement->bindValue(":defaultaction", $this->defaultaction);
213
+			$statement->bindValue(":active", $this->active);
214
+			$statement->bindValue(":preloadonly", $this->preloadonly);
215
+
216
+			if (!$statement->execute()) {
217
+				throw new Exception($statement->errorInfo());
218
+			}
219
+
220
+			if ($statement->rowCount() !== 1) {
221
+				throw new OptimisticLockFailedException();
222
+			}
223
+
224
+			$this->updateversion++;
225
+		}
226
+	}
227
+
228
+	/**
229
+	 * Override delete() from DataObject
230
+	 */
231
+	public function delete()
232
+	{
233
+		throw new Exception("You shouldn't be doing that, you'll break logs.");
234
+	}
235
+
236
+	/**
237
+	 * @return string
238
+	 */
239
+	public function getName()
240
+	{
241
+		return $this->name;
242
+	}
243
+
244
+	/**
245
+	 * @param string $name
246
+	 */
247
+	public function setName($name)
248
+	{
249
+		$this->name = $name;
250
+	}
251
+
252
+	/**
253
+	 * @return string
254
+	 */
255
+	public function getText()
256
+	{
257
+		return $this->text;
258
+	}
259
+
260
+	/**
261
+	 * @param string $text
262
+	 */
263
+	public function setText($text)
264
+	{
265
+		$this->text = $text;
266
+	}
267
+
268
+	/**
269
+	 * @return string|null
270
+	 */
271
+	public function getJsquestion()
272
+	{
273
+		return $this->jsquestion;
274
+	}
275
+
276
+	/**
277
+	 * @param string $jsquestion
278
+	 */
279
+	public function setJsquestion($jsquestion)
280
+	{
281
+		$this->jsquestion = $jsquestion;
282
+	}
283
+
284
+	/**
285
+	 * @return string
286
+	 */
287
+	public function getDefaultAction()
288
+	{
289
+		return $this->defaultaction;
290
+	}
291
+
292
+	/**
293
+	 * @param string $defaultAction
294
+	 */
295
+	public function setDefaultAction($defaultAction)
296
+	{
297
+		$this->defaultaction = $defaultAction;
298
+	}
299
+
300
+	/**
301
+	 * @return bool
302
+	 */
303
+	public function getActive()
304
+	{
305
+		return $this->active == 1;
306
+	}
307
+
308
+	/**
309
+	 * @param bool $active
310
+	 */
311
+	public function setActive($active)
312
+	{
313
+		$this->active = $active ? 1 : 0;
314
+	}
315
+
316
+	/**
317
+	 * @return bool
318
+	 */
319
+	public function getPreloadOnly()
320
+	{
321
+		return $this->preloadonly == 1;
322
+	}
323
+
324
+	/**
325
+	 * @param bool $preloadonly
326
+	 */
327
+	public function setPreloadOnly($preloadonly)
328
+	{
329
+		$this->preloadonly = $preloadonly ? 1 : 0;
330
+	}
331 331
 }
Please login to merge, or discard this patch.
includes/DataObjects/GeoLocation.php 1 patch
Indentation   +99 added lines, -99 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
-     *
32
-     * @return GeoLocation
33
-     */
34
-    public static function getByAddress($address, PdoDatabase $database)
35
-    {
36
-        $statement = $database->prepare("SELECT * FROM geolocation WHERE address = :id LIMIT 1;");
37
-        $statement->bindValue(":id", $address);
38
-
39
-        $statement->execute();
40
-
41
-        $resultObject = $statement->fetchObject(get_called_class());
42
-
43
-        if ($resultObject != false) {
44
-            $resultObject->setDatabase($database);
45
-        }
46
-
47
-        return $resultObject;
48
-    }
49
-
50
-    public function save()
51
-    {
52
-        if ($this->isNew()) {
53
-            // insert
54
-            $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
+	 *
32
+	 * @return GeoLocation
33
+	 */
34
+	public static function getByAddress($address, PdoDatabase $database)
35
+	{
36
+		$statement = $database->prepare("SELECT * FROM geolocation WHERE address = :id LIMIT 1;");
37
+		$statement->bindValue(":id", $address);
38
+
39
+		$statement->execute();
40
+
41
+		$resultObject = $statement->fetchObject(get_called_class());
42
+
43
+		if ($resultObject != false) {
44
+			$resultObject->setDatabase($database);
45
+		}
46
+
47
+		return $resultObject;
48
+	}
49
+
50
+	public function save()
51
+	{
52
+		if ($this->isNew()) {
53
+			// insert
54
+			$statement = $this->dbObject->prepare(<<<SQL
55 55
 INSERT INTO `geolocation` (address, data) VALUES (:address, :data);
56 56
 SQL
57
-            );
58
-            $statement->bindValue(":address", $this->address);
59
-            $statement->bindValue(":data", $this->data);
60
-
61
-            if ($statement->execute()) {
62
-                $this->id = (int)$this->dbObject->lastInsertId();
63
-            }
64
-            else {
65
-                throw new Exception($statement->errorInfo());
66
-            }
67
-        }
68
-        else {
69
-            // update
70
-            $statement = $this->dbObject->prepare(<<<SQL
57
+			);
58
+			$statement->bindValue(":address", $this->address);
59
+			$statement->bindValue(":data", $this->data);
60
+
61
+			if ($statement->execute()) {
62
+				$this->id = (int)$this->dbObject->lastInsertId();
63
+			}
64
+			else {
65
+				throw new Exception($statement->errorInfo());
66
+			}
67
+		}
68
+		else {
69
+			// update
70
+			$statement = $this->dbObject->prepare(<<<SQL
71 71
 UPDATE `geolocation`
72 72
 SET address = :address, data = :data, updateversion = updateversion + 1
73 73
 WHERE id = :id AND updateversion = :updateversion
74 74
 LIMIT 1;
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/Log.php 1 patch
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -17,151 +17,151 @@
 block discarded – undo
17 17
  */
18 18
 class Log extends DataObject
19 19
 {
20
-    /** @var int */
21
-    private $objectid;
22
-    /** @var string */
23
-    private $objecttype;
24
-    /** @var int */
25
-    private $user;
26
-    /** @var string */
27
-    private $action;
28
-    private $timestamp;
29
-    /** @var string|null */
30
-    private $comment;
31
-
32
-    /**
33
-     * @throws Exception
34
-     */
35
-    public function save()
36
-    {
37
-        if ($this->isNew()) {
38
-            $statement = $this->dbObject->prepare(<<<SQL
20
+	/** @var int */
21
+	private $objectid;
22
+	/** @var string */
23
+	private $objecttype;
24
+	/** @var int */
25
+	private $user;
26
+	/** @var string */
27
+	private $action;
28
+	private $timestamp;
29
+	/** @var string|null */
30
+	private $comment;
31
+
32
+	/**
33
+	 * @throws Exception
34
+	 */
35
+	public function save()
36
+	{
37
+		if ($this->isNew()) {
38
+			$statement = $this->dbObject->prepare(<<<SQL
39 39
                 INSERT INTO log (objectid, objecttype, user, action, timestamp, comment) 
40 40
                 VALUES (:id, :type, :user, :action, CURRENT_TIMESTAMP(), :comment);
41 41
 SQL
42
-            );
43
-
44
-            $statement->bindValue(":id", $this->objectid);
45
-            $statement->bindValue(":type", $this->objecttype);
46
-            $statement->bindValue(":user", $this->user);
47
-            $statement->bindValue(":action", $this->action);
48
-            $statement->bindValue(":comment", $this->comment);
49
-
50
-            if ($statement->execute()) {
51
-                $this->id = (int)$this->dbObject->lastInsertId();
52
-            }
53
-            else {
54
-                throw new Exception($statement->errorInfo());
55
-            }
56
-        }
57
-        else {
58
-            throw new Exception("Updating logs is not available");
59
-        }
60
-    }
61
-
62
-    /**
63
-     * @throws Exception
64
-     */
65
-    public function delete()
66
-    {
67
-        throw new Exception("Deleting logs is not available.");
68
-    }
69
-
70
-    /**
71
-     * @return int
72
-     */
73
-    public function getObjectId()
74
-    {
75
-        return $this->objectid;
76
-    }
77
-
78
-    /**
79
-     * Summary of setObjectId
80
-     *
81
-     * @param int $objectId
82
-     */
83
-    public function setObjectId($objectId)
84
-    {
85
-        $this->objectid = $objectId;
86
-    }
87
-
88
-    /**
89
-     * @return string
90
-     */
91
-    public function getObjectType()
92
-    {
93
-        return $this->objecttype;
94
-    }
95
-
96
-    /**
97
-     * Summary of setObjectType
98
-     *
99
-     * @param string $objectType
100
-     */
101
-    public function setObjectType($objectType)
102
-    {
103
-        $this->objecttype = $objectType;
104
-    }
105
-
106
-    /**
107
-     * @return int
108
-     */
109
-    public function getUser()
110
-    {
111
-        return $this->user;
112
-    }
113
-
114
-    /**
115
-     * Summary of setUser
116
-     *
117
-     * @param User $user
118
-     */
119
-    public function setUser(User $user)
120
-    {
121
-        $this->user = $user->getId();
122
-    }
123
-
124
-    /**
125
-     * @return string
126
-     */
127
-    public function getAction()
128
-    {
129
-        return $this->action;
130
-    }
131
-
132
-    /**
133
-     * Summary of setAction
134
-     *
135
-     * @param string $action
136
-     */
137
-    public function setAction($action)
138
-    {
139
-        $this->action = $action;
140
-    }
141
-
142
-    /**
143
-     * @return DateTimeImmutable
144
-     */
145
-    public function getTimestamp()
146
-    {
147
-        return new DateTimeImmutable($this->timestamp);
148
-    }
149
-
150
-    /**
151
-     * @return string|null
152
-     */
153
-    public function getComment()
154
-    {
155
-        return $this->comment;
156
-    }
157
-
158
-    /**
159
-     * Summary of setComment
160
-     *
161
-     * @param string $comment
162
-     */
163
-    public function setComment($comment)
164
-    {
165
-        $this->comment = $comment;
166
-    }
42
+			);
43
+
44
+			$statement->bindValue(":id", $this->objectid);
45
+			$statement->bindValue(":type", $this->objecttype);
46
+			$statement->bindValue(":user", $this->user);
47
+			$statement->bindValue(":action", $this->action);
48
+			$statement->bindValue(":comment", $this->comment);
49
+
50
+			if ($statement->execute()) {
51
+				$this->id = (int)$this->dbObject->lastInsertId();
52
+			}
53
+			else {
54
+				throw new Exception($statement->errorInfo());
55
+			}
56
+		}
57
+		else {
58
+			throw new Exception("Updating logs is not available");
59
+		}
60
+	}
61
+
62
+	/**
63
+	 * @throws Exception
64
+	 */
65
+	public function delete()
66
+	{
67
+		throw new Exception("Deleting logs is not available.");
68
+	}
69
+
70
+	/**
71
+	 * @return int
72
+	 */
73
+	public function getObjectId()
74
+	{
75
+		return $this->objectid;
76
+	}
77
+
78
+	/**
79
+	 * Summary of setObjectId
80
+	 *
81
+	 * @param int $objectId
82
+	 */
83
+	public function setObjectId($objectId)
84
+	{
85
+		$this->objectid = $objectId;
86
+	}
87
+
88
+	/**
89
+	 * @return string
90
+	 */
91
+	public function getObjectType()
92
+	{
93
+		return $this->objecttype;
94
+	}
95
+
96
+	/**
97
+	 * Summary of setObjectType
98
+	 *
99
+	 * @param string $objectType
100
+	 */
101
+	public function setObjectType($objectType)
102
+	{
103
+		$this->objecttype = $objectType;
104
+	}
105
+
106
+	/**
107
+	 * @return int
108
+	 */
109
+	public function getUser()
110
+	{
111
+		return $this->user;
112
+	}
113
+
114
+	/**
115
+	 * Summary of setUser
116
+	 *
117
+	 * @param User $user
118
+	 */
119
+	public function setUser(User $user)
120
+	{
121
+		$this->user = $user->getId();
122
+	}
123
+
124
+	/**
125
+	 * @return string
126
+	 */
127
+	public function getAction()
128
+	{
129
+		return $this->action;
130
+	}
131
+
132
+	/**
133
+	 * Summary of setAction
134
+	 *
135
+	 * @param string $action
136
+	 */
137
+	public function setAction($action)
138
+	{
139
+		$this->action = $action;
140
+	}
141
+
142
+	/**
143
+	 * @return DateTimeImmutable
144
+	 */
145
+	public function getTimestamp()
146
+	{
147
+		return new DateTimeImmutable($this->timestamp);
148
+	}
149
+
150
+	/**
151
+	 * @return string|null
152
+	 */
153
+	public function getComment()
154
+	{
155
+		return $this->comment;
156
+	}
157
+
158
+	/**
159
+	 * Summary of setComment
160
+	 *
161
+	 * @param string $comment
162
+	 */
163
+	public function setComment($comment)
164
+	{
165
+		$this->comment = $comment;
166
+	}
167 167
 }
Please login to merge, or discard this patch.