MINOR force a specific set of subsite IDs to be queried on (from r95849)

This commit is contained in:
Tom Rix 2010-03-01 21:56:24 +00:00
parent ba1db5ae24
commit 9e423fda4d
2 changed files with 11 additions and 3 deletions

View File

@ -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) {

View File

@ -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';