code/GroupSubsites.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(Cookie::get('noSubsiteFilter') == 'true') return;
		if(!$query->filtersOnID()) {
			if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
			else $subsiteID = (int)Subsite::currentSubsiteID();
			$hasGroupSubsites = false;
			foreach($query->from as $item) if(strpos($item, 'Group_Subsites') !== false) {
				$hasGroupSubsites = true;
				break;
			}
			if(!$hasGroupSubsites) {
				if($subsiteID) {
					$query->leftJoin("Group_Subsites", "\"Group_Subsites\".\"GroupID\" 
						= \"Group\".\"ID\" AND \"Group_Subsites\".\"SubsiteID\" = $subsiteID");
					$query->where[] = "(\"Group_Subsites\".\"SubsiteID\" IS NOT NULL OR
						\"Group\".\"AccessAllSubsites\" = 1)";
				} else {
					$query->where[] = "\"Group\".\"AccessAllSubsites\" = 1";
				}
			}
			if(!$query->select[0] == 'COUNT(*)') {
				$query->orderby = "\"AccessAllSubsites\" DESC" . ($query->orderby ? ', ' : '') . $query->orderby;
			}
		}
	}
function augmentSQL ( SQLQuery & $ query ) { if ( Subsite :: $ disable_subsite_filter ) return ; if ( Cookie :: get ( 'noSubsiteFilter' ) == 'true' ) return ; if ( ! $ query -> filtersOnID ( ) ) { if ( $ context = DataObject :: context_obj ( ) ) $ subsiteID = ( int ) $ context -> SubsiteID ; else $ subsiteID = ( int ) Subsite :: currentSubsiteID ( ) ; $ hasGroupSubsites = false ; foreach ( $ query -> from as $ item ) if ( strpos ( $ item , 'Group_Subsites' ) !== false ) { $ hasGroupSubsites = true ; break ; } if ( ! $ hasGroupSubsites ) { if ( $ subsiteID ) { $ query -> leftJoin ( " Group_Subsites " , " \" Group_Subsites \" . \" GroupID \"  
						=  \" Group \" . \" ID \"  AND  \" Group_Subsites \" . \" SubsiteID \"  =  $ subsiteID " ) ; $ query -> where [ ] = " ( \" Group_Subsites \" . \" SubsiteID \"  IS NOT NULL OR
						 \" Group \" . \" AccessAllSubsites \"  = 1) " ; } else { $ query -> where [ ] = " \" Group \" . \" AccessAllSubsites \"  = 1 " ; } } if ( ! $ query -> select [ 0 ] == 'COUNT(*)' ) { $ query -> orderby = " \" AccessAllSubsites \"  DESC " . ( $ 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... // Don't filter by Group_Subsites if we've already done that // WORKAROUND for databases that complain about an ORDER BY when the column wasn't selected (e.g. SQL Server)