← All changes
|
Modules/Migrations/Http/Controllers/BPMigrationController.php
+19
-5
2.5.0
→
2.10.0
View file →
| @@ -3,11 +3,8 @@ | ||
| 3 | 3 | namespace FluentCommunity\Modules\Migrations\Http\Controllers; |
| 4 | 4 | |
| 5 | 5 | use FluentCommunity\App\Functions\Utility; |
| 6 | 6 | use FluentCommunity\App\Http\Controllers\Controller; |
| 7 | -use FluentCommunity\App\Models\BaseSpace; | |
| 8 | -use FluentCommunity\App\Models\Space; | |
| 9 | -use FluentCommunity\App\Models\SpaceGroup; | |
| 10 | 7 | use FluentCommunity\App\Models\User; |
| 11 | 8 | use FluentCommunity\App\Services\Helper; |
| 12 | 9 | use FluentCommunity\Framework\Http\Request\Request; |
| 13 | 10 | use FluentCommunity\Framework\Support\Arr; |
| @@ -48,10 +45,27 @@ | ||
| 48 | 45 | } |
| 49 | 46 | |
| 50 | 47 | public function startMigration(Request $request) |
| 51 | 48 | { |
| 49 | + // Validate the destructive request before mutating anything, so a rejected request | |
| 50 | + // never clears saved migration progress. | |
| 51 | + if ($request->get('delete_current_data') === 'yes') { | |
| 52 | + if (!Helper::isSuperAdmin()) { | |
| 53 | + return $this->sendError([ | |
| 54 | + 'message' => __('You do not have permission to delete existing FluentCommunity data.', 'fluent-community') | |
| 55 | + ], 403); | |
| 56 | + } | |
| 57 | + | |
| 58 | + if ($request->get('delete_current_data_confirmation') !== 'DELETE') { | |
| 59 | + return $this->sendError([ | |
| 60 | + // translators: %s is the confirmation word the user must type (DELETE) | |
| 61 | + 'message' => sprintf(__('Please type %s to confirm permanently removing all existing FluentCommunity data.', 'fluent-community'), 'DELETE') | |
| 62 | + ]); | |
| 63 | + } | |
| 64 | + } | |
| 65 | + | |
| 52 | 66 | if ($request->get('reset_migration') === 'yes') { |
| 53 | - update_option('_fcom_bp_migrations_status', [], 'no'); | |
| 67 | + update_option('_fcom_bp_migrations_status', [], false); | |
| 54 | 68 | } |
| 55 | 69 | |
| 56 | 70 | if ($request->get('delete_current_data') === 'yes') { |
| 57 | 71 | $this->deleteCurrentData(); |
| @@ -332,9 +346,9 @@ | ||
| 332 | 346 | 'last_migrated_user_id', |
| 333 | 347 | 'current_stage' |
| 334 | 348 | ]); |
| 335 | 349 | |
| 336 | - update_option('_fcom_bp_migrations_status', $newData, 'no'); | |
| 350 | + update_option('_fcom_bp_migrations_status', $newData, false); | |
| 337 | 351 | |
| 338 | 352 | return $newData; |
| 339 | 353 | } |
| 340 | 354 | |