BUGFIX: orphaned permissions and subsite administrator groups were causing trouble - now with the JOIN the first global administrator group is picked up when ussing the override login.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@94835 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Mateusz Uzdowski 2009-12-10 01:00:08 +00:00 committed by Sam Minnee
parent fa3fe47284
commit 056dae8103

View File

@ -602,13 +602,18 @@ class Security extends Controller {
* privileges.
*/
static function findAnAdministrator($username = 'admin', $password = 'password') {
$permission = DataObject::get_one("Permission", "\"Code\" = 'ADMIN'", true, "\"Permission\".\"ID\"");
$adminGroup = null;
// coupling to subsites module
$subsiteCheck = class_exists('GroupSubsites') ? ' AND "Group"."SubsiteID" = 0' : '';
if($permission) $adminGroup = DataObject::get_one("Group", "\"Group\".\"ID\" = '{$permission->GroupID}'$subsiteCheck", true, "\"Group\".\"ID\"");
if($adminGroup) {
// find a group with ADMIN permission
$adminGroup = DataObject::get('Group',
"\"Permission\".\"Code\" = 'ADMIN'$subsiteCheck",
"\"Group\".\"ID\"",
"JOIN \"Permission\" ON \"Group\".\"ID\"=\"Permission\".\"GroupID\"",
'1');
if ($adminGroup) {
$adminGroup = $adminGroup->First();
if($adminGroup->Members()->First()) {
$member = $adminGroup->Members()->First();
}