mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
MINOR force a specific set of subsite IDs to be queried on (from r95849)
This commit is contained in:
parent
ba1db5ae24
commit
9e423fda4d
@ -69,9 +69,11 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
|
||||
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
|
||||
if (!$query->where || (!preg_match('/\.(\'|"|`|)ID(\'|"|`|)( ?)=/', $query->where[0]))) {
|
||||
$context = DataObject::context_obj();
|
||||
if($context && is_numeric($context->SubsiteID)) $subsiteID = (int) $context->SubsiteID;
|
||||
else $subsiteID = (int) Subsite::currentSubsiteID();
|
||||
if (Subsite::$force_subsite) $subsiteID = Subsite::$force_subsite;
|
||||
else {
|
||||
if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||
else $subsiteID = (int)Subsite::currentSubsiteID();
|
||||
}
|
||||
|
||||
// The foreach is an ugly way of getting the first key :-)
|
||||
foreach($query->from as $tableName => $info) {
|
||||
|
@ -12,6 +12,12 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
* to limit DataObject::get*() calls to a specific subsite. Useful for debugging.
|
||||
*/
|
||||
static $disable_subsite_filter = false;
|
||||
|
||||
/**
|
||||
* Allows you to force a specific subsite ID, or comma separated list of IDs.
|
||||
* Only works for reading. An object cannot be written to more than 1 subsite.
|
||||
*/
|
||||
static $force_subsite = null;
|
||||
|
||||
static $write_hostmap = true;
|
||||
static $default_sort = 'Title';
|
||||
|
Loading…
Reference in New Issue
Block a user