function quiz_views_handler_argument_quiz_nid::subselect_vids in Quiz 6.6
Same name and namespace in other branches
- 8.4 includes/views/handlers/quiz_views_handler_argument_quiz_nid.inc \quiz_views_handler_argument_quiz_nid::subselect_vids()
- 6.3 includes/views/handlers/quiz_views_handler_argument_quiz_nid.inc \quiz_views_handler_argument_quiz_nid::subselect_vids()
- 6.4 includes/views/handlers/quiz_views_handler_argument_quiz_nid.inc \quiz_views_handler_argument_quiz_nid::subselect_vids()
- 6.5 includes/views/handlers/quiz_views_handler_argument_quiz_nid.inc \quiz_views_handler_argument_quiz_nid::subselect_vids()
- 7.6 includes/views/handlers/quiz_views_handler_argument_quiz_nid.inc \quiz_views_handler_argument_quiz_nid::subselect_vids()
- 7 includes/views/handlers/quiz_views_handler_argument_quiz_nid.inc \quiz_views_handler_argument_quiz_nid::subselect_vids()
- 7.4 includes/views/handlers/quiz_views_handler_argument_quiz_nid.inc \quiz_views_handler_argument_quiz_nid::subselect_vids()
Helper method to retrieve the vid(s) the final view query should actually be run against.
Would be done in pre_query(), but $this->argument is not yet available at that time. So, called from set_argument().
2 calls to quiz_views_handler_argument_quiz_nid::subselect_vids()
- quiz_views_handler_argument_quiz_nid::query in includes/
views/ handlers/ quiz_views_handler_argument_quiz_nid.inc - Override the default behavior of query() to introduce the medial step of retrieving vids from the provided nids.
- quiz_views_handler_argument_quiz_nid::set_argument in includes/
views/ handlers/ quiz_views_handler_argument_quiz_nid.inc - Set up the argument with the vids extracted from nids.
File
- includes/
views/ handlers/ quiz_views_handler_argument_quiz_nid.inc, line 121
Class
Code
function subselect_vids() {
$from = 'FROM {quiz_node_properties} qnp';
$field = 'qnp.vid';
if (count($this->value) > 1) {
// Guaranteed to produce multiple values; therefore may need the group by
$use_group_by = TRUE;
$operator = empty($this->options['not']) ? 'IN' : 'NOT IN';
$placeholders = implode(', ', array_fill(0, count($this->value), '%d'));
$where = "WHERE qnp.nid {$operator} ({$placeholders})";
}
else {
// Multiple values only possible with a NOT; only then do we need group by
$use_group_by = !empty($this->options['not']);
$operator = empty($this->options['not']) ? '=' : '!=';
$where = "WHERE qnp.nid {$operator} %d";
}
switch ($this->options['which_vid']) {
case 'initial':
case 'latest':
// SQL operation for getting a single vids based on view config settings
$operation = $this->options['which_vid'] == 'initial' ? 'MIN' : 'MAX';
// If we need a group by clause, tag it onto the end.
$where .= $use_group_by ? ' GROUP BY qnp.nid' : '';
$result = db_query("SELECT {$operation}(qnp.vid) AS vid {$from} {$where}", $this->value);
break;
case 'all':
$result = db_query("SELECT qnp.vid AS vid {$from} {$where}", $this->value);
break;
}
$this->corresponding_vids = array();
while ($item = db_fetch_object($result)) {
$this->corresponding_vids[] = $item->vid;
}
return count($this->corresponding_vids) > 1;
}