Skip to content
Snippets Groups Projects
Commit 8c2b42de authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2323939 by jhodgdon: Fixed Views user language field/filter is for...

Issue #2323939 by jhodgdon: Fixed Views user language field/filter is for original language code, no translation language field/filter.
parent ba1393b7
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -457,11 +457,11 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ...@@ -457,11 +457,11 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setDescription(t('The user language code.')); ->setDescription(t('The user language code.'));
$fields['preferred_langcode'] = BaseFieldDefinition::create('language') $fields['preferred_langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Preferred admin language code')) ->setLabel(t('Preferred language code'))
->setDescription(t("The user's preferred language code for receiving emails and viewing the site.")); ->setDescription(t("The user's preferred language code for receiving emails and viewing the site."));
$fields['preferred_admin_langcode'] = BaseFieldDefinition::create('language') $fields['preferred_admin_langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Preferred language code')) ->setLabel(t('Preferred admin language code'))
->setDescription(t("The user's preferred language code for viewing administration pages.")) ->setDescription(t("The user's preferred language code for viewing administration pages."))
->setDefaultValue(''); ->setDefaultValue('');
......
...@@ -7,66 +7,41 @@ ...@@ -7,66 +7,41 @@
namespace Drupal\user; namespace Drupal\user;
use Drupal\views\EntityViewsDataInterface; use Drupal\views\EntityViewsData;
/** /**
* Provides the views data for the user entity type. * Provides the views data for the user entity type.
*/ */
class UserViewsData implements EntityViewsDataInterface { class UserViewsData extends EntityViewsData {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getViewsData() { public function getViewsData() {
// Define the base group of this table. Fields that don't have a group defined $data = parent::getViewsData();
// will go into this field by default.
$data['users']['table']['group'] = t('User'); $data['users']['table']['base']['help'] = t('Users who have created accounts on your site.');
$data['users']['table']['base']['access query tag'] = 'user_access';
$data['users']['table']['base'] = array(
'field' => 'uid',
'title' => t('User'),
'help' => t('Users who have created accounts on your site.'),
'access query tag' => 'user_access',
);
$data['users']['table']['entity type'] = 'user';
$data['users']['table']['wizard_id'] = 'user'; $data['users']['table']['wizard_id'] = 'user';
$data['users_field_data']['table']['group'] = t('User'); $data['users']['uid']['field']['id'] = 'user';
$data['users_field_data']['table']['entity type'] = 'user'; $data['users']['uid']['argument']['id'] = 'user_uid';
$data['users_field_data']['table']['join']['users'] = array( $data['users']['uid']['argument'] += array(
'type' => 'INNER', 'name table' => 'users_field_data',
'left_field' => 'uid', 'name field' => 'name',
'empty field name' => \Drupal::config('user.settings')->get('anonymous'),
);
$data['users']['uid']['filter']['id'] = 'user_name';
$data['users']['uid']['filter']['title'] = t('Name');
$data['users']['uid']['relationship'] = array(
'title' => t('Content authored'),
'help' => t('Relate content to the user who created it. This relationship will create one record for each content item created by the user.'),
'id' => 'standard',
'base' => 'node_field_data',
'base field' => 'uid',
'field' => 'uid', 'field' => 'uid',
); 'label' => t('nodes'),
$data['users']['uid'] = array(
'title' => t('Uid'),
'help' => t('The user ID'),
'field' => array(
'id' => 'user',
),
'argument' => array(
'id' => 'user_uid',
'name table' => 'users_field_data',
'name field' => 'name',
'empty field name' => \Drupal::config('user.settings')->get('anonymous'),
),
'filter' => array(
'title' => t('Name'),
'id' => 'user_name',
),
'sort' => array(
'id' => 'standard',
),
'relationship' => array(
'title' => t('Content authored'),
'help' => t('Relate content to the user who created it. This relationship will create one record for each content item created by the user.'),
'id' => 'standard',
'base' => 'node_field_data',
'base field' => 'uid',
'field' => 'uid',
'label' => t('nodes'),
),
); );
$data['users']['uid_raw'] = array( $data['users']['uid_raw'] = array(
...@@ -104,59 +79,23 @@ public function getViewsData() { ...@@ -104,59 +79,23 @@ public function getViewsData() {
), ),
); );
$data['users_field_data']['name'] = array( $data['users_field_data']['name']['help'] = t('The user or author name.');
'title' => t('Name'), $data['users_field_data']['name']['field']['id'] = 'user_name';
'help' => t('The user or author name.'), $data['users_field_data']['name']['filter']['title'] = t('Name (raw)');
'field' => array( $data['users_field_data']['name']['filter']['help'] = t('The user or author name. This filter does not check if the user exists and allows partial matching. Does not utilize autocomplete.');
'id' => 'user_name',
),
'sort' => array(
'id' => 'standard',
),
'argument' => array(
'id' => 'string',
),
'filter' => array(
'id' => 'string',
'title' => t('Name (raw)'),
'help' => t('The user or author name. This filter does not check if the user exists and allows partial matching. Does not utilize autocomplete.')
),
);
// Note that this field implements field level access control. // Note that this field implements field level access control.
$data['users_field_data']['mail'] = array( $data['users_field_data']['mail']['help'] = t('Email address for a given user. This field is normally not shown to users, so be cautious when using it.');
'title' => t('Email'), $data['users_field_data']['mail']['field']['id'] = 'user_mail';
'help' => t('Email address for a given user. This field is normally not shown to users, so be cautious when using it.'),
'field' => array(
'id' => 'user_mail',
),
'sort' => array(
'id' => 'standard',
),
'filter' => array(
'id' => 'string',
),
'argument' => array(
'id' => 'string',
),
);
$data['users']['langcode'] = array( $data['users']['langcode']['id'] = 'user_language';
'title' => t('Language'), $data['users']['langcode']['help'] = t('Original language of the user information');
'help' => t('Language of the user'), $data['users_field_data']['langcode']['help'] = t('Language of the translation of user information');
'field' => array(
'id' => 'user_language', $data['users_field_data']['preferred_langcode']['title'] = t('Preferred language');
), $data['users_field_data']['preferred_langcode']['help'] = t('Preferred language of the user');
'sort' => array( $data['users_field_data']['preferred_admin_langcode']['title'] = t('Preferred admin language');
'id' => 'standard', $data['users_field_data']['preferred_admin_langcode']['help'] = t('Preferred administrative language of the user');
),
'filter' => array(
'id' => 'language',
),
'argument' => array(
'id' => 'language',
),
);
$data['users']['view_user'] = array( $data['users']['view_user'] = array(
'field' => array( 'field' => array(
...@@ -167,20 +106,6 @@ public function getViewsData() { ...@@ -167,20 +106,6 @@ public function getViewsData() {
), ),
); );
$data['users_field_data']['created'] = array(
'title' => t('Created date'),
'help' => t('The date the user was created.'),
'field' => array(
'id' => 'date',
),
'sort' => array(
'id' => 'date'
),
'filter' => array(
'id' => 'date',
),
);
$data['users_field_data']['created_fulldate'] = array( $data['users_field_data']['created_fulldate'] = array(
'title' => t('Created date'), 'title' => t('Created date'),
'help' => t('Date in the form of CCYYMMDD.'), 'help' => t('Date in the form of CCYYMMDD.'),
...@@ -235,66 +160,13 @@ public function getViewsData() { ...@@ -235,66 +160,13 @@ public function getViewsData() {
), ),
); );
$data['users_field_data']['access'] = array( $data['users_field_data']['status']['field']['output formats'] = array(
'title' => t('Last access'), 'active-blocked' => array(t('Active'), t('Blocked')),
'help' => t("The user's last access date."),
'field' => array(
'id' => 'date',
),
'sort' => array(
'id' => 'date'
),
'filter' => array(
'id' => 'date',
),
); );
$data['users_field_data']['status']['filter']['label'] = t('Active');
$data['users_field_data']['status']['filter']['type'] = 'yes-no';
$data['users_field_data']['login'] = array( $data['users_field_data']['changed']['title'] = t('Updated date');
'title' => t('Last login'),
'help' => t("The user's last login date."),
'field' => array(
'id' => 'date',
),
'sort' => array(
'id' => 'date'
),
'filter' => array(
'id' => 'date',
),
);
$data['users_field_data']['status'] = array(
'title' => t('Status'),
'help' => t('Whether a user is active or blocked.'),
'field' => array(
'id' => 'boolean',
'output formats' => array(
'active-blocked' => array(t('Active'), t('Blocked')),
),
),
'filter' => array(
'id' => 'boolean',
'label' => t('Active'),
'type' => 'yes-no',
),
'sort' => array(
'id' => 'standard',
),
);
$data['users_field_data']['changed'] = array(
'title' => t('Updated date'),
'help' => t('The date the user was last updated.'),
'field' => array(
'id' => 'date',
),
'sort' => array(
'id' => 'date'
),
'filter' => array(
'id' => 'date',
),
);
$data['users_field_data']['changed_fulldate'] = array( $data['users_field_data']['changed_fulldate'] = array(
'title' => t('Updated date'), 'title' => t('Updated date'),
...@@ -350,6 +222,9 @@ public function getViewsData() { ...@@ -350,6 +222,9 @@ public function getViewsData() {
), ),
); );
unset($data['users_field_data']['signature']);
unset($data['users_field_data']['signature_format']);
if (\Drupal::moduleHandler()->moduleExists('filter')) { if (\Drupal::moduleHandler()->moduleExists('filter')) {
$data['users_field_data']['signature'] = array( $data['users_field_data']['signature'] = array(
'title' => t('Signature'), 'title' => t('Signature'),
...@@ -402,11 +277,8 @@ public function getViewsData() { ...@@ -402,11 +277,8 @@ public function getViewsData() {
), ),
); );
// Define the base group of this table. Fields that don't have a group defined
// will go into this field by default.
$data['users_roles']['table']['group'] = t('User'); $data['users_roles']['table']['group'] = t('User');
// Explain how this table joins to others.
$data['users_roles']['table']['join'] = array( $data['users_roles']['table']['join'] = array(
'users' => array( 'users' => array(
'left_field' => 'uid', 'left_field' => 'uid',
......
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