protected function alter_query(Query $query, array $conditions) { if (isset($conditions['nid'])) { $query->where('nid = ?', (int) $conditions['nid']); } $query->where('status != "spam" && status != "pending"'); return $query->order('created'); }
/** * Support for the `year`, `month` and `day` conditions. Changes the order to * `date DESC, created_at DESC`. * * If the view is of type "home" the query is altered to search for nodes which are not * excluded from _home_. */ protected function alter_query(Query $query, array $conditions) { foreach ($conditions as $property => $value) { switch ($property) { case 'year': $query->where('YEAR(date) = ?', (int) $value); break; case 'month': $query->where('MONTH(date) = ?', (int) $value); break; case 'day': $query->where('DAY(date) = ?', (int) $value); break; } } if ($this->view->type == 'home') { $query->where('is_home_excluded = 0'); } return parent::alter_query($query, $conditions)->order('date DESC, created_at DESC'); }
/** * Alerts the query to match recors of a similar language. * * A record is considered of a similar language when it doesn't have a language defined * (`language` = "") or it matches the specified language. * * @param Query $query * @param string $language The language to match. If the language is `null` the current * language is used instead. * * @return Query */ protected function scope_similar_language(Query $query, $language = null) { global $core; return $query->where('language = "" OR language = ?', $language !== null ? $language : $core->site->language); }