`.`MultiFormIsTemporary` = 1 * * @package multiform */ class MultiFormObjectDecorator extends DataExtension { private static $db = array( 'MultiFormIsTemporary' => 'Boolean', ); private static $has_one = array( 'MultiFormSession' => 'MultiFormSession', ); public function augmentSQL(SQLQuery &$query) { // If you're querying by ID, ignore the sub-site - this is a bit ugly... if( strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false && strpos($query->where[0], "ID = ") !== 0 && !$this->wantsTemporary($query) ) { $query->where[] = "\"{$query->from[0]}\".\"MultiFormIsTemporary\" = 0"; } } /** * Determines if the current query is supposed * to be exempt from the automatic filtering out * of temporary records. * * @param SQLQuery $query * @return boolean */ protected function wantsTemporary($query) { foreach($query->where as $whereClause) { if($whereClause == "\"{$query->from[0]}\".\"MultiFormIsTemporary\" = 1") { return true; } } return false; } }