-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWikiReadOnlyController.php
More file actions
45 lines (36 loc) · 1.24 KB
/
Copy pathWikiReadOnlyController.php
File metadata and controls
45 lines (36 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace App\Http\Controllers\Backend;
use App\Http\Controllers\Controller;
use App\Wiki;
use Illuminate\Http\Request;
class WikiReadOnlyController extends Controller {
public function setWikiReadOnly(Request $request) {
$validated = $request->validate([
'domain' => 'required|string',
'readOnly' => 'required|boolean',
]);
$domain = $validated['domain'];
$readOnly = $validated['readOnly'];
$wiki = Wiki::where('domain', $domain)->first();
if (!$wiki) {
return response()->json([
'error' => "Wiki not found for domain '$domain'",
], 404);
}
if ($readOnly) {
$wiki->setSetting('wgReadOnly', 'This wiki is currently read-only.');
return response()->json([
'success' => true,
'domain' => $domain,
'message' => 'Wiki set to read-only successfully.',
]);
} else {
$wiki->deleteSetting('wgReadOnly');
return response()->json([
'success' => true,
'domain' => $domain,
'message' => 'Read-only setting successfully removed for wiki.',
]);
}
}
}