BUGFIX: Let users without a specific TRANSLATE_ permission edit the default locale, so that things don't break when you install the Translatabe module.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97267 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-01-20 09:26:11 +00:00
parent 1526b8fc05
commit 1c851476b6
2 changed files with 8 additions and 2 deletions

View File

@ -129,7 +129,8 @@
*
* <h2>Permissions</h2>
*
* Authors without administrative access need special permissions.
* Authors without administrative access need special permissions to edit locales other than
* the default locale.
*
* - TRANSLATE_ALL: Translate into all locales
* - Translate_<locale>: Translate a specific locale. Only available for all locales set in
@ -1146,8 +1147,12 @@ class Translatable extends DataObjectDecorator implements PermissionProvider {
!is_array(self::get_allowed_locales())
|| in_array($locale, self::get_allowed_locales())
);
if(!$allowedLocale) return false;
// By default, anyone who can edit a page can edit the default locale
if($locale == self::default_locale()) return true;
// check for generic translation permission
if(Permission::checkMember($member, 'TRANSLATE_ALL')) return true;

View File

@ -89,7 +89,7 @@ class SiteTreeActionsTest extends FunctionalTest {
$page->CanEditType = 'LoggedInUsers';
$page->write();
$page->doPublish();
$actionsArr = $page->getCMSActions()->column('Name');
$this->assertContains('action_save',$actionsArr);
@ -116,6 +116,7 @@ class SiteTreeActionsTest extends FunctionalTest {
// Get the live version of the page
$page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
$this->assertType('SiteTree', $page);
$actionsArr = $page->getCMSActions()->column('Name');