convert users and translations as well

8.0.x
Daniel Wehner 2012-07-29 16:40:37 -05:00 committed by Tim Plunkett
parent 797e863f35
commit d9c68d48d4
12 changed files with 131 additions and 49 deletions

View File

@ -5,12 +5,22 @@
* Definition of views_handler_field_user_language. * Definition of views_handler_field_user_language.
*/ */
namespace Views\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
/** /**
* Views field handler for user language. * Views field handler for user language.
* *
* @ingroup views_field_handlers * @ingroup views_field_handlers
*/ */
class user_language extends User {
/**
* @Plugin(
* plugin_id = "user_language"
* )
*/
class Language extends User {
function render_link($data, $values) { function render_link($data, $values) {
$uid = $this->get_value($values, 'uid'); $uid = $this->get_value($values, 'uid');

View File

@ -5,12 +5,22 @@
* Definition of views_handler_field_user_link_cancel. * Definition of views_handler_field_user_link_cancel.
*/ */
namespace Views\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
/** /**
* Field handler to present a link to user cancel. * Field handler to present a link to user cancel.
* *
* @ingroup views_field_handlers * @ingroup views_field_handlers
*/ */
class views_handler_field_user_link_cancel extends views_handler_field_user_link {
/**
* @Plugin(
* plugin_id = "user_link_cancel"
* )
*/
class views_handler_field_user_link_cancel extends Link {
function render_link($data, $values) { function render_link($data, $values) {
$uid = $values->{$this->aliases['uid']}; $uid = $values->{$this->aliases['uid']};

View File

@ -5,12 +5,22 @@
* Definition of views_handler_field_user_link_edit. * Definition of views_handler_field_user_link_edit.
*/ */
namespace Views\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
/** /**
* Field handler to present a link to user edit. * Field handler to present a link to user edit.
* *
* @ingroup views_field_handlers * @ingroup views_field_handlers
*/ */
class views_handler_field_user_link_edit extends views_handler_field_user_link {
/**
* @Plugin(
* plugin_id = "user_link_edit"
* )
*/
class LinkEdit extends Link {
function render_link($data, $values) { function render_link($data, $values) {
// Build a pseudo account object to be able to check the access. // Build a pseudo account object to be able to check the access.
$account = entity_create('user', array()); $account = entity_create('user', array());

View File

@ -5,12 +5,23 @@
* Definition of views_handler_field_user_mail. * Definition of views_handler_field_user_mail.
*/ */
namespace Views\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
/**
/** /**
* Field handler to provide acess control for the email field. * Field handler to provide acess control for the email field.
* *
* @ingroup views_field_handlers * @ingroup views_field_handlers
*/ */
class user_mail extends User {
/**
* @Plugin(
* plugin_id = "user_mail"
* )
*/
class Mail extends User {
function option_definition() { function option_definition() {
$options = parent::option_definition(); $options = parent::option_definition();
$options['link_to_user'] = array('default' => 'mailto'); $options['link_to_user'] = array('default' => 'mailto');

View File

@ -5,12 +5,23 @@
* Definition of views_handler_field_user_permissions. * Definition of views_handler_field_user_permissions.
*/ */
namespace Views\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\field\PrerenderList;
/** /**
* Field handler to provide a list of permissions. * Field handler to provide a list of permissions.
* *
* @ingroup views_field_handlers * @ingroup views_field_handlers
*/ */
class views_handler_field_user_permissions extends views_handler_field_prerender_list {
/**
* @Plugin(
* plugin_id = "user_permissions"
* )
*/
class Permissions extends PrerenderList {
function construct() { function construct() {
parent::construct(); parent::construct();
$this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid'); $this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid');

View File

@ -5,6 +5,9 @@
* Definition of views_handler_field_user_picture. * Definition of views_handler_field_user_picture.
*/ */
namespace Views\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
/** /**
@ -12,7 +15,13 @@ use Drupal\views\Plugin\views\field\FieldPluginBase;
* *
* @ingroup views_field_handlers * @ingroup views_field_handlers
*/ */
class views_handler_field_user_picture extends FieldPluginBase {
/**
* @Plugin(
* plugin_id = "user_picture"
* )
*/
class Picture extends FieldPluginBase {
function construct() { function construct() {
parent::construct(); parent::construct();
$this->additional_fields['uid'] = 'uid'; $this->additional_fields['uid'] = 'uid';

View File

@ -5,6 +5,9 @@
* Definition of views_handler_field_user_roles. * Definition of views_handler_field_user_roles.
*/ */
namespace Views\user\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\field\PrerenderList; use Drupal\views\Plugin\views\field\PrerenderList;
/** /**
@ -12,7 +15,13 @@ use Drupal\views\Plugin\views\field\PrerenderList;
* *
* @ingroup views_field_handlers * @ingroup views_field_handlers
*/ */
class views_handler_field_user_roles extends PrerenderList {
/**
* @Plugin(
* plugin_id = "user_roles"
* )
*/
class Roles extends PrerenderList {
function construct() { function construct() {
parent::construct(); parent::construct();
$this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid'); $this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid');

View File

@ -5,6 +5,9 @@
* Definition of views_handler_filter_user_current. * Definition of views_handler_filter_user_current.
*/ */
namespace Views\user\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\filter\BooleanOperator; use Drupal\views\Plugin\views\filter\BooleanOperator;
/** /**
@ -12,7 +15,13 @@ use Drupal\views\Plugin\views\filter\BooleanOperator;
* *
* @ingroup views_filter_handlers * @ingroup views_filter_handlers
*/ */
class views_handler_filter_user_current extends BooleanOperator {
/**
* @Plugin(
* plugin_id = "user_current"
* )
*/
class Current extends BooleanOperator {
function construct() { function construct() {
parent::construct(); parent::construct();
$this->value_value = t('Is the logged in user'); $this->value_value = t('Is the logged in user');

View File

@ -5,6 +5,9 @@
* Definition of views_handler_filter_user_permissions. * Definition of views_handler_filter_user_permissions.
*/ */
namespace Views\user\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\filter\ManyToOne; use Drupal\views\Plugin\views\filter\ManyToOne;
/** /**
@ -12,7 +15,13 @@ use Drupal\views\Plugin\views\filter\ManyToOne;
* *
* @ingroup views_filter_handlers * @ingroup views_filter_handlers
*/ */
class views_handler_filter_user_permissions extends ManyToOne {
/**
* @Plugin(
* plugin_id = "user_permissions"
* )
*/
class Permissions extends ManyToOne {
function get_value_options() { function get_value_options() {
$module_info = system_get_info('module'); $module_info = system_get_info('module');

View File

@ -5,6 +5,9 @@
* Definition of views_handler_filter_user_roles. * Definition of views_handler_filter_user_roles.
*/ */
namespace Views\user\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\filter\ManyToOne; use Drupal\views\Plugin\views\filter\ManyToOne;
/** /**
@ -12,7 +15,13 @@ use Drupal\views\Plugin\views\filter\ManyToOne;
* *
* @ingroup views_filter_handlers * @ingroup views_filter_handlers
*/ */
class views_handler_filter_user_roles extends ManyToOne {
/**
* @Plugin(
* plugin_id = "user_roles"
* )
*/
class Roles extends ManyToOne {
function get_value_options() { function get_value_options() {
$this->value_options = user_roles(TRUE); $this->value_options = user_roles(TRUE);
unset($this->value_options[DRUPAL_AUTHENTICATED_RID]); unset($this->value_options[DRUPAL_AUTHENTICATED_RID]);

View File

@ -47,16 +47,16 @@ function user_views_data() {
'title' => t('Uid'), 'title' => t('Uid'),
'help' => t('The user ID'), // The help that appears on the UI, 'help' => t('The user ID'), // The help that appears on the UI,
'field' => array( 'field' => array(
'handler' => 'views_handler_field_user', 'plugin_id' => 'user',
'click sortable' => TRUE, 'click sortable' => TRUE,
), ),
'argument' => array( 'argument' => array(
'handler' => 'views_handler_argument_user_uid', 'plugin_id' => 'user_uid',
'name field' => 'name', // display this field in the summary 'name field' => 'name', // display this field in the summary
), ),
'filter' => array( 'filter' => array(
'title' => t('Name'), 'title' => t('Name'),
'handler' => 'views_handler_filter_user_name', 'plugin_id' => 'user_name',
), ),
'sort' => array( 'sort' => array(
'plugin_id' => 'standard', 'plugin_id' => 'standard',
@ -104,7 +104,7 @@ function user_views_data() {
'title' => t('Current'), 'title' => t('Current'),
'help' => t('Filter the view to the currently logged in user.'), 'help' => t('Filter the view to the currently logged in user.'),
'filter' => array( 'filter' => array(
'handler' => 'views_handler_filter_user_current', 'plugin_id' => 'user_current',
'type' => 'yes-no', 'type' => 'yes-no',
), ),
); );
@ -114,7 +114,7 @@ function user_views_data() {
'title' => t('Name'), // The item it appears as on the UI, 'title' => t('Name'), // The item it appears as on the UI,
'help' => t('The user or author name.'), // The help that appears on the UI, 'help' => t('The user or author name.'), // The help that appears on the UI,
'field' => array( 'field' => array(
'handler' => 'views_handler_field_user_name', 'plugin_id' => 'user_name',
'click sortable' => TRUE, 'click sortable' => TRUE,
), ),
'sort' => array( 'sort' => array(
@ -136,7 +136,7 @@ function user_views_data() {
'title' => t('E-mail'), // The item it appears as on the UI, 'title' => t('E-mail'), // The item it appears as on the UI,
'help' => t('Email address for a given user. This field is normally not shown to users, so be cautious when using it.'), // The help that appears on the UI, 'help' => t('Email address for a given user. This field is normally not shown to users, so be cautious when using it.'), // The help that appears on the UI,
'field' => array( 'field' => array(
'handler' => 'views_handler_field_user_mail', 'plugin_id' => 'user_mail',
'click sortable' => TRUE, 'click sortable' => TRUE,
), ),
'sort' => array( 'sort' => array(
@ -155,17 +155,17 @@ function user_views_data() {
'title' => t('Language'), // The item it appears as on the UI, 'title' => t('Language'), // The item it appears as on the UI,
'help' => t('Language of the user'), 'help' => t('Language of the user'),
'field' => array( 'field' => array(
'handler' => 'views_handler_field_user_language', 'plugin_id' => 'user_language',
'click sortable' => TRUE, 'click sortable' => TRUE,
), ),
'sort' => array( 'sort' => array(
'plugin_id' => 'standard', 'plugin_id' => 'standard',
), ),
'filter' => array( 'filter' => array(
'handler' => 'views_handler_filter_node_language', 'plugin_id' => 'node_language',
), ),
'argument' => array( 'argument' => array(
'handler' => 'views_handler_argument_node_language', 'plugin_id' => 'node_language',
), ),
); );
@ -176,7 +176,7 @@ function user_views_data() {
'help' => t("The user's picture, if allowed."), // The help that appears on the UI, 'help' => t("The user's picture, if allowed."), // The help that appears on the UI,
// Information for displaying the uid // Information for displaying the uid
'field' => array( 'field' => array(
'handler' => 'views_handler_field_user_picture', 'plugin_id' => 'user_picture',
'click sortable' => TRUE, 'click sortable' => TRUE,
), ),
'sort' => array( 'sort' => array(
@ -194,7 +194,7 @@ function user_views_data() {
'field' => array( 'field' => array(
'title' => t('Link'), 'title' => t('Link'),
'help' => t('Provide a simple link to the user.'), 'help' => t('Provide a simple link to the user.'),
'handler' => 'views_handler_field_user_link', 'plugin_id' => 'user_link',
), ),
); );
@ -219,7 +219,7 @@ function user_views_data() {
'help' => t('Date in the form of CCYYMMDD.'), 'help' => t('Date in the form of CCYYMMDD.'),
'argument' => array( 'argument' => array(
'field' => 'created', 'field' => 'created',
'handler' => 'views_handler_argument_node_created_fulldate', 'plugin_id' => 'node_created_fulldate',
), ),
); );
@ -228,7 +228,7 @@ function user_views_data() {
'help' => t('Date in the form of YYYYMM.'), 'help' => t('Date in the form of YYYYMM.'),
'argument' => array( 'argument' => array(
'field' => 'created', 'field' => 'created',
'handler' => 'views_handler_argument_node_created_year_month', 'plugin_id' => 'node_created_year_month',
), ),
); );
@ -238,7 +238,7 @@ function user_views_data() {
'help' => t('Date in the form of YYYY.'), 'help' => t('Date in the form of YYYY.'),
'argument' => array( 'argument' => array(
'field' => 'created', 'field' => 'created',
'handler' => 'views_handler_argument_node_created_year', 'plugin_id' => 'node_created_year',
), ),
); );
@ -247,7 +247,7 @@ function user_views_data() {
'help' => t('Date in the form of MM (01 - 12).'), 'help' => t('Date in the form of MM (01 - 12).'),
'argument' => array( 'argument' => array(
'field' => 'created', 'field' => 'created',
'handler' => 'views_handler_argument_node_created_month', 'plugin_id' => 'node_created_month',
), ),
); );
@ -256,7 +256,7 @@ function user_views_data() {
'help' => t('Date in the form of DD (01 - 31).'), 'help' => t('Date in the form of DD (01 - 31).'),
'argument' => array( 'argument' => array(
'field' => 'created', 'field' => 'created',
'handler' => 'views_handler_argument_node_created_day', 'plugin_id' => 'node_created_day',
), ),
); );
@ -265,7 +265,7 @@ function user_views_data() {
'help' => t('Date in the form of WW (01 - 53).'), 'help' => t('Date in the form of WW (01 - 53).'),
'argument' => array( 'argument' => array(
'field' => 'created', 'field' => 'created',
'handler' => 'views_handler_argument_node_created_week', 'plugin_id' => 'node_created_week',
), ),
); );
@ -341,7 +341,7 @@ function user_views_data() {
'field' => array( 'field' => array(
'title' => t('Edit link'), 'title' => t('Edit link'),
'help' => t('Provide a simple link to edit the user.'), 'help' => t('Provide a simple link to edit the user.'),
'handler' => 'views_handler_field_user_link_edit', 'plugin_id' => 'user_link_edit',
), ),
); );
@ -349,7 +349,7 @@ function user_views_data() {
'field' => array( 'field' => array(
'title' => t('Cancel link'), 'title' => t('Cancel link'),
'help' => t('Provide a simple link to cancel the user.'), 'help' => t('Provide a simple link to cancel the user.'),
'handler' => 'views_handler_field_user_link_cancel', 'plugin_id' => 'user_link_cancel',
), ),
); );
@ -390,15 +390,15 @@ function user_views_data() {
'title' => t('Roles'), 'title' => t('Roles'),
'help' => t('Roles that a user belongs to.'), 'help' => t('Roles that a user belongs to.'),
'field' => array( 'field' => array(
'handler' => 'views_handler_field_user_roles', 'plugin_id' => 'user_roles',
'no group by' => TRUE, 'no group by' => TRUE,
), ),
'filter' => array( 'filter' => array(
'handler' => 'views_handler_filter_user_roles', 'plugin_id' => 'user_roles',
'allow empty' => TRUE, 'allow empty' => TRUE,
), ),
'argument' => array( 'argument' => array(
'handler' => 'views_handler_argument_users_roles_rid', 'plugin_id' => 'users_roles_rid',
'name table' => 'role', 'name table' => 'role',
'name field' => 'name', 'name field' => 'name',
'empty field name' => t('No role'), 'empty field name' => t('No role'),
@ -450,11 +450,11 @@ function user_views_data() {
'title' => t('Permission'), 'title' => t('Permission'),
'help' => t('The user permissions.'), 'help' => t('The user permissions.'),
'field' => array( 'field' => array(
'handler' => 'views_handler_field_user_permissions', 'plugin_id' => 'user_permissions',
'no group by' => TRUE, 'no group by' => TRUE,
), ),
'filter' => array( 'filter' => array(
'handler' => 'views_handler_filter_user_permissions', 'plugin_id' => 'user_permissions',
), ),
); );
@ -526,21 +526,6 @@ function user_views_data() {
return $data; return $data;
} }
/**
* Implements hook_views_plugins().
*/
function user_views_plugins() {
return array(
'argument validator' => array(
'user' => array(
'title' => t('User'),
'handler' => 'views_plugin_argument_validate_user',
'path' => drupal_get_path('module', 'views') . '/modules/user', // not necessary for most modules
),
),
);
}
/** /**
* Allow replacement of current userid so we can cache these queries * Allow replacement of current userid so we can cache these queries
*/ */