diff --git a/.travis.yml b/.travis.yml index 873913f6..8f6adc0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ before_script: - cd ~/builds/ss script: - - phpunit cms/tests + - vendor/bin/phpunit cms/tests branches: except: diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php index 03847567..e871a7d3 100644 --- a/code/SecurityAdmin.php +++ b/code/SecurityAdmin.php @@ -70,16 +70,20 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { $fields = $record->getCMSFields(); if($fields->hasTabSet()) { - $fields->findOrMakeTab('Root.Import',_t('Group.IMPORTTABTITLE', 'Import')); - $fields->addFieldToTab('Root.Import', - new LiteralField( - 'MemberImportFormIframe', - sprintf( - '', - $this->Link('memberimport') + // Add import capabilities. Limit to admin since the import logic can affect assigned permissions + if(Permission::check('ADMIN')) { + $fields->findOrMakeTab('Root.Import',_t('Group.IMPORTTABTITLE', 'Import')); + $fields->addFieldToTab('Root.Import', + new LiteralField( + 'MemberImportFormIframe', + sprintf( + '', + $this->Link('memberimport') + ) ) - ) - ); + ); + } + if(Permission::check('APPLY_ROLES')) { $fields->addFieldToTab( 'Root.Roles', @@ -147,8 +151,19 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { ) ) ) - ), - new Tab('Import', _t('SecurityAdmin.TABIMPORT', 'Import'), + ) + ), + // necessary for tree node selection in LeftAndMain.EditForm.js + new HiddenField('ID', false, 0) + ); + + // Add import capabilities. Limit to admin since the import logic can affect assigned permissions + if(Permission::check('ADMIN')) { + $fields->addFieldsToTab( + 'Root', + new Tab( + 'Import', + _t('SecurityAdmin.TABIMPORT', 'Import'), new LiteralField( 'GroupImportFormIframe', sprintf( @@ -157,10 +172,8 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { ) ) ) - ), - // necessary for tree node selection in LeftAndMain.EditForm.js - new HiddenField('ID', false, 0) - ); + ); + } // Add roles editing interface if(Permission::check('APPLY_ROLES')) { @@ -217,6 +230,8 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { * @return Form */ public function MemberImportForm() { + if(!Permission::check('ADMIN')) return false; + $group = $this->currentPage(); $form = new MemberImportForm( $this, @@ -249,6 +264,8 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { * @return Form */ public function GroupImportForm() { + if(!Permission::check('ADMIN')) return false; + $form = new GroupImportForm( $this, 'GroupImportForm' diff --git a/composer.json b/composer.json index 9b7ca40a..404ab830 100644 --- a/composer.json +++ b/composer.json @@ -23,5 +23,9 @@ "extra": { "branch-alias": { "dev-post-2.4": "2.5.x-dev" + } + }, + "require-dev": { + "phpunit/PHPUnit": "~3.7" } -}} +}