diff --git a/code/Subsite.php b/code/Subsite.php index 73b5799..2d5b47d 100644 --- a/code/Subsite.php +++ b/code/Subsite.php @@ -220,8 +220,8 @@ SQL; $SQLa_perm = Convert::raw2sql($permissionCodes); $SQL_perms = join("','", $SQLa_perm); $memberID = (int)$member->ID; - - return DB::query("SELECT COUNT(`Permission`.`ID`) FROM `Permission` LEFT JOIN `Group` ON `Group`.`ID` = `Permission`.`GroupID` LEFT JOIN `Group_Members` USING(`GroupID`) WHERE `Permission`.`Code` IN ('$SQL_perms') AND `SubsiteID` = 0 AND `MemberID` = {$memberID}")->value(); + // `SubsiteID` = 0 AND + return DB::query("SELECT COUNT(`Permission`.`ID`) FROM `Permission` LEFT JOIN `Group` ON `Group`.`ID` = `Permission`.`GroupID` LEFT JOIN `Group_Members` USING(`GroupID`) WHERE `Permission`.`Code` IN ('$SQL_perms') AND `MemberID` = {$memberID}")->value(); } function createInitialRecords() { diff --git a/code/SubsiteAdmin.php b/code/SubsiteAdmin.php index 85ed6f4..89d9284 100644 --- a/code/SubsiteAdmin.php +++ b/code/SubsiteAdmin.php @@ -14,14 +14,16 @@ class SubsiteAdmin extends GenericDataAdmin { } function getLink() { - return 'admin/intranets/'; + return 'admin/subsites/'; } function Link() { return $this->getLink(); } - function Results($data, $form) { + function Results($data = null) { + if(!$data) $data = $this->requestParams; + $where = ''; if(isset($data['Name']) && $data['Name']) { $SQL_name = Convert::raw2sql($data['Name']); @@ -38,7 +40,7 @@ class SubsiteAdmin extends GenericDataAdmin { foreach($intranets as $intranet) { $numIntranets++; $evenOdd = ($numIntranets % 2) ? 'odd':'even'; - $html .= "ID}\">{$intranet->Title}{$intranet->Subdomain}.{$intranet->Domain}"; + $html .= "ID}\">{$intranet->Title}{$intranet->Subdomain}.{$intranet->Domain}"; } $html .= ""; return $html; @@ -108,7 +110,7 @@ class SubsiteAdmin extends GenericDataAdmin { $member->Groups()->add($groupObjects['Administrators']); - Director::redirect('admin/intranets/show/' . $intranet->ID); + Director::redirect('admin/subsites/show/' . $intranet->ID); } } ?> diff --git a/tests/SubsiteAdminTest.php b/tests/SubsiteAdminTest.php index ef1aa7b..3efe664 100644 --- a/tests/SubsiteAdminTest.php +++ b/tests/SubsiteAdminTest.php @@ -2,6 +2,27 @@ class SubsiteAdminTest extends SapphireTest { static $fixture_file = 'subsites/tests/SubsiteTest.yml'; + + /** + * Test generation of the view + */ + function testBasicView() { + // Open the admin area logged in as admin + $response1 = Director::test('admin/subsites/'); + + + // Confirm that this URL gets you the entire page, with the edit form loaded + $response2 = Director::test('admin/subsites/show/1'); + $this->assertTrue(strpos($response2->getBody(), 'id="Root_Configuration"') !== false); + $this->assertTrue(strpos($response2->getBody(), ' 1)); + + $this->assertTrue(strpos($response3->getBody(), 'id="Root_Configuration"') !== false); + $this->assertTrue(strpos($response3->getBody(), 'assertTrue(strpos($response3->getBody(), ' 'Other'), - array('Name' => ''), ); foreach($searches as $search) { $response = $form->testAjaxSubmission('getResults', $search); - - echo $response->getBody(); + $links = $response->getLinks(); + foreach($links as $link) { + $this->assertTrue(preg_match('/^admin\/subsites\/show\/[0-9]+$/', $link['href']) == 1, "Search result links bad."); + } } - - /* - $this->assertHasLink($response->getBody(), 'admin/intranets/show/' . $this->idFromFixture('Subsite', 'other')); - $this->assertHasntLink($response->getBody(), 'admin/intranets/show/' . $this->idFromFixture('Subsite', 'other')); - */ $cont->popCurrent(); } diff --git a/tests/SubsiteTest.php b/tests/SubsiteTest.php index 5f52548..681ae40 100644 --- a/tests/SubsiteTest.php +++ b/tests/SubsiteTest.php @@ -2,7 +2,7 @@ class SubsiteTest extends SapphireTest { static $fixture_file = 'subsites/tests/SubsiteTest.yml'; - + /** * Create a new subsite from the template and verify that all the template's pages are copied */