Skip to content

Commit

Permalink
Fix line length
Browse files Browse the repository at this point in the history
  • Loading branch information
raissanorth committed Feb 1, 2018
1 parent db69c48 commit 8b5f593
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 16 deletions.
8 changes: 6 additions & 2 deletions src/Extensions/GroupSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
}
}

// 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');
Expand Down Expand Up @@ -230,7 +231,10 @@ public function providePermissions()
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.'
Expand Down
10 changes: 8 additions & 2 deletions src/Extensions/SiteTreeSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
}

// 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;
}
Expand Down Expand Up @@ -418,7 +421,10 @@ public function augmentSyncLinkTracking()
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);
Expand Down
18 changes: 12 additions & 6 deletions src/Model/Subsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,9 @@ public static function accessible_sites(
)
->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) {
Expand All @@ -504,7 +506,9 @@ public static function accessible_sites(
->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) {
Expand Down Expand Up @@ -628,10 +632,12 @@ public static function hasMainSitePermission($member = null, $permissionCodes =
$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
Expand Down
15 changes: 12 additions & 3 deletions src/Pages/SubsitesVirtualPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,18 @@ public function fieldLabels($includerelations = true)
{
$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;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/php/SubsiteAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public function testBasicView()

// 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()
);
Expand Down
6 changes: 4 additions & 2 deletions tests/php/SubsiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public function testSubsiteCreation()
$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) {
Expand Down Expand Up @@ -193,7 +194,8 @@ public function testStrictSubdomainMatching()
$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,
Expand Down

0 comments on commit 8b5f593

Please sign in to comment.