mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 09:05:55 +00:00
BUGFIX: Improved support for subsites trunk with 2.2.2
ENHANCEMENT: Got 'Is Default Site' checkbox actually working; if used the main site option is removed from the sites list when editing content. API CHANGE: Added $subsite->absoluteBaseURL(), as a subsite-specific equivaent of Director::absoluteBaseURL()
This commit is contained in:
parent
3315786c66
commit
3993cf6fe4
@ -65,8 +65,23 @@ class LeftAndMainSubsites extends Extension {
|
||||
$siteList = new DataObjectSet();
|
||||
$subsites = Subsite::accessible_sites('CMS_ACCESS_' . $this->owner->class);
|
||||
|
||||
if(Subsite::hasMainSitePermission(Member::currentUser(), array('CMS_ACCESS_' . $this->owner->class, 'ADMIN')))
|
||||
$siteList->push(new ArrayData(array('Title' => 'Main site', 'ID' => 0)));
|
||||
|
||||
$mainSiteTitle = null;
|
||||
switch($this->owner->class) {
|
||||
case "AssetAdmin":
|
||||
$mainSiteTitle = "Shared files & images"; break;
|
||||
case "SecurityAdmin":
|
||||
$mainSiteTitle = "Groups accessing all sites"; break;
|
||||
case "CMSMain":
|
||||
// If there's a default site then main site has no meaning
|
||||
if(!DataObject::get_one('Subsite',"`DefaultSite` AND `IsPublic`")) {
|
||||
$mainSiteTitle = "Main site";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if($mainSiteTitle && Subsite::hasMainSitePermission(Member::currentUser(), array('CMS_ACCESS_' . $this->owner->class, 'ADMIN')))
|
||||
$siteList->push(new ArrayData(array('Title' => $mainSiteTitle, 'ID' => 0)));
|
||||
|
||||
if($subsites)
|
||||
$siteList->merge($subsites);
|
||||
@ -77,7 +92,9 @@ class LeftAndMainSubsites extends Extension {
|
||||
public function SubsiteList() {
|
||||
$list = $this->Subsites();
|
||||
|
||||
$requestSubsiteID = Controller::curr()->getRequest()->getVar('SubsiteID');
|
||||
if(Controller::curr()->hasMethod('getRequest')) $requestSubsiteID = Controller::curr()->getRequest()->getVar('SubsiteID');
|
||||
else $requestSubsiteID = isset($_REQUEST['SubsiteID']) ? $_REQUEST['SubsiteID'] : null;
|
||||
|
||||
$currentSubsiteID = ($requestSubsiteID) ? $requestSubsiteID : Session::get('SubsiteID');
|
||||
|
||||
if($list->Count() > 1) {
|
||||
|
@ -157,6 +157,10 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
if($sub) return "$sub.$base";
|
||||
else return $base;
|
||||
}
|
||||
|
||||
function absoluteBaseURL() {
|
||||
return "http://" . $this->domain() . Director::baseURL();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the configuration fields for each subsite
|
||||
@ -310,7 +314,10 @@ JS;
|
||||
$subsite = DataObject::get_one('Subsite',"`Subdomain` = '$SQL_subdomain' AND `Domain`='$SQL_domain' AND `IsPublic`=1");
|
||||
}
|
||||
if(!$subsite) {
|
||||
$subsite = DataObject::get_one('Subsite',"`Subdomain` = '$SQL_subdomain' AND `IsPublic`=1");
|
||||
$subsite = DataObject::get_one('Subsite',"`Subdomain` = '$SQL_subdomain' AND `IsPublic`");
|
||||
}
|
||||
if(!$subsite) {
|
||||
$subsite = DataObject::get_one('Subsite',"`DefaultSite` AND `IsPublic`");
|
||||
}
|
||||
|
||||
if($subsite) {
|
||||
|
@ -4,7 +4,10 @@ SubsitesTreeDropdownField.prototype = {
|
||||
//subsiteID: null,
|
||||
|
||||
ajaxGetTree: function(after) {
|
||||
var ajaxURL = this.helperURLBase() + 'gettree?forceValues=' + this.inputTag.value;
|
||||
// This if block is necessary to maintain both 2.2 and 2.3 support
|
||||
var baseURL = this.options.dropdownField.helperURLBase();
|
||||
if(baseURL.match('action_callfieldmethod') var ajaxURL = baseURL+ '&methodName=gettree&forceValues=' + this.getIdx();
|
||||
else var ajaxURL = baseURL+ 'gettree?forceValues=' + this.getIdx();
|
||||
|
||||
// Customized: Append subsiteid (evaluated in SubsitesVirtualPage.php)
|
||||
if(this.subsiteID) ajaxURL += '&' + this.id + '_SubsiteID=' + this.subsiteID;
|
||||
@ -22,7 +25,10 @@ SubsitesTreeDropdownField.prototype = {
|
||||
var ul = this.treeNodeHolder();
|
||||
ul.innerHTML = ss.i18n._t('LOADING');
|
||||
|
||||
var ajaxURL = this.options.dropdownField.helperURLBase() + 'getsubtree?&SubtreeRootID=' + this.getIdx();
|
||||
// This if block is necessary to maintain both 2.2 and 2.3 support
|
||||
var baseURL = this.options.dropdownField.helperURLBase();
|
||||
if(baseURL.match('action_callfieldmethod') var ajaxURL = baseURL+ '&methodName=gettree&SubtreeRootID=' + this.getIdx();
|
||||
else var ajaxURL = baseURL+ 'gettree?SubtreeRootID=' + this.getIdx();
|
||||
|
||||
// Customized: Append subsiteid (evaluated in SubsitesVirtualPage.php)
|
||||
if(this.subsiteID) ajaxURL += '&' + this.id + '_SubsiteID=' + this.subsiteID;
|
||||
|
Loading…
x
Reference in New Issue
Block a user