Skip to content

Commit

Permalink
Add ability to disable some extensions via config
Browse files Browse the repository at this point in the history
  • Loading branch information
purplespider committed Jul 10, 2020
1 parent 9038350 commit 68b1cd0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions code/extensions/CannotCreatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class CannotCreatePage extends DataExtension

public function canCreate($member = null, $context = array())
{
if ($config = $this->owner->config()->get('can_create')) {
return true;
}

return false;
}

Expand Down
10 changes: 6 additions & 4 deletions code/extensions/PageSettingsHidePermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ class PageSettingsHidePermissions extends DataExtension

public function updateSettingsFields(FieldList $fields)
{
$fields->removeFieldFromTab("Root.Settings", "CanViewType");
$fields->removeFieldFromTab("Root.Settings", "ViewerGroups");
$fields->removeFieldFromTab("Root.Settings", "CanEditType");
$fields->removeFieldFromTab("Root.Settings", "EditorGroups");
if (!$this->owner->config()->get('show_permissions')) {
$fields->removeFieldFromTab("Root.Settings", "CanViewType");
$fields->removeFieldFromTab("Root.Settings", "ViewerGroups");
$fields->removeFieldFromTab("Root.Settings", "CanEditType");
$fields->removeFieldFromTab("Root.Settings", "EditorGroups");
}
}
}

0 comments on commit 68b1cd0

Please sign in to comment.