BUGFIX: Sam's fix for "Unknown column Group.SubsiteID" with new subsites (from r100375)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@105555 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-05-25 03:45:27 +00:00
parent 08fb51c584
commit 95c4befb4a

View File

@ -625,14 +625,22 @@ class Security extends Controller {
*/
static function findAnAdministrator() {
// coupling to subsites module
$subsiteCheck = class_exists('GroupSubsites') ? ' AND "Group"."SubsiteID" = 0' : '';
$origSubsite = null;
if(is_callable('Subsite::changeSubsite')) {
$origSubsite = Subsite::currentSubsiteID();
Subsite::changeSubsite(0);
}
// find a group with ADMIN permission
$adminGroup = DataObject::get('Group',
"\"Permission\".\"Code\" = 'ADMIN'$subsiteCheck",
"\"Permission\".\"Code\" = 'ADMIN'",
"\"Group\".\"ID\"",
"JOIN \"Permission\" ON \"Group\".\"ID\"=\"Permission\".\"GroupID\"",
'1');
if(is_callable('Subsite::changeSubsite')) {
Subsite::changeSubsite($origSubsite);
}
if ($adminGroup) {
$adminGroup = $adminGroup->First();