From 81bd4c102e6267e4ba33ab600ff9dd9206275f78 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Sat, 11 Dec 2010 05:45:04 +0000 Subject: [PATCH] MINOR: restored SiteConfig functions git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@114822 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteConfig.php | 49 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/core/model/SiteConfig.php b/core/model/SiteConfig.php index b94492c6a..36d85de95 100644 --- a/core/model/SiteConfig.php +++ b/core/model/SiteConfig.php @@ -14,7 +14,6 @@ * @package cms */ class SiteConfig extends DataObject implements PermissionProvider { - static $db = array( "Title" => "Varchar(255)", "Tagline" => "Varchar(255)", @@ -51,11 +50,57 @@ class SiteConfig extends DataObject implements PermissionProvider { new DropdownField("Theme", _t('SiteConfig.THEME', 'Theme'), $this->getAvailableThemes(), '', null, _t('SiteConfig.DEFAULTTHEME', '(Use default theme)')) ), new Tab('Access', - new HeaderField('WhoCanViewHeader', _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?"), 2) + new HeaderField('WhoCanViewHeader', _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?"), 2), + $viewersOptionsField = new OptionsetField("CanViewType"), + $viewerGroupsField = new TreeMultiselectField("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups")), + new HeaderField('WhoCanEditHeader', _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?"), 2), + $editorsOptionsField = new OptionsetField("CanEditType"), + $editorGroupsField = new TreeMultiselectField("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups")), + new HeaderField('WhoCanCreateTopLevelHeader', _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?"), 2), + $topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType"), + $topLevelCreatorsGroupsField = new TreeMultiselectField("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators")) ) ) ); + + $viewersOptionsSource = array(); + $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone"); + $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users"); + $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)"); + $viewersOptionsField->setSource($viewersOptionsSource); + + $editorsOptionsSource = array(); + $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS"); + $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)"); + $editorsOptionsField->setSource($editorsOptionsSource); + + $topLevelCreatorsOptionsField->setSource($editorsOptionsSource); + + // Translatable doesn't handle updateCMSFields on DataObjects, + // so add it here to save the current Locale, + // because onBeforeWrite does not work. + if(Object::has_extension('SiteConfig',"Translatable")){ + $fields->push(new HiddenField("Locale")); + } + if (!Permission::check('EDIT_SITECONFIG')) { + $fields->makeFieldReadonly($viewersOptionsField); + $fields->makeFieldReadonly($viewerGroupsField); + $fields->makeFieldReadonly($editorsOptionsField); + $fields->makeFieldReadonly($editorGroupsField); + $fields->makeFieldReadonly($topLevelCreatorsOptionsField); + $fields->makeFieldReadonly($topLevelCreatorsGroupsField); + $fields->makeFieldReadonly($taglineField); + $fields->makeFieldReadonly($titleField); + } + + if(file_exists(BASE_PATH . '/install.php')) { + $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader", + "

" . _t("SiteTree.REMOVE_INSTALL_WARNING", + "Warning: You should remove install.php from this SilverStripe install for security reasons.") + . "

"), "Title"); + } + $this->extend('updateCMSFields', $fields); return $fields;