mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
MINOR CHANGE: columns quoted properly (from r88146)
This commit is contained in:
parent
c45fee8783
commit
6b5f6f902d
@ -147,7 +147,7 @@ class GroupSubsites extends DataObjectDecorator implements PermissionProvider {
|
||||
$query->where[] = "{$q}Group{$q}.{$q}AccessAllSubsites{$q} = 1";
|
||||
}
|
||||
}
|
||||
$query->orderby = "{$q}AccessAllSubsites{$q} DESC" . ($query->orderby ? ', ' : '') . $query->orderby;
|
||||
$query->orderby = "\"SubsiteID\"" . ($query->orderby ? ', ' : '') . $query->orderby;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,10 @@ class RelatedPageLink extends DataObject {
|
||||
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain", true);
|
||||
if(!$subsites) $subsites = new DataObjectSet();
|
||||
|
||||
if(Subsite::hasMainSitePermission()) {
|
||||
$subsites->push(new ArrayData(array('Title' => 'Main site', "\"ID\"" => 0)));
|
||||
}
|
||||
|
||||
if($subsites->Count()) {
|
||||
$subsiteSelectionField = new DropdownField(
|
||||
"CopyContentFromID_SubsiteID",
|
||||
|
@ -29,7 +29,7 @@ class SiteConfigSubsites extends DataObjectDecorator {
|
||||
|
||||
$tableName = array_shift(array_keys($query->from));
|
||||
if($tableName != 'SiteConfig') return;
|
||||
$query->where[] = "`$tableName`.SubsiteID IN ($subsiteID)";
|
||||
$query->where[] = "\"$tableName\".\"SubsiteID\" IN ($subsiteID)";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
$oldState = Subsite::$disable_subsite_filter;
|
||||
Subsite::$disable_subsite_filter = true;
|
||||
|
||||
$linkedPages = DataObject::get("SubsitesVirtualPage", "CopyContentFromID = {$this->owner->ID}");
|
||||
$linkedPages = DataObject::get("SubsitesVirtualPage", "\"CopyContentFromID\" = {$this->owner->ID}");
|
||||
if($linkedPages) foreach($linkedPages as $page) {
|
||||
$page->copyFrom($page->CopyContentFrom());
|
||||
$page->write();
|
||||
@ -136,7 +136,7 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
$oldState = Subsite::$disable_subsite_filter;
|
||||
Subsite::$disable_subsite_filter = true;
|
||||
|
||||
$linkedPages = DataObject::get("SubsitesVirtualPage", "CopyContentFromID = {$this->owner->ID}");
|
||||
$linkedPages = DataObject::get("SubsitesVirtualPage", "\"CopyContentFromID\" = {$this->owner->ID}");
|
||||
if($linkedPages) foreach($linkedPages as $page) {
|
||||
$page->copyFrom($page->CopyContentFrom());
|
||||
if($page->ExistsOnLive) $page->doPublish();
|
||||
|
@ -113,7 +113,7 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
*/
|
||||
function domain() {
|
||||
if($this->ID) {
|
||||
$domains = DataObject::get("SubsiteDomain", "SubsiteID = $this->ID", "IsPrimary DESC",
|
||||
$domains = DataObject::get("SubsiteDomain", "\"SubsiteID\" = $this->ID", "\"IsPrimary\" DESC",
|
||||
"", 1);
|
||||
if($domains) {
|
||||
$domain = $domains->First()->Domain;
|
||||
@ -296,13 +296,16 @@ JS;
|
||||
*/
|
||||
static function getSubsiteIDForDomain($host = null, $returnMainIfNotFound = true) {
|
||||
if($host == null) $host = $_SERVER['HTTP_HOST'];
|
||||
if(defined('DB::USE_ANSI_SQL'))
|
||||
$q="\"";
|
||||
else $q='`';
|
||||
|
||||
$host = str_replace('www.','',$host);
|
||||
$SQL_host = Convert::raw2sql($host);
|
||||
|
||||
$matchingDomains = DataObject::get("SubsiteDomain", "'$SQL_host' LIKE replace({$q}SubsiteDomain{$q}.{$q}Domain{$q},'*','%')",
|
||||
"{$q}IsPrimary{$q} DESC", "INNER JOIN {$q}Subsite{$q} ON {$q}Subsite{$q}.{$q}ID{$q} = {$q}SubsiteDomain{$q}.{$q}SubsiteID{$q} AND
|
||||
{$q}Subsite{$q}.{$q}IsPublic{$q}");
|
||||
{$q}Subsite{$q}.{$q}IsPublic{$q}=1");
|
||||
|
||||
if($matchingDomains) {
|
||||
$subsiteIDs = array_unique($matchingDomains->column('SubsiteID'));
|
||||
@ -311,7 +314,7 @@ JS;
|
||||
}
|
||||
|
||||
// Check for a 'default' subsite
|
||||
if ($default = DataObject::get_one('Subsite', 'DefaultSite = 1')) {
|
||||
if ($default = DataObject::get_one('Subsite', "\"DefaultSite\" = 1")) {
|
||||
return $default->ID;
|
||||
}
|
||||
|
||||
@ -332,15 +335,51 @@ JS;
|
||||
|
||||
return DataObject::get(
|
||||
'Member',
|
||||
<<<<<<< .working
|
||||
"{$q}Group{$q}.{$q}SubsiteID{$q} = $this->ID AND {$q}Permission{$q}.{$q}Code{$q} IN ('$SQL_permissionCodes')",
|
||||
=======
|
||||
"\"Group\".\"SubsiteID\" = $this->ID AND \"Permission\".\"Code\" IN ('$SQL_permissionCodes')",
|
||||
>>>>>>> .merge-right.r88146
|
||||
'',
|
||||
<<<<<<< .working
|
||||
"LEFT JOIN {$q}Group_Members{$q} ON {$q}Member{$q}.{$q}ID{$q} = {$q}Group_Members{$q}.{$q}MemberID{$q}
|
||||
LEFT JOIN {$q}Group{$q} ON {$q}Group{$q}.{$q}ID{$q} = {$q}Group_Members{$q}.{$q}GroupID{$q}
|
||||
LEFT JOIN {$q}Permission{$q} ON {$q}Permission{$q}.{$q}GroupID{$q} = {$q}Group{$q}.{$q}ID{$q}"
|
||||
=======
|
||||
"LEFT JOIN \"Group_Members\" ON \"Member\".\"ID\" = \"Group_Members\".\"MemberID\"
|
||||
LEFT JOIN \"Group\" ON \"Group\".\"ID\" = \"Group_Members\".\"GroupID\"
|
||||
LEFT JOIN \"Permission\" ON \"Permission\".\"GroupID\" = \"Group\".\"ID\""
|
||||
>>>>>>> .merge-right.r88146
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
<<<<<<< .working
|
||||
=======
|
||||
/**
|
||||
* Get all subsites.
|
||||
*
|
||||
* @return DataObjectSet Subsite instances
|
||||
*/
|
||||
static function getSubsitesForMember( $member = null) {
|
||||
if(!$member && $member !== FALSE) $member = Member::currentMember();
|
||||
|
||||
if(!$member) return false;
|
||||
|
||||
if(self::hasMainSitePermission($member)) {
|
||||
return DataObject::get('Subsite');
|
||||
} else {
|
||||
return DataObject::get(
|
||||
'Subsite',
|
||||
"\"MemberID\" = {$member->ID}",
|
||||
'',
|
||||
"LEFT JOIN \"Group\" ON \"Subsite\".\"ID\" = \"SubsiteID\"
|
||||
LEFT JOIN \"Group_Members\" ON \"Group\".\"ID\" = \"Group_Members\".\"GroupID\""
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
>>>>>>> .merge-right.r88146
|
||||
static function hasMainSitePermission($member = null, $permissionCodes = array('ADMIN')) {
|
||||
if(!is_array($permissionCodes))
|
||||
user_error('Permissions must be passed to Subsite::hasMainSitePermission as an array', E_USER_ERROR);
|
||||
@ -360,13 +399,25 @@ JS;
|
||||
else $q='`';
|
||||
|
||||
$groupCount = DB::query("
|
||||
<<<<<<< .working
|
||||
SELECT COUNT({$q}Permission{$q}.{$q}ID{$q})
|
||||
FROM {$q}Permission{$q}
|
||||
INNER JOIN {$q}Group{$q} ON {$q}Group{$q}.{$q}ID{$q} = {$q}Permission{$q}.{$q}GroupID{$q} AND {$q}Group{$q}.{$q}AccessAllSubsites{$q} = 1
|
||||
INNER JOIN {$q}Group_Members{$q} USING({$q}GroupID{$q})
|
||||
=======
|
||||
SELECT COUNT(\"Permission\".\"ID\")
|
||||
FROM \"Permission\"
|
||||
INNER JOIN \"Group\" ON \"Group\".\"ID\" = \"Permission\".\"GroupID\" AND \"Group\".\"SubsiteID\" = 0
|
||||
INNER JOIN \"Group_Members\" USING(\"GroupID\")
|
||||
>>>>>>> .merge-right.r88146
|
||||
WHERE
|
||||
<<<<<<< .working
|
||||
{$q}Permission{$q}.{$q}Code{$q} IN ('$SQL_perms')
|
||||
AND {$q}MemberID{$q} = {$memberID}
|
||||
=======
|
||||
\"Permission\".\"Code\" IN ('$SQL_perms')
|
||||
AND \"MemberID\" = {$memberID}
|
||||
>>>>>>> .merge-right.r88146
|
||||
")->value();
|
||||
|
||||
return ($groupCount > 0);
|
||||
@ -402,7 +453,11 @@ JS;
|
||||
while(count($stack) > 0) {
|
||||
list($sourceParentID, $destParentID) = array_pop($stack);
|
||||
|
||||
<<<<<<< .working
|
||||
$children = Versioned::get_by_stage('Page', 'Live', "{$q}ParentID{$q} = $sourceParentID", '');
|
||||
=======
|
||||
$children = Versioned::get_by_stage('Page', 'Live', "\"ParentID\"=$sourceParentID", '');
|
||||
>>>>>>> .merge-right.r88146
|
||||
|
||||
if($children) {
|
||||
foreach($children as $child) {
|
||||
@ -451,8 +506,15 @@ JS;
|
||||
|
||||
return DataObject::get(
|
||||
'Subsite',
|
||||
<<<<<<< .working
|
||||
"{$q}Subsite{$q}.{$q}Title{$q} != ''",
|
||||
=======
|
||||
"\"Group_Members\".\"MemberID\" = $member->ID
|
||||
AND \"Permission\".\"Code\" IN ($SQL_codes, 'ADMIN', 'SUBSITE_ACCESS_ALL')
|
||||
AND \"Subsite\".Title != ''",
|
||||
>>>>>>> .merge-right.r88146
|
||||
'',
|
||||
<<<<<<< .working
|
||||
"LEFT JOIN {$q}Group_Subsites{$q}
|
||||
ON {$q}Group_Subsites{$q}.{$q}SubsiteID{$q} = {$q}Subsite{$q}.{$q}ID{$q}
|
||||
INNER JOIN {$q}Group{$q} ON {$q}Group{$q}.{$q}ID{$q} = {$q}Group_Subsites{$q}.{$q}GroupID{$q}
|
||||
@ -463,6 +525,11 @@ JS;
|
||||
INNER JOIN {$q}Permission{$q}
|
||||
ON {$q}Group{$q}.{$q}ID{$q}={$q}Permission{$q}.{$q}GroupID{$q}
|
||||
AND {$q}Permission{$q}.{$q}Code{$q} IN ($SQL_codes, 'ADMIN')"
|
||||
=======
|
||||
"LEFT JOIN \"Group\" ON (\"SubsiteID\"=\"Subsite\".\"ID\" OR \"SubsiteID\" = 0)
|
||||
LEFT JOIN \"Group_Members\" ON \"Group_Members\".\"GroupID\"=\"Group\".\"ID\"
|
||||
LEFT JOIN \"Permission\" ON \"Group\".\"ID\"=\"Permission\".\"GroupID\""
|
||||
>>>>>>> .merge-right.r88146
|
||||
);
|
||||
|
||||
$rolesSubsites = DataObject::get(
|
||||
@ -616,7 +683,11 @@ class Subsite_Template extends Subsite {
|
||||
while(count($stack) > 0) {
|
||||
list($sourceParentID, $destParentID) = array_pop($stack);
|
||||
|
||||
<<<<<<< .working
|
||||
$children = Versioned::get_by_stage('SiteTree', 'Live', "{$q}ParentID{$q} = $sourceParentID", '');
|
||||
=======
|
||||
$children = Versioned::get_by_stage('SiteTree', 'Live', "\"ParentID\"=$sourceParentID", '');
|
||||
>>>>>>> .merge-right.r88146
|
||||
|
||||
if($children) {
|
||||
foreach($children as $child) {
|
||||
@ -633,8 +704,12 @@ class Subsite_Template extends Subsite {
|
||||
* Copy groups from the template to the given subsites. Each of the groups will be created and left
|
||||
* empty.
|
||||
*/
|
||||
<<<<<<< .working
|
||||
|
||||
$groups = $this->Groups();
|
||||
=======
|
||||
$groups = DataObject::get("Group", "\"SubsiteID\" = '$this->ID'");
|
||||
>>>>>>> .merge-right.r88146
|
||||
if($groups) foreach($groups as $group) {
|
||||
$group->duplicateToSubsite($intranet);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user