diff --git a/src/Extensions/GroupSubsites.php b/src/Extensions/GroupSubsites.php index 0e4921e..2d138b4 100644 --- a/src/Extensions/GroupSubsites.php +++ b/src/Extensions/GroupSubsites.php @@ -187,7 +187,8 @@ class GroupSubsites extends DataExtension implements PermissionProvider } } - // WORKAROUND for databases that complain about an ORDER BY when the column wasn't selected (e.g. SQL Server) + // WORKAROUND for databases that complain about an ORDER BY when the column wasn't selected + // (e.g. SQL Server) $select = $query->getSelect(); if (isset($select[0]) && !$select[0] == 'COUNT(*)') { $query->addOrderBy('AccessAllSubsites', 'DESC'); @@ -230,7 +231,10 @@ class GroupSubsites extends DataExtension implements PermissionProvider return [ 'SECURITY_SUBSITE_GROUP' => [ 'name' => _t(__CLASS__ . '.MANAGE_SUBSITES', 'Manage subsites for groups'), - 'category' => _t('SilverStripe\\Security\\Permission.PERMISSIONS_CATEGORY', 'Roles and access permissions'), + 'category' => _t( + 'SilverStripe\\Security\\Permission.PERMISSIONS_CATEGORY', + 'Roles and access permissions' + ), 'help' => _t( __CLASS__ . '.MANAGE_SUBSITES_HELP', 'Ability to limit the permissions for a group to one or more subsites.' diff --git a/src/Extensions/SiteTreeSubsites.php b/src/Extensions/SiteTreeSubsites.php index d69383b..689197d 100644 --- a/src/Extensions/SiteTreeSubsites.php +++ b/src/Extensions/SiteTreeSubsites.php @@ -62,7 +62,10 @@ class SiteTreeSubsites extends DataExtension } // If you're querying by ID, ignore the sub-site - this is a bit ugly... - // if(!$query->where || (strpos($query->where[0], ".\"ID\" = ") === false && strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false && strpos($query->where[0], "ID = ") !== 0)) { + // if(!$query->where + // || (strpos($query->where[0], ".\"ID\" = ") === false + // && strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false + // && strpos($query->where[0], "ID = ") !== 0)) { if ($query->filtersOnID()) { return; } @@ -418,7 +421,10 @@ class SiteTreeSubsites extends DataExtension Subsite::disable_subsite_filter(true); $candidatePage = DataObject::get_one( SiteTree::class, - "\"URLSegment\" = '" . Convert::raw2sql(urldecode($rest)) . "' AND \"SubsiteID\" = " . $subsiteID, + "\"URLSegment\" = '" + . Convert::raw2sql(urldecode($rest)) + . "' AND \"SubsiteID\" = " + . $subsiteID, false ); Subsite::disable_subsite_filter($origDisableSubsiteFilter); diff --git a/src/Model/Subsite.php b/src/Model/Subsite.php index 529fb75..4b25af2 100644 --- a/src/Model/Subsite.php +++ b/src/Model/Subsite.php @@ -480,7 +480,9 @@ class Subsite extends DataObject ) ->innerJoin( 'Permission', - "\"Group\".\"ID\"=\"Permission\".\"GroupID\" AND \"Permission\".\"Code\" IN ($SQL_codes, 'CMS_ACCESS_LeftAndMain', 'ADMIN')" + "\"Group\".\"ID\"=\"Permission\".\"GroupID\" + AND \"Permission\".\"Code\" + IN ($SQL_codes, 'CMS_ACCESS_LeftAndMain', 'ADMIN')" ); if (!$subsites) { @@ -504,7 +506,9 @@ class Subsite extends DataObject ->innerJoin('PermissionRole', '"Group_Roles"."PermissionRoleID"="PermissionRole"."ID"') ->innerJoin( 'PermissionRoleCode', - "\"PermissionRole\".\"ID\"=\"PermissionRoleCode\".\"RoleID\" AND \"PermissionRoleCode\".\"Code\" IN ($SQL_codes, 'CMS_ACCESS_LeftAndMain', 'ADMIN')" + "\"PermissionRole\".\"ID\"=\"PermissionRoleCode\".\"RoleID\" + AND \"PermissionRoleCode\".\"Code\" + IN ($SQL_codes, 'CMS_ACCESS_LeftAndMain', 'ADMIN')" ); if (!$subsites && $rolesSubsites) { @@ -628,10 +632,12 @@ class Subsite extends DataObject $groupCount = DB::query(" SELECT COUNT(\"Permission\".\"ID\") FROM \"Permission\" - INNER JOIN \"Group\" ON \"Group\".\"ID\" = \"Permission\".\"GroupID\" AND \"Group\".\"AccessAllSubsites\" = 1 - INNER JOIN \"Group_Members\" ON \"Group_Members\".\"GroupID\" = \"Permission\".\"GroupID\" - WHERE \"Permission\".\"Code\" IN ('$SQL_perms') - AND \"Group_Members\".\"MemberID\" = {$memberID} + INNER JOIN \"Group\" + ON \"Group\".\"ID\" = \"Permission\".\"GroupID\" AND \"Group\".\"AccessAllSubsites\" = 1 + INNER JOIN \"Group_Members\" + ON \"Group_Members\".\"GroupID\" = \"Permission\".\"GroupID\" + WHERE \"Permission\".\"Code\" + IN ('$SQL_perms') AND \"Group_Members\".\"MemberID\" = {$memberID} ")->value(); // Count this user's groups which have a role that can access the main site diff --git a/src/Pages/SubsitesVirtualPage.php b/src/Pages/SubsitesVirtualPage.php index ea2a882..b4c3d4f 100644 --- a/src/Pages/SubsitesVirtualPage.php +++ b/src/Pages/SubsitesVirtualPage.php @@ -141,9 +141,18 @@ class SubsitesVirtualPage extends VirtualPage { $labels = parent::fieldLabels($includerelations); $labels['CustomMetaTitle'] = _t('SilverStripe\\Subsites\\Model\\Subsite.CustomMetaTitle', 'Title'); - $labels['CustomMetaKeywords'] = _t('SilverStripe\\Subsites\\Model\\Subsite.CustomMetaKeywords', 'Keywords'); - $labels['CustomMetaDescription'] = _t('SilverStripe\\Subsites\\Model\\Subsite.CustomMetaDescription', 'Description'); - $labels['CustomExtraMeta'] = _t('SilverStripe\\Subsites\\Model\\Subsite.CustomExtraMeta', 'Custom Meta Tags'); + $labels['CustomMetaKeywords'] = _t( + 'SilverStripe\\Subsites\\Model\\Subsite.CustomMetaKeywords', + 'Keywords' + ); + $labels['CustomMetaDescription'] = _t( + 'SilverStripe\\Subsites\\Model\\Subsite.CustomMetaDescription', + 'Description' + ); + $labels['CustomExtraMeta'] = _t( + 'SilverStripe\\Subsites\\Model\\Subsite.CustomExtraMeta', + 'Custom Meta Tags' + ); return $labels; } diff --git a/tests/php/SubsiteAdminTest.php b/tests/php/SubsiteAdminTest.php index 5bdb265..f5815f9 100644 --- a/tests/php/SubsiteAdminTest.php +++ b/tests/php/SubsiteAdminTest.php @@ -39,7 +39,8 @@ class SubsiteAdminTest extends BaseSubsiteTest // Confirm that this URL gets you the entire page, with the edit form loaded $response2 = Director::test( - "admin/subsites/SilverStripe-Subsites-Model-Subsite/EditForm/field/SilverStripe-Subsites-Model-Subsite/item/$subsite1ID/edit", + "admin/subsites/SilverStripe-Subsites-Model-Subsite/EditForm/field/" + ."SilverStripe-Subsites-Model-Subsite/item/$subsite1ID/edit", null, $this->adminLoggedInSession() ); diff --git a/tests/php/SubsiteTest.php b/tests/php/SubsiteTest.php index 7c23fc8..bea0426 100644 --- a/tests/php/SubsiteTest.php +++ b/tests/php/SubsiteTest.php @@ -57,7 +57,8 @@ class SubsiteTest extends BaseSubsiteTest $tmplStaff = $this->objFromFixture('Page', 'staff'); $tmplHome = DataObject::get_one('Page', "\"URLSegment\" = 'home'"); - // Publish all the pages in the template, testing that DataObject::get only returns pages from the chosen subsite + // Publish all the pages in the template, testing that DataObject::get only returns pages + // from the chosen subsite $pages = DataObject::get(SiteTree::class); $totalPages = $pages->count(); foreach ($pages as $page) { @@ -193,7 +194,8 @@ class SubsiteTest extends BaseSubsiteTest $this->assertEquals( $subsite1->ID, Subsite::getSubsiteIDForDomain('www.example.org'), - 'Matches without strict checking when using www prefix, still matching first domain regardless of www prefix (falling back to subsite primary key ordering)' + 'Matches without strict checking when using www prefix, ' + .'still matching first domain regardless of www prefix (falling back to subsite primary key ordering)' ); $this->assertEquals( $subsite1->ID,