summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2013-07-13 11:03:08 (GMT)
committer Nathaniel Catchpole2013-07-13 11:03:08 (GMT)
commit7232dbf9f1d031a56034e09b58bbacd6864439c9 (patch)
tree68c124bf1b4bd4cb042707b6f4ed2ba95ec7607b
parentc094757a99aebea8c39a5b4255b4122845f704d2 (diff)
Issue #2024893 by bdone, dawehner: Change status filter on admin/people to 'active'/'blocked'.
-rw-r--r--core/modules/user/config/views.view.user_admin_people.yml18
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php2
-rw-r--r--core/modules/user/user.views.inc2
-rw-r--r--core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php2
-rw-r--r--core/modules/views/lib/Drupal/views/Tests/Handler/FilterBooleanOperatorTest.php79
5 files changed, 95 insertions, 8 deletions
diff --git a/core/modules/user/config/views.view.user_admin_people.yml b/core/modules/user/config/views.view.user_admin_people.yml
index ad49d68..89fd1c9 100644
--- a/core/modules/user/config/views.view.user_admin_people.yml
+++ b/core/modules/user/config/views.view.user_admin_people.yml
@@ -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:
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php b/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php
index b9c01fa..55bef92 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php
@@ -89,7 +89,7 @@ class UserAdminTest extends WebTestBase {
$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');
diff --git a/core/modules/user/user.views.inc b/core/modules/user/user.views.inc
index f9b35ca..0a8b49b 100644
--- a/core/modules/user/user.views.inc
+++ b/core/modules/user/user.views.inc
@@ -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',
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php
index ec65d2c..81b4289 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php
@@ -1233,7 +1233,7 @@ abstract class FilterPluginBase extends HandlerBase {
$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;
diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterBooleanOperatorTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterBooleanOperatorTest.php
index d354f0f..77841f3 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterBooleanOperatorTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterBooleanOperatorTest.php
@@ -98,5 +98,84 @@ class FilterBooleanOperatorTest extends ViewUnitTestBase {
$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;
+ }
+
}