Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cms 660 show read-only settings when allowAdminChanges is disabled #16265

Open
wants to merge 27 commits into
base: 5.6
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
829c9e3
switch revision notice to a generic class
i-just Dec 3, 2024
c2f10a7
show settings > system items in readOnly mode
i-just Dec 3, 2024
429121b
no need for a new method...
i-just Dec 3, 2024
e8b7b0b
show user profile fields but disabled
i-just Dec 3, 2024
e0e4952
show settings > content items in readOnly mode
i-just Dec 3, 2024
f3b4dcb
show settings > media items in readOnly mode
i-just Dec 3, 2024
c51a748
handle settings > plugins in readOnly mode
i-just Dec 3, 2024
5db7e2d
translation & notice on the main settings page
i-just Dec 3, 2024
d01af67
build
i-just Dec 3, 2024
f529d67
missed notices
i-just Dec 3, 2024
839637d
Merge remote-tracking branch 'origin/5.6' into feature/cms-660-show-r…
i-just Dec 3, 2024
e9c504e
email settings > site overrides read only
i-just Dec 3, 2024
55c2803
twig require admin node and token parser updates
i-just Dec 4, 2024
7560a1d
Merge branch '5.6' into feature/cms-660-show-read-only-settings-when-…
i-just Dec 4, 2024
8897d9a
missed from the merge
i-just Dec 4, 2024
9310f99
updated notice wording
i-just Dec 6, 2024
0f6338e
Merge branch '5.6' into feature/cms-660-show-read-only-settings-when-…
i-just Dec 6, 2024
0555a75
add disabled attr to the lightswitch field
i-just Dec 9, 2024
0c6399e
disabled attr for the .menubtn
i-just Dec 9, 2024
68a9b80
adds readOnlySettingsReady method to the transport adapters
i-just Dec 9, 2024
9e40f04
bug fix
i-just Dec 9, 2024
1ffd021
added Field->readOnlySettingsReady()
i-just Dec 9, 2024
099d6bd
disabled field layout designer shouldn't be keyboard focusable
i-just Dec 9, 2024
8327c21
added Fs->readOnlySettingsReady()
i-just Dec 9, 2024
0dedce3
Merge branch '5.6' into feature/cms-660-show-read-only-settings-when-…
i-just Dec 9, 2024
a77ad09
Merge branch '5.6' into feature/cms-660-show-read-only-settings-when-…
brandonkelly Dec 11, 2024
3db71f9
Merge branch '5.6' into feature/cms-660-show-read-only-settings-when-…
brandonkelly Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
no need for a new method...
i-just committed Dec 3, 2024
commit 429121ba5501010cc01317a7331cefea98f733d8
12 changes: 6 additions & 6 deletions src/controllers/SitesController.php
Original file line number Diff line number Diff line change
@@ -43,13 +43,13 @@ public function beforeAction($action): bool
return false;
}

// All actions require an admin account (but not allowAdminChanges)
$this->requireAdmin(false);

$viewActions = ['settings-index', 'edit-site'];
// Most actions then require allowAdminChanges
if (!in_array($action->id, $viewActions)) {
$this->requireAdminChanges();
if (in_array($action->id, $viewActions)) {
// Some actions require admin but not allowAdminChanges
$this->requireAdmin(false);
} else {
// All other actions require an admin & allowAdminChanges
$this->requireAdmin();
}

$this->readOnly = !Craft::$app->getConfig()->getGeneral()->allowAdminChanges;
12 changes: 6 additions & 6 deletions src/controllers/SystemSettingsController.php
Original file line number Diff line number Diff line change
@@ -49,13 +49,13 @@ public function beforeAction($action): bool
return false;
}

// All actions require an admin account (but not allowAdminChanges)
$this->requireAdmin(false);

$viewActions = ['general-settings', 'edit-email-settings', 'global-set-index', 'edit-global-set'];
// Most actions then require allowAdminChanges
if (!in_array($action->id, $viewActions)) {
$this->requireAdminChanges();
if (in_array($action->id, $viewActions)) {
// Some actions require admin but not allowAdminChanges
$this->requireAdmin(false);
} else {
// All other actions require an admin & allowAdminChanges
$this->requireAdmin();
}

$this->readOnly = !Craft::$app->getConfig()->getGeneral()->allowAdminChanges;
11 changes: 6 additions & 5 deletions src/controllers/UserSettingsController.php
Original file line number Diff line number Diff line change
@@ -36,13 +36,14 @@ public function beforeAction($action): bool
return false;
}

// All actions require an admin account (but not allowAdminChanges)
$this->requireAdmin(false);

$viewActions = ['edit-group'];
// Most actions then require allowAdminChanges
if (!in_array($action->id, $viewActions)) {
$this->requireAdminChanges();
if (in_array($action->id, $viewActions)) {
// Some actions require admin but not allowAdminChanges
$this->requireAdmin(false);
} else {
// All other actions require an admin & allowAdminChanges
$this->requireAdmin();
}

$this->readOnly = !Craft::$app->getConfig()->getGeneral()->allowAdminChanges;
15 changes: 1 addition & 14 deletions src/web/Controller.php
Original file line number Diff line number Diff line change
@@ -493,20 +493,7 @@ public function requireAdmin(bool $requireAdminChanges = true): void
}

// Make sure admin changes are allowed
if ($requireAdminChanges) {
$this->requireAdminChanges();
}
}

/**
* Throws a 403 error if the <config5:allowAdminChanges> config setting is disabled.
*
* @throws ForbiddenHttpException if the current user is not an admin
*/
protected function requireAdminChanges(): void
{
// Make sure admin changes are allowed
if (!Craft::$app->getConfig()->getGeneral()->allowAdminChanges) {
if ($requireAdminChanges && !Craft::$app->getConfig()->getGeneral()->allowAdminChanges) {
throw new ForbiddenHttpException('Administrative changes are disallowed in this environment.');
}
}