2013-10-16 02:20:54 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Section-agnostic PJAX controller.
|
|
|
|
*/
|
2015-11-23 04:53:45 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-27 05:10:14 +02:00
|
|
|
* Allow access if user allowed into the CMS at all.
|
2015-11-23 04:53:45 +01:00
|
|
|
*/
|
|
|
|
public function canAccess()
|
|
|
|
{
|
2016-05-27 05:10:14 +02:00
|
|
|
// Allow if any cms access is available
|
|
|
|
return Permission::check(array(
|
|
|
|
'CMS_ACCESS', // Supported by 3.1.14 and up
|
|
|
|
'CMS_ACCESS_LeftAndMain'
|
|
|
|
));
|
2015-11-23 04:53:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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');
|
|
|
|
}
|
2013-10-16 02:20:54 +02:00
|
|
|
}
|