Skip to content
Snippets Groups Projects
Commit bd208a71 authored by Sam Boyer's avatar Sam Boyer
Browse files

Added a nullable uid filter and updated the argument. Plus some minor fixups.

parent a935757c
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,6 @@ class quiz_views_handler_argument_user_uid_nullable extends views_handler_argume
else {
$group = 0;
}
// By adding the ISNULL, joins can properly inform us about quiz state
$this->query->add_where($group, $where, $this->argument);
......
......@@ -18,8 +18,10 @@ class quiz_views_handler_filter_quiz_nid extends views_handler_filter {
var $secondary_table_alias;
var $secondary_tables = array(
'none' => array(
'secondary_group_by' => NULL,
'secondary_table' => NULL,
'secondary_group_by' => 'nid',
'secondary_table' => 'quiz_node_results',
'secondary_vid' => 'vid',
'secondary_nid' => 'nid',
),
'results' => array(
'secondary_group_by' => 'uid',
......@@ -82,7 +84,6 @@ class quiz_views_handler_filter_quiz_nid extends views_handler_filter {
}
function value_submit($form, &$form_state) {
// dsm($form_state);
$form_state['values']['options']['secondaries'] = $this->secondary_tables[$form_state['values']['options']['secondary']];
}
......
<?php
// $Id$
class quiz_views_handler_filter_user_nullable extends views_handler_filter {
function option_definition() {
$options = parent::option_definition();
$options['allow_null'] = array('default' => FALSE);
$options['use_current'] = array('default' => FALSE);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['use_current'] = array(
'#type' => 'checkbox',
'#title' => t('Use Current User'),
'#description' => t('Filter using the current user; only quiz results owned by the current user will be shown.'),
'#default_value' => $this->options['use_current'],
);
$form['allow_null'] = array(
'#type' => 'checkbox',
'#title' => t('Used for Quiz Status'),
'#description' => t('If you are using the Quiz Status, this box must be checked; otherwise, the field will not work properly.'),
'#default_value' => $this->options['allow_null'],
);
}
function admin_summary() {
return !empty($this->options['use_current']) ? t('Current User') : t('NOT Current User');
}
function query() {
$group = $this->query->set_where_group('AND', 'qnr_user');
$this->ensure_my_table();
$operator = empty($this->options['use_current']) ? '!=' : '=';
// By adding the ISNULL, joins can properly inform us about quiz state
$this->query->add_where($group, "$this->table_alias.$this->real_field $operator ***CURRENT_USER*** OR ISNULL($this->table_alias.$this->real_field)", $this->argument);
}
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ function quiz_views_handlers() {
'parent' => 'views_handler_filter',
),
'quiz_views_handler_filter_user_nullable' => array(
'parent' => 'views_handler_filter_boolean_operator',
'parent' => 'views_handler_filter',
),
// Relationships
'quiz_views_handler_relationship_vid_from_nid' => array(
......@@ -530,7 +530,7 @@ function quiz_views_data() {
'sort' => array('handler' => 'views_handler_sort'),
),
'uid' => array(
'title' => t('User ID'),
'title' => t('User'),
'help' => t('The ID of the user who took this quiz.'),
'field' => array(
'handler' => 'views_handler_field_user',
......@@ -545,6 +545,7 @@ function quiz_views_data() {
),
'filter' => array(
'handler' => 'quiz_views_handler_filter_user_nullable',
'help' => t('Filter on the user who owns the quiz results.'),
),
'sort' => array('handler' => 'views_handler_sort'),
// Related to USERS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment