|
1
|
|
|
<?php |
|
2
|
|
|
/****************************************************************************** |
|
3
|
|
|
* Wikipedia Account Creation Assistance tool * |
|
4
|
|
|
* * |
|
5
|
|
|
* All code in this file is released into the public domain by the ACC * |
|
6
|
|
|
* Development Team. Please see team.json for a list of contributors. * |
|
7
|
|
|
******************************************************************************/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Waca\DataObjects; |
|
10
|
|
|
|
|
11
|
|
|
use Exception; |
|
12
|
|
|
use Waca\DataObject; |
|
13
|
|
|
use Waca\Exceptions\OptimisticLockFailedException; |
|
14
|
|
|
|
|
15
|
|
|
class RequestQueue extends DataObject |
|
16
|
|
|
{ |
|
17
|
|
|
/** @var int */ |
|
18
|
|
|
private $enabled = 0; |
|
19
|
|
|
/** @var int */ |
|
20
|
|
|
private $isdefault = 0; |
|
21
|
|
|
/** @var int */ |
|
22
|
|
|
private $defaultantispoof = 0; |
|
23
|
|
|
/** @var int */ |
|
24
|
|
|
private $defaulttitleblacklist = 0; |
|
25
|
|
|
/** @var int */ |
|
26
|
|
|
private $domain; |
|
27
|
|
|
/** @var string */ |
|
28
|
|
|
private $apiname; |
|
29
|
|
|
/** @var string */ |
|
30
|
|
|
private $displayname; |
|
31
|
|
|
/** @var string */ |
|
32
|
|
|
private $header; |
|
33
|
|
|
/** @var string|null */ |
|
34
|
|
|
private $help; |
|
35
|
|
|
/** |
|
36
|
|
|
* @var string |
|
37
|
|
|
* @deprecated Removal due as part of #607 |
|
38
|
|
|
*/ |
|
39
|
|
|
private $logname; |
|
40
|
|
|
/** |
|
41
|
|
|
* @var string |
|
42
|
|
|
* @deprecated Removal due as part of #602 |
|
43
|
|
|
*/ |
|
44
|
|
|
private $legacystatus; |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
public function save() |
|
48
|
|
|
{ |
|
49
|
|
|
if ($this->isNew()) { |
|
50
|
|
|
// insert |
|
51
|
|
|
$statement = $this->dbObject->prepare(<<<SQL |
|
52
|
|
|
INSERT INTO requestqueue ( |
|
53
|
|
|
enabled, isdefault, defaultantispoof, defaulttitleblacklist, domain, apiname, displayname, header, help, logname, legacystatus |
|
54
|
|
|
) VALUES ( |
|
55
|
|
|
:enabled, :isdefault, :defaultantispoof, :defaulttitleblacklist, :domain, :apiname, :displayname, :header, :help, :logname, :legacystatus |
|
56
|
|
|
); |
|
57
|
|
|
SQL |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
$statement->bindValue(":enabled", $this->enabled); |
|
61
|
|
|
$statement->bindValue(":isdefault", $this->isdefault); |
|
62
|
|
|
$statement->bindValue(":defaultantispoof", $this->defaultantispoof); |
|
63
|
|
|
$statement->bindValue(":defaulttitleblacklist", $this->defaulttitleblacklist); |
|
64
|
|
|
$statement->bindValue(":domain", $this->domain); |
|
65
|
|
|
$statement->bindValue(":apiname", $this->apiname); |
|
66
|
|
|
$statement->bindValue(":displayname", $this->displayname); |
|
67
|
|
|
$statement->bindValue(":header", $this->header); |
|
68
|
|
|
$statement->bindValue(":help", $this->help); |
|
69
|
|
|
$statement->bindValue(":logname", $this->logname); |
|
|
|
|
|
|
70
|
|
|
$statement->bindValue(":legacystatus", $this->legacystatus); |
|
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
if ($statement->execute()) { |
|
73
|
|
|
$this->id = (int)$this->dbObject->lastInsertId(); |
|
74
|
|
|
} |
|
75
|
|
|
else { |
|
76
|
|
|
throw new Exception($statement->errorInfo()); |
|
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
else { |
|
80
|
|
|
$statement = $this->dbObject->prepare(<<<SQL |
|
81
|
|
|
UPDATE requestqueue SET |
|
82
|
|
|
enabled = :enabled, |
|
83
|
|
|
isdefault = :isdefault, |
|
84
|
|
|
defaultantispoof = :defaultantispoof, |
|
85
|
|
|
defaulttitleblacklist = :defaulttitleblacklist, |
|
86
|
|
|
domain = :domain, |
|
87
|
|
|
apiname = :apiname, |
|
88
|
|
|
displayname = :displayname, |
|
89
|
|
|
header = :header, |
|
90
|
|
|
help = :help, |
|
91
|
|
|
logname = :logname, |
|
92
|
|
|
legacystatus = :legacystatus, |
|
93
|
|
|
|
|
94
|
|
|
updateversion = updateversion + 1 |
|
95
|
|
|
WHERE id = :id AND updateversion = :updateversion; |
|
96
|
|
|
SQL |
|
97
|
|
|
); |
|
98
|
|
|
|
|
99
|
|
|
$statement->bindValue(":enabled", $this->enabled); |
|
100
|
|
|
$statement->bindValue(":isdefault", $this->isdefault); |
|
101
|
|
|
$statement->bindValue(":defaultantispoof", $this->defaultantispoof); |
|
102
|
|
|
$statement->bindValue(":defaulttitleblacklist", $this->defaulttitleblacklist); |
|
103
|
|
|
$statement->bindValue(":domain", $this->domain); |
|
104
|
|
|
$statement->bindValue(":apiname", $this->apiname); |
|
105
|
|
|
$statement->bindValue(":displayname", $this->displayname); |
|
106
|
|
|
$statement->bindValue(":header", $this->header); |
|
107
|
|
|
$statement->bindValue(":help", $this->help); |
|
108
|
|
|
$statement->bindValue(":logname", $this->logname); |
|
|
|
|
|
|
109
|
|
|
$statement->bindValue(":legacystatus", $this->legacystatus); |
|
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
$statement->bindValue(':id', $this->id); |
|
112
|
|
|
$statement->bindValue(':updateversion', $this->updateversion); |
|
113
|
|
|
|
|
114
|
|
|
if (!$statement->execute()) { |
|
115
|
|
|
throw new Exception($statement->errorInfo()); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
if ($statement->rowCount() !== 1) { |
|
119
|
|
|
throw new OptimisticLockFailedException(); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
$this->updateversion++; |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @return bool |
|
128
|
|
|
*/ |
|
129
|
|
|
public function isEnabled(): bool |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->enabled == 1; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @param bool $enabled |
|
136
|
|
|
*/ |
|
137
|
|
|
public function setEnabled(bool $enabled): void |
|
138
|
|
|
{ |
|
139
|
|
|
$this->enabled = $enabled ? 1 : 0; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @return bool |
|
144
|
|
|
*/ |
|
145
|
|
|
public function isDefault(): bool |
|
146
|
|
|
{ |
|
147
|
|
|
return $this->isdefault == 1; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @param bool $isDefault |
|
152
|
|
|
*/ |
|
153
|
|
|
public function setDefault(bool $isDefault): void |
|
154
|
|
|
{ |
|
155
|
|
|
$this->isdefault = $isDefault ? 1 : 0; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @return bool |
|
160
|
|
|
*/ |
|
161
|
|
|
public function isDefaultAntispoof(): bool |
|
162
|
|
|
{ |
|
163
|
|
|
return $this->defaultantispoof == 1; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @param bool $isDefault |
|
168
|
|
|
*/ |
|
169
|
|
|
public function setDefaultAntispoof(bool $isDefault): void |
|
170
|
|
|
{ |
|
171
|
|
|
$this->defaultantispoof = $isDefault ? 1 : 0; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* @return bool |
|
176
|
|
|
*/ |
|
177
|
|
|
public function isDefaultTitleBlacklist(): bool |
|
178
|
|
|
{ |
|
179
|
|
|
return $this->defaulttitleblacklist == 1; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* @param bool $isDefault |
|
184
|
|
|
*/ |
|
185
|
|
|
public function setDefaultTitleBlacklist(bool $isDefault): void |
|
186
|
|
|
{ |
|
187
|
|
|
$this->defaulttitleblacklist = $isDefault ? 1 : 0; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* @return int |
|
192
|
|
|
*/ |
|
193
|
|
|
public function getDomain(): int |
|
194
|
|
|
{ |
|
195
|
|
|
return $this->domain; |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* @param int $domain |
|
200
|
|
|
*/ |
|
201
|
|
|
public function setDomain(int $domain): void |
|
202
|
|
|
{ |
|
203
|
|
|
$this->domain = $domain; |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* @return string |
|
208
|
|
|
*/ |
|
209
|
|
|
public function getApiName(): string |
|
210
|
|
|
{ |
|
211
|
|
|
return $this->apiname; |
|
212
|
|
|
} |
|
213
|
|
|
|
|
214
|
|
|
/** |
|
215
|
|
|
* @param string $apiName |
|
216
|
|
|
*/ |
|
217
|
|
|
public function setApiName(string $apiName): void |
|
218
|
|
|
{ |
|
219
|
|
|
$this->apiname = $apiName; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
/** |
|
223
|
|
|
* @return string |
|
224
|
|
|
*/ |
|
225
|
|
|
public function getDisplayName(): string |
|
226
|
|
|
{ |
|
227
|
|
|
return $this->displayname; |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
/** |
|
231
|
|
|
* @param string $displayName |
|
232
|
|
|
*/ |
|
233
|
|
|
public function setDisplayName(string $displayName): void |
|
234
|
|
|
{ |
|
235
|
|
|
$this->displayname = $displayName; |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
/** |
|
239
|
|
|
* @return string |
|
240
|
|
|
*/ |
|
241
|
|
|
public function getHeader(): string |
|
242
|
|
|
{ |
|
243
|
|
|
return $this->header; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* @param string $header |
|
248
|
|
|
*/ |
|
249
|
|
|
public function setHeader(string $header): void |
|
250
|
|
|
{ |
|
251
|
|
|
$this->header = $header; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* @return string|null |
|
256
|
|
|
*/ |
|
257
|
|
|
public function getHelp(): ?string |
|
258
|
|
|
{ |
|
259
|
|
|
return $this->help; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* @param string|null $help |
|
264
|
|
|
*/ |
|
265
|
|
|
public function setHelp(?string $help): void |
|
266
|
|
|
{ |
|
267
|
|
|
$this->help = $help; |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
/** |
|
271
|
|
|
* @return string |
|
272
|
|
|
* @deprecated |
|
273
|
|
|
*/ |
|
274
|
|
|
public function getLogName(): string |
|
275
|
|
|
{ |
|
276
|
|
|
return $this->logname; |
|
|
|
|
|
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
/** |
|
280
|
|
|
* @param string $logName |
|
281
|
|
|
* |
|
282
|
|
|
* @deprecated |
|
283
|
|
|
*/ |
|
284
|
|
|
public function setLogName(string $logName): void |
|
285
|
|
|
{ |
|
286
|
|
|
$this->logname = $logName; |
|
|
|
|
|
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* @return string |
|
291
|
|
|
* @deprecated |
|
292
|
|
|
*/ |
|
293
|
|
|
public function getLegacyStatus(): string |
|
294
|
|
|
{ |
|
295
|
|
|
return $this->legacystatus; |
|
|
|
|
|
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* @param string $legacyStatus |
|
300
|
|
|
* |
|
301
|
|
|
* @deprecated |
|
302
|
|
|
*/ |
|
303
|
|
|
public function setLegacyStatus(string $legacyStatus): void |
|
304
|
|
|
{ |
|
305
|
|
|
$this->legacystatus = $legacyStatus; |
|
|
|
|
|
|
306
|
|
|
} |
|
307
|
|
|
} |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.