forked from silverstripe/silverstripe-subsites
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request silverstripe#115 from mateusz/admin-access
Fix CMS Admin access issues
- Loading branch information
Showing
10 changed files
with
373 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/** | ||
* Section-agnostic PJAX controller. | ||
*/ | ||
class SubsiteXHRController extends LeftAndMain { | ||
|
||
/** | ||
* Relax the access permissions, so anyone who has access to any CMS subsite can access this controller. | ||
*/ | ||
public function canView($member = null) { | ||
if (parent::canView()) return true; | ||
|
||
if (Subsite::all_accessible_sites()->count()>0) return true; | ||
|
||
return false; | ||
} | ||
|
||
public function getResponseNegotiator() { | ||
$negotiator = parent::getResponseNegotiator(); | ||
$self = $this; | ||
|
||
// Register a new callback | ||
$negotiator->setCallback('SubsiteList', function() use(&$self) { | ||
return $self->SubsiteList(); | ||
}); | ||
|
||
return $negotiator; | ||
} | ||
|
||
/** | ||
* Provide the list of available subsites as a cms-section-agnostic PJAX handler. | ||
*/ | ||
public function SubsiteList() { | ||
return $this->renderWith('SubsiteList'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.