|
1
|
|
|
<?php |
|
2
|
|
|
/****************************************************************************** |
|
3
|
|
|
* Wikipedia Account Creation Assistance tool * |
|
4
|
|
|
* ACC Development Team. Please see team.json for a list of contributors. * |
|
5
|
|
|
* * |
|
6
|
|
|
* This is free and unencumbered software released into the public domain. * |
|
7
|
|
|
* Please see LICENSE.md for the full licencing statement. * |
|
8
|
|
|
******************************************************************************/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Waca\Pages\UserAuth; |
|
11
|
|
|
|
|
12
|
|
|
use Exception; |
|
13
|
|
|
use Waca\DataObjects\Domain; |
|
14
|
|
|
use Waca\DataObjects\User; |
|
15
|
|
|
use Waca\Exceptions\ApplicationLogicException; |
|
16
|
|
|
use Waca\Fragments\LogEntryLookup; |
|
17
|
|
|
use Waca\Helpers\Logger; |
|
18
|
|
|
use Waca\Helpers\PreferenceManager; |
|
19
|
|
|
use Waca\SessionAlert; |
|
20
|
|
|
use Waca\Tasks\InternalPageBase; |
|
21
|
|
|
use Waca\WebRequest; |
|
22
|
|
|
|
|
23
|
|
|
class PageUserReactivate extends InternalPageBase |
|
24
|
|
|
{ |
|
25
|
|
|
use LogEntryLookup; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @throws ApplicationLogicException |
|
29
|
|
|
* @throws Exception |
|
30
|
|
|
*/ |
|
31
|
|
|
protected function main() |
|
32
|
|
|
{ |
|
33
|
|
|
$db = $this->getDatabase(); |
|
34
|
|
|
$currentUser = User::getCurrent($db); |
|
35
|
|
|
|
|
36
|
|
|
// *Only* deactivated users should be able to access this. |
|
37
|
|
|
// Redirect anyone else away. |
|
38
|
|
|
if (!$currentUser->isDeactivated()) { |
|
39
|
|
|
$this->redirect(); |
|
40
|
|
|
return; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
$ableToAppeal = true; |
|
44
|
|
|
$prefs = new PreferenceManager($db, $currentUser->getId(), Domain::getCurrent($db)->getId()); |
|
45
|
|
|
if ($prefs->getPreference(PreferenceManager::ADMIN_PREF_PREVENT_REACTIVATION) ?? false) { |
|
46
|
|
|
$ableToAppeal = false; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
if (WebRequest::wasPosted()) { |
|
50
|
|
|
$this->validateCSRFToken(); |
|
51
|
|
|
|
|
52
|
|
|
$reason = WebRequest::postString('reason'); |
|
53
|
|
|
$updateVersion = WebRequest::postInt('updateVersion'); |
|
54
|
|
|
|
|
55
|
|
|
if (!$ableToAppeal) { |
|
56
|
|
|
throw new ApplicationLogicException('Appeal is disabled'); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
if ($reason === null || trim($reason) === '') { |
|
60
|
|
|
throw new ApplicationLogicException('The reason field cannot be empty.'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
Logger::requestedReactivation($db, $currentUser, $reason); |
|
64
|
|
|
$currentUser->setStatus(User::STATUS_NEW); |
|
65
|
|
|
$currentUser->setUpdateVersion($updateVersion); |
|
66
|
|
|
$currentUser->save(); |
|
67
|
|
|
|
|
68
|
|
|
SessionAlert::success('Reactivation request has been saved. Please wait for a response from the tool admin team.'); |
|
69
|
|
|
$this->redirect(); |
|
70
|
|
|
} |
|
71
|
|
|
else { |
|
72
|
|
|
$this->assignCSRFToken(); |
|
73
|
|
|
$this->assign('deactivationReason', $this->getLogEntry('DeactivatedUser', $currentUser, $db)); |
|
74
|
|
|
$this->assign('updateVersion', $currentUser->getUpdateVersion()); |
|
75
|
|
|
$this->assign('ableToAppeal', $ableToAppeal); |
|
76
|
|
|
$this->setTemplate('reactivate.tpl'); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
} |