code/SiteTreeSubsites.php
/**
	 * Update any requests to limit the results to the current site
	 */
Update any requests to limit the results to the current site
Update any requests to limit the results to the current site
function augmentSQL(SQLQuery &$query) {
		if(Subsite::$disable_subsite_filter) return;
		if ($query->delete) return;
		if (!$query->where || (!preg_match('/\.(\'|"|`|)ID(\'|"|`|)( ?)=/', $query->where[0]))) {
			if (Subsite::$force_subsite) $subsiteID = Subsite::$force_subsite;
			else {
				if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
				else $subsiteID = (int)Subsite::currentSubsiteID();
			}
			foreach($query->from as $tableName => $info) {
				if(strpos($tableName,'SiteTree') === false) break;
				$query->where[] = "\"$tableName\".\"SubsiteID\" IN ($subsiteID)";
				break;
			}
		}
	}
function augmentSQL ( SQLQuery & $ query ) { if ( Subsite :: $ disable_subsite_filter ) return ; if ( $ query -> delete ) return ; if ( ! $ query -> where || ( ! preg_match ( '/\.(\'|"|`|)ID(\'|"|`|)( ?)=/' , $ query -> where [ 0 ] ) ) ) { if ( Subsite :: $ force_subsite ) $ subsiteID = Subsite :: $ force_subsite ; else { if ( $ context = DataObject :: context_obj ( ) ) $ subsiteID = ( int ) $ context -> SubsiteID ; else $ subsiteID = ( int ) Subsite :: currentSubsiteID ( ) ; } foreach ( $ query -> from as $ tableName => $ info ) { if ( strpos ( $ tableName , 'SiteTree' ) === false ) break ; $ query -> where [ ] = " \" $ tableName \" . \" SubsiteID \"  IN ( $ subsiteID ) " ; break ; } } }
Update any requests to limit the results to the current site
Update any requests to limit the results to the current site
// Don't run on delete queries, since they are always tied to // a specific ID. // If you're querying by ID, ignore the sub-site - this is a bit ugly... // if(!$query->where || (strpos($query->where[0], ".\"ID\" = ") === false && strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false && strpos($query->where[0], "ID = ") !== 0)) { // The foreach is an ugly way of getting the first key :-) // The tableName should be SiteTree or SiteTree_Live...