mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Merge branch '2.0' into 2.1
This commit is contained in:
commit
9655371276
10
.travis.yml
10
.travis.yml
@ -17,13 +17,13 @@ env:
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.0.x-dev PHPCS_TEST=1 PHPUNIT_TEST=1
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.3.x-dev PHPCS_TEST=1 PHPUNIT_TEST=1
|
||||
- php: 7.0
|
||||
env: DB=PGSQL INSTALLER_VERSION=4.1.x-dev PHPUNIT_TEST=1
|
||||
env: DB=PGSQL INSTALLER_VERSION=4.3.x-dev PHPUNIT_TEST=1
|
||||
- php: 7.1
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.1.x-dev BEHAT_TEST=1
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.3.x-dev BEHAT_TEST=1
|
||||
- php: 7.2
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.2.x-dev PHPUNIT_COVERAGE_TEST=1
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.3.x-dev PHPUNIT_COVERAGE_TEST=1
|
||||
- php: 7.2
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.x-dev BEHAT_TEST=1
|
||||
|
||||
@ -39,7 +39,7 @@ before_script:
|
||||
# Install composer
|
||||
- composer validate
|
||||
- composer require silverstripe/installer:"$INSTALLER_VERSION" silverstripe/recipe-testing:^1 --no-update
|
||||
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.0.x-dev; fi
|
||||
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.1.x-dev; fi
|
||||
- composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
||||
|
||||
# Behat bootstrapping
|
||||
|
@ -215,11 +215,16 @@ class LeftAndMainSubsites extends LeftAndMainExtension
|
||||
|
||||
/**
|
||||
* Check if the current controller is accessible for this user on this subsite.
|
||||
*
|
||||
* @param Member $member
|
||||
*/
|
||||
public function canAccess()
|
||||
public function canAccess(Member $member = null)
|
||||
{
|
||||
if (!$member) {
|
||||
$member = Security::getCurrentUser();
|
||||
}
|
||||
|
||||
// Admin can access everything, no point in checking.
|
||||
$member = Security::getCurrentUser();
|
||||
if ($member
|
||||
&& (Permission::checkMember($member, 'ADMIN') // 'Full administrative rights'
|
||||
|| Permission::checkMember($member, 'CMS_ACCESS_LeftAndMain') // 'Access to all CMS sections'
|
||||
@ -236,10 +241,12 @@ class LeftAndMainSubsites extends LeftAndMainExtension
|
||||
/**
|
||||
* Prevent accessing disallowed resources. This happens after onBeforeInit has executed,
|
||||
* so all redirections should've already taken place.
|
||||
*
|
||||
* @param Member $member
|
||||
*/
|
||||
public function alternateAccessCheck()
|
||||
public function alternateAccessCheck(Member $member = null)
|
||||
{
|
||||
return $this->owner->canAccess();
|
||||
return $this->owner->canAccess($member);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,6 +9,7 @@ use SilverStripe\CMS\Controllers\CMSPageEditController;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Subsites\Extensions\LeftAndMainSubsites;
|
||||
use SilverStripe\Subsites\Model\Subsite;
|
||||
use SilverStripe\Subsites\State\SubsiteState;
|
||||
|
||||
@ -100,4 +101,14 @@ class LeftAndMainSubsitesTest extends FunctionalTest
|
||||
$this->assertTrue($l->shouldChangeSubsite(CMSPageEditController::class, 1, 5));
|
||||
$this->assertFalse($l->shouldChangeSubsite(CMSPageEditController::class, 1, 1));
|
||||
}
|
||||
|
||||
public function testCanAccessWithPassedMember()
|
||||
{
|
||||
$memberID = $this->logInWithPermission('ADMIN');
|
||||
$member = Member::get()->byID($memberID);
|
||||
|
||||
/** @var LeftAndMain&LeftAndMainSubsites $leftAndMain */
|
||||
$leftAndMain = new LeftAndMain();
|
||||
$this->assertTrue($leftAndMain->canAccess($member));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user