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.
BUG Move the SubsiteList PJAX request to a dedicated Controller.
Currently the request cannot be made if one doesn't have access to the SubsiteAdmin section, which often happens with subsite-specific admins.
- Loading branch information
Showing
3 changed files
with
41 additions
and
16 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