code/FileSubsites.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(!$query->where || !preg_match('/\.(\'|"|`|)ID(\'|"|`|)/', $query->where[0])) {
			if($context = DataObject::context_obj()) $subsiteID = (int) $context->SubsiteID;
			else $subsiteID = (int) Subsite::currentSubsiteID();
			foreach($query->from as $tableName => $info) {
				$where = "\"$tableName\".\"SubsiteID\" IN (0, $subsiteID)";
				$query->where[] = $where;
				break;
			}
			$isCounting = strpos($query->select[0], 'COUNT') !== false;
			if(!$query->delete && !$isCounting) {
				$query->orderby = "\"SubsiteID\"" . ($query->orderby ? ', ' : '') . $query->orderby;
			}
		}
	}
function augmentSQL ( SQLQuery & $ query ) { if ( ! $ query -> where || ! preg_match ( '/\.(\'|"|`|)ID(\'|"|`|)/' , $ query -> where [ 0 ] ) ) { if ( $ context = DataObject :: context_obj ( ) ) $ subsiteID = ( int ) $ context -> SubsiteID ; else $ subsiteID = ( int ) Subsite :: currentSubsiteID ( ) ; foreach ( $ query -> from as $ tableName => $ info ) { $ where = " \" $ tableName \" . \" SubsiteID \"  IN (0,  $ subsiteID ) " ; $ query -> where [ ] = $ where ; break ; } $ isCounting = strpos ( $ query -> select [ 0 ] , 'COUNT' ) !== false ; if ( ! $ query -> delete && ! $ isCounting ) { $ query -> orderby = " \" SubsiteID \" " . ( $ query -> orderby ? ', ' : '' ) . $ query -> orderby ; } } }
Update any requests to limit the results to the current site
Update any requests to limit the results to the current site
// If you're querying by ID, ignore the sub-site - this is a bit ugly... (but it was WAYYYYYYYYY worse) // The foreach is an ugly way of getting the first key :-) // Ordering when deleting or counting doesn't apply