Commit 7232dbf9 authored by catch's avatar catch

Issue #2024893 by bdone, dawehner: Change status filter on admin/people to 'active'/'blocked'.

parent c094757a
......@@ -802,7 +802,7 @@ display:
exposed: '1'
expose:
operator_id: ''
label: Active
label: ''
description: ''
use_operator: '0'
operator: status_op
......@@ -814,18 +814,26 @@ display:
authenticated: authenticated
anonymous: '0'
administrator: '0'
is_grouped: '0'
is_grouped: '1'
group_info:
label: ''
label: 'Status'
description: ''
identifier: ''
identifier: status
optional: '1'
widget: select
multiple: '0'
remember: '0'
default_group: All
default_group_multiple: { }
group_items: { }
group_items:
1:
title: Active
operator: '='
value: '1'
2:
title: Blocked
operator: '='
value: '0'
plugin_id: boolean
provider: views
uid_raw:
......
......@@ -89,7 +89,7 @@ function testUserAdmin() {
$this->assertEqual($account->status, 0, 'User C blocked');
// Test filtering on admin page for blocked users
$this->drupalGet('admin/people', array('query' => array('status' => 0)));
$this->drupalGet('admin/people', array('query' => array('status' => 2)));
$this->assertNoText($user_a->name, 'User A not on filtered by status on admin users page');
$this->assertNoText($user_b->name, 'User B not on filtered by status on admin users page');
$this->assertText($user_c->name, 'User C on filtered by status on admin users page');
......
......@@ -250,7 +250,7 @@ function user_views_data() {
);
$data['users']['status'] = array(
'title' => t('Active status'),
'title' => t('Status'),
'help' => t('Whether a user is active or blocked.'),
'field' => array(
'id' => 'boolean',
......
......@@ -1233,7 +1233,7 @@ public function convertExposedInput(&$input, $selected_group_id = NULL) {
$input[$this->options['expose']['operator']] = $this->options['group_info']['group_items'][$selected_group]['operator'];
// Value can be optional, For example for 'empty' and 'not empty' filters.
if (!empty($this->options['group_info']['group_items'][$selected_group]['value'])) {
if (isset($this->options['group_info']['group_items'][$selected_group]['value']) && $this->options['group_info']['group_items'][$selected_group]['value'] != '') {
$input[$this->options['expose']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value'];
}
$this->options['expose']['use_operator'] = TRUE;
......
......@@ -98,5 +98,84 @@ public function testFilterBooleanOperator() {
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
}
/**
* Tests the boolean filter with grouped exposed form enabled.
*/
public function testFilterGroupedExposed() {
$filters = $this->getGroupedExposedFilters();
$view = views_get_view('test_view');
$view->setExposedInput(array('status' => 1));
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
$this->executeView($view);
$expected_result = array(
array('id' => 1),
array('id' => 3),
array('id' => 5),
);
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$view->destroy();
$view->setExposedInput(array('status' => 2));
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
$this->executeView($view);
$expected_result = array(
array('id' => 2),
array('id' => 4),
);
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
}
/**
* Provides grouped exposed filter configuration.
*
* @return array
*/
protected function getGroupedExposedFilters() {
$filters = array(
'status' => array(
'id' => 'status',
'table' => 'views_test_data',
'field' => 'status',
'relationship' => 'none',
'exposed' => TRUE,
'expose' => array(
'operator' => 'status_op',
'label' => 'status',
'identifier' => 'status',
),
'is_grouped' => TRUE,
'group_info' => array(
'label' => 'status',
'identifier' => 'status',
'default_group' => 'All',
'group_items' => array(
1 => array(
'title' => 'Active',
'operator' => '=',
'value' => '1',
),
2 => array(
'title' => 'Blocked',
'operator' => '=',
'value' => '0',
),
),
),
),
);
return $filters;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment