PluginProbe
User Access Manager / 2.2.21
User Access Manager v2.2.21
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Controller/Backend/SetupController.php +79 -16 2.3.152.2.21 View file →
@@ -1,5 +1,18 @@
1 1 <?php
2 +/**
3 + * SetupController.php
4 + *
5 + * The SetupController class file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
2 15
3 16 declare(strict_types=1);
4 17
5 18 namespace UserAccessManager\Controller\Backend;
@@ -12,32 +25,61 @@
12 25 use UserAccessManager\UserAccessManager;
13 26 use UserAccessManager\Wrapper\Php;
14 27 use UserAccessManager\Wrapper\Wordpress;
15 28
29 +/**
30 + * Class SetupController
31 + *
32 + * @package UserAccessManager\Controller
33 + */
16 34 class SetupController extends Controller
17 35 {
18 - public const SETUP_UPDATE_NONCE = 'uamSetupUpdate';
19 - public const SETUP_REVERT_NONCE = 'uamSetupRevert';
20 - public const SETUP_REPAIR_NONCE = 'uamSetupRepair';
21 - public const SETUP_DELETE_BACKUP_NONCE = 'uamSetupDeleteBackup';
22 - public const SETUP_RESET_NONCE = 'uamSetupReset';
23 - public const UPDATE_BLOG = 'blog';
24 - public const UPDATE_NETWORK = 'network';
36 + const SETUP_UPDATE_NONCE = 'uamSetupUpdate';
37 + const SETUP_REVERT_NONCE = 'uamSetupRevert';
38 + const SETUP_REPAIR_NONCE = 'uamSetupRepair';
39 + const SETUP_DELETE_BACKUP_NONCE = 'uamSetupDeleteBackup';
40 + const SETUP_RESET_NONCE = 'uamSetupReset';
41 + const UPDATE_BLOG = 'blog';
42 + const UPDATE_NETWORK = 'network';
25 43
26 - protected ?string $template = 'AdminSetup.php';
44 + /**
45 + * @var string
46 + */
47 + protected $template = 'AdminSetup.php';
27 48
49 + /**
50 + * @var SetupHandler
51 + */
52 + private $setupHandler;
53 +
54 + /**
55 + * @var Database
56 + */
57 + private $database;
58 +
59 + /**
60 + * SetupController constructor.
61 + * @param Php $php
62 + * @param Wordpress $wordpress
63 + * @param WordpressConfig $wordpressConfig
64 + * @param Database $database
65 + * @param SetupHandler $setupHandler
66 + */
28 67 public function __construct(
29 68 Php $php,
30 69 Wordpress $wordpress,
31 70 WordpressConfig $wordpressConfig,
32 - private Database $database,
33 - private SetupHandler $setupHandler
71 + Database $database,
72 + SetupHandler $setupHandler
34 73 ) {
35 74 parent::__construct($php, $wordpress, $wordpressConfig);
75 + $this->database = $database;
76 + $this->setupHandler = $setupHandler;
36 77 }
37 78
38 79 /**
39 - * @throws MissingColumnsException
80 + * Returns if a database update is necessary.
81 + * @return bool
40 82 */
41 83 public function isDatabaseUpdateNecessary(): bool
42 84 {
43 85 return $this->setupHandler->getDatabaseHandler()->isDatabaseUpdateNecessary();
@@ -42,8 +84,12 @@
42 84 {
43 85 return $this->setupHandler->getDatabaseHandler()->isDatabaseUpdateNecessary();
44 86 }
45 87
88 + /**
89 + * Checks if a network update is nessary.
90 + * @return bool
91 + */
46 92 public function showNetworkUpdate(): bool
47 93 {
48 94 return $this->wordpress->isSuperAdmin() === true
49 95 && defined('MULTISITE') === true && MULTISITE === true
@@ -49,14 +95,21 @@
49 95 && defined('MULTISITE') === true && MULTISITE === true
50 96 && defined('WP_ALLOW_MULTISITE') === true && WP_ALLOW_MULTISITE === true;
51 97 }
52 98
99 + /**
100 + * Returns the existing backups
101 + * @return array
102 + */
53 103 public function getBackups(): array
54 104 {
55 105 return $this->setupHandler->getDatabaseHandler()->getBackups();
56 106 }
57 107
58 - public function updateDatabaseAction(): void
108 + /**
109 + * The database update action.
110 + */
111 + public function updateDatabaseAction()
59 112 {
60 113 $success = true;
61 114 $this->verifyNonce(self::SETUP_UPDATE_NONCE);
62 115 $update = $this->getRequestParameter('uam_update_db');
@@ -81,9 +134,12 @@
81 134 $this->setUpdateMessage($message);
82 135 }
83 136 }
84 137
85 - public function revertDatabaseAction(): void
138 + /**
139 + * Reverts the database to the given version.
140 + */
141 + public function revertDatabaseAction()
86 142 {
87 143 $this->verifyNonce(self::SETUP_REVERT_NONCE);
88 144 $version = $this->getRequestParameter('uam_revert_database');
89 145
@@ -92,8 +148,10 @@
92 148 }
93 149 }
94 150
95 151 /**
152 + * Checks if the database is broken.
153 + * @return bool
96 154 * @throws MissingColumnsException
97 155 */
98 156 public function isDatabaseBroken(): bool
99 157 {
@@ -110,11 +168,12 @@
110 168 return $numberOfIssues > 0;
111 169 }
112 170
113 171 /**
172 + * Repairs the database.
114 173 * @throws MissingColumnsException
115 174 */
116 - public function repairDatabaseAction(): void
175 + public function repairDatabaseAction()
117 176 {
118 177 $this->verifyNonce(self::SETUP_REPAIR_NONCE);
119 178
120 179 $databaseHandler = $this->setupHandler->getDatabaseHandler();
@@ -129,9 +188,12 @@
129 188 $this->wordpress->updateOption('uam_db_version', UserAccessManager::DB_VERSION);
130 189 }
131 190 }
132 191
133 - public function deleteDatabaseBackupAction(): void
192 + /**
193 + * Deletes the given database backup.
194 + */
195 + public function deleteDatabaseBackupAction()
134 196 {
135 197 $this->verifyNonce(self::SETUP_DELETE_BACKUP_NONCE);
136 198 $version = (string) $this->getRequestParameter('uam_delete_backup');
137 199
@@ -140,11 +202,12 @@
140 202 }
141 203 }
142 204
143 205 /**
206 + * The reset action.
144 207 * @throws MissingColumnsException
145 208 */
146 - public function resetUamAction(): void
209 + public function resetUamAction()
147 210 {
148 211 $this->verifyNonce(self::SETUP_RESET_NONCE);
149 212 $reset = $this->getRequestParameter('uam_reset');
150 213