owner->class}.currentPage");
}
// Update current subsite in session
Subsite::changeSubsite($_GET['SubsiteID']);
//Redirect to clear the current page
return $this->owner->redirect('admin/');
}
// Set subsite ID based on currently shown record
$req = $this->owner->getRequest();
$id = $req->param('ID');
if($id && is_numeric($id)) {
$record = DataObject::get_by_id($this->owner->stat('tree_class'), $id);
if($record) Session::set('SubsiteID', $record->SubsiteID);
}
}
/**
* Set the title of the CMS tree
*/
function getCMSTreeTitle() {
$subsite = Subsite::currentSubSite();
return $subsite ? Convert::raw2xml($subsite->Title) : _t('LeftAndMain.SITECONTENTLEFT');
}
function updatePageOptions(&$fields) {
$fields->push(new HiddenField('SubsiteID', 'SubsiteID', Subsite::currentSubsiteID()));
}
public function Subsites() {
// figure out what permission the controller needs
// Subsite::accessible_sites() expects something, so if there's no permission
// then fallback to using CMS_ACCESS_LeftAndMain.
$permission = 'CMS_ACCESS_' . $this->owner->class;
$available = Permission::get_codes(false);
if(!isset($available[$permission])) {
$permission = $this->owner->stat('required_permission_codes');
if(!$permission) {
$permission = 'CMS_ACCESS_LeftAndMain';
}
}
switch($this->owner->class) {
case "AssetAdmin":
$subsites = Subsite::accessible_sites($permission, true, "Shared files & images");
break;
case "SecurityAdmin":
$subsites = Subsite::accessible_sites($permission, true, "Groups accessing all sites");
if($subsites->find('ID',0)) {
$subsites->push(new ArrayData(array('Title' => 'All groups', 'ID' => -1)));
}
break;
case "CMSMain":
case "CMSPagesController":
// If there's a default site then main site has no meaning
$showMainSite = !DataObject::get_one('Subsite',"\"DefaultSite\"=1");
$subsites = Subsite::accessible_sites($permission, $showMainSite);
break;
case "SubsiteAdmin":
$subsites = Subsite::accessible_sites('ADMIN', true);
break;
default:
$subsites = Subsite::accessible_sites($permission);
break;
}
return $subsites;
}
public function SubsiteList() {
$list = $this->Subsites();
$currentSubsiteID = Subsite::currentSubsiteID();
if($list->Count() > 1) {
$output = '