diff --git a/README.md b/README.md index 92c101a..9be7ff3 100644 --- a/README.md +++ b/README.md @@ -1 +1,37 @@ -NExteEuropa User Managemente +NextEuropa User Management + +# Setting up +You will need to add into the settings.php one of the following to 'variable': +```php +$conf['nexteuropa_user_management_banned_roles'] = array(); +$conf['nexteuropa_user_management_banned_role_ids'] = array(); +``` + +Inside the `nexteuropa_user_management_banned_roles` include the role names +(string type) which you want to exclude as a grantable role by User management +users. +Inside the `nexteuropa_user_management_banned_role_ids` include the role ids +(integer type except the two exception see below) which you want to exclude as a +grantable role by User management users. + +To exclude Administrator role use `` token in the +`nexteuropa_user_management_banned_role_ids` array. +To exclude User management role use `` token in the +`nexteuropa_user_management_banned_role_ids` array. + +So to exclude as grantable role for User management user, put this into the +settings.php: +```php +$conf['nexteuropa_user_management_banned_role_ids'] = array( + '', + '', +); +``` + +## Default values for setting variables +If `nexteuropa_user_management_banned_roles` remains undefined, it will be +considered as an empty array. +If the `nexteuropa_user_management_banned_role_ids` remains undefined, it will +be considered as admin and user management was set. +The two condition above are independent from eachother, by defining role names, +won't remove role ids' default values. diff --git a/nexteuropa_user_management.actions.inc b/nexteuropa_user_management.actions.inc new file mode 100644 index 0000000..7440a27 --- /dev/null +++ b/nexteuropa_user_management.actions.inc @@ -0,0 +1,208 @@ + array( + 'label' => t('Block the selected user'), + 'type' => 'user', + 'configurable' => FALSE, + 'triggers' => array(), + ), + 'nexteuropa_user_management_unblock_selected_user_action' => array( + 'label' => t('Unblock the selected user'), + 'type' => 'user', + 'configurable' => FALSE, + 'triggers' => array(), + ), + 'nexteuropa_user_management_change_user_roles_action' => array( + 'label' => t('Change user roles'), + 'type' => 'user', + 'configurable' => TRUE, + 'triggers' => array(), + ), + ); +} + +/** + * Block a specific user. + * + * @param object $entity + * (optional) An entity object; if it is provided and it has a uid property, + * the user with that ID is blocked. + * @param array $context + * (optional) An associative array; currently not used here. + * + * @ingroup actions + * + * @throws \Exception + */ +function nexteuropa_user_management_block_selected_user_action(&$entity, $context = array()) { + // If there's no user or tries to modify himself then exit. + if (!isset($entity->uid) || $entity->uid === $GLOBALS['user']->uid) { + return; + } + + $account = user_load($entity->uid); + $account = user_save($account, array('status' => 0)); + watchdog('action', 'User %name blocked.', array('%name' => $account->name)); +} + +/** + * Unblock a specific user. + * + * @param object $entity + * (optional) An entity object; if it is provided and it has a uid property, + * the user with that ID is unblocked. + * @param array $context + * (optional) An associative array; currently not used here. + * + * @ingroup actions + * + * @throws \Exception + */ +function nexteuropa_user_management_unblock_selected_user_action(&$entity, $context = array()) { + // If there's no user or tries to modify himself then exit. + if (!isset($entity->uid) || $entity->uid === $GLOBALS['user']->uid) { + return; + } + + $account = user_load($entity->uid); + $account = user_save($account, array('status' => 1)); + watchdog('action', 'Unblock user %name.', array('%name' => $account->name)); +} + +/** + * Action settings form. + * + * @param array $context + * Provides a context for the action form. + * + * @return array + * Renderable array. + */ +function nexteuropa_user_management_change_user_roles_action_form($context) { + if (!user_access('nexteuropa manage users non restricted operations') && !user_access('administer permissions')) { + drupal_set_message(t('Your user does not have access to modify user roles.'), 'error'); + return array(); + } + + $roles = user_roles(TRUE); + // Can't edit authenticated role. + unset($roles[DRUPAL_AUTHENTICATED_RID]); + + // If the current user has access to grant any role (i.e. user 1 and + // administrator role), it's useless to restrict here the list, however if it + // has no this right, restrict it. + if (!user_access('administer permissions')) { + _nexteuropa_user_management_restrict_roles($roles); + } + + if (empty($roles)) { + return array( + 'message' => array( + '#markup' => t("There's no role which you can assign."), + ), + ); + } + + $form = array(); + $form['add_roles'] = array( + '#type' => 'checkboxes', + '#title' => t('Add roles'), + '#description' => t('Choose one or more roles you would like to assign to the selected users.'), + '#options' => $roles, + ); + $form['remove_roles'] = array( + '#type' => 'checkboxes', + '#title' => t('Remove roles'), + '#description' => t('Choose one or more roles you would like to remove from the selected users.'), + '#options' => $roles, + ); + + return $form; +} + +/** + * Provides a validation for the action form. + * + * @param array $form + * Action form, renderable array. + * @param array $form_state + * Action form state. + */ +function nexteuropa_user_management_change_user_roles_action_validate($form, $form_state) { + if (!$form_state['values']['add_roles'] && !$form_state['values']['remove_roles']) { + form_set_error('add_roles', t('You have not chosen any role to add or remove. Please select something to do.')); + } +} + +/** + * Action form submit handler, it will returns roles. + * + * @param array $form + * Action form's renderable array. + * @param array $form_state + * Action form's state. + * + * @return array + * Returns the action form results. Roles to remove and add to the selected + * users. + */ +function nexteuropa_user_management_change_user_roles_action_submit($form, $form_state) { + return array( + 'add_roles' => array_filter($form_state['values']['add_roles']), + 'remove_roles' => array_filter($form_state['values']['remove_roles']), + ); +} + +/** + * Add/remove roles for the 'Change user roles' action. + * + * @param object $entity + * An user entity, roles will be modified on this entity. + * @param array $context + * Determinates which roles will be added, by the 'add_roles' array key, and + * which will be removed by the 'remove_roles' key. Changes will be made on + * the $entity object. + */ +function nexteuropa_user_management_change_user_roles_action($entity, $context = array()) { + // Silently exit if: + // - there's no user or + // - tries to modify himself or + // - nothing to be set or + // - user does not have permission to change roles. + if ( + !isset($entity->uid) || + $entity->uid === $GLOBALS['user']->uid || + empty($context['add_roles']) && empty($context['remove_roles']) || + !user_access('nexteuropa manage users non restricted operations') && !user_access('administer permissions') + ) { + return; + } + + $wrapper = entity_metadata_wrapper('user', $entity); + + $original_roles = $roles = $wrapper->roles->value(); + if (is_array($context['add_roles'])) { + $roles = array_merge($roles, $context['add_roles']); + } + if (is_array($context['remove_roles'])) { + $roles = array_diff($roles, $context['remove_roles']); + } + $wrapper->roles->set($roles); + $wrapper->save(); + + watchdog('action', 'Roles was modified on %name user, added: "%added_roles", removed: "%removed_roles" and original: "%original_roles".', array( + '%name' => $wrapper->label(), + '%added_roles' => implode(', ', $context['add_roles']), + '%removed_roles' => implode(', ', $context['remove_roles']), + '%original_roles' => implode(', ', $original_roles), + )); +} diff --git a/nexteuropa_user_management.features.inc b/nexteuropa_user_management.features.inc new file mode 100644 index 0000000..818fe83 --- /dev/null +++ b/nexteuropa_user_management.features.inc @@ -0,0 +1,13 @@ + "3.0"); +} diff --git a/nexteuropa_user_management.info b/nexteuropa_user_management.info new file mode 100644 index 0000000..9f62fea --- /dev/null +++ b/nexteuropa_user_management.info @@ -0,0 +1,15 @@ +name = NextEuropa User Management +description = Provides a role with view to be able to manage the users. +core = 7.x +package = NextEuropa +hidden = TRUE +dependencies[] = ctools +dependencies[] = entity +dependencies[] = features +dependencies[] = views +dependencies[] = views_bulk_operations +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[views_view][] = nexteuropa_user_management +multisite_version = 2.5 +php = 5.6 diff --git a/nexteuropa_user_management.install b/nexteuropa_user_management.install new file mode 100644 index 0000000..14a46d0 --- /dev/null +++ b/nexteuropa_user_management.install @@ -0,0 +1,98 @@ + array( + 'title' => $t('Special role already exist!'), + 'description' => $t('Special role already exist! Make sure you rename it ("%role_name") before install this module.', ['%role_name' => NEXTEUROPA_USER_MANAGEMENT_USER_MANAGER_ROLE]), + 'severity' => REQUIREMENT_ERROR, + ), + ); + } + } +} + +/** + * Implements hook_install(). + */ +function nexteuropa_user_management_install() { + // Ensure translations don't break during installation. + $t = get_t(); + + $role = new stdClass(); + $role->name = NEXTEUROPA_USER_MANAGEMENT_USER_MANAGER_ROLE; + if (user_role_save($role) === FALSE) { + drupal_set_message($t('Role creation failed!'), 'error'); + return; + } + + variable_set('nexteuropa_user_management_user_manager_rid', $role->rid); + + // Do not use user_role_grant_permission() since it relies on + // hook_permission(), however hook_permission() only runs after the module is + // enabled, so in the current moment the hook_permission() didn't run, which + // means the defined permissions inside that hook is not existing yet. + db_merge('role_permission') + ->key(array( + 'rid' => $role->rid, + 'permission' => 'access nexteuropa user management views', + 'module' => 'nexteuropa_user_management', + )) + ->execute(); + db_merge('role_permission') + ->key(array( + 'rid' => $role->rid, + 'permission' => 'nexteuropa manage users non restricted operations', + 'module' => 'nexteuropa_user_management', + )) + ->execute(); + + // Grant the minimal permissions to the role to be able to access the views + // and be usable. + user_role_grant_permissions($role->rid, array( + 'access administration pages', + 'view the administration theme', + )); + + // If admin_menu is installed, grant access to that one too, otherwise user + // won't be able to navigate to the views. + if (module_exists('admin_menu')) { + user_role_grant_permissions($role->rid, array( + 'access administration menu', + )); + } + + // Add administrator role for user 1 so he can access the views. The views is + // restricted to administrator and user management role, for some reason the + // user 1 doesn't penetrate through on that restriction. + $user_1_wrapper = entity_metadata_wrapper('user', 1); + $user_1_roles = $user_1_wrapper->roles->value(); + $admin_role = variable_get('user_admin_role', 0); + if (!in_array($admin_role, $user_1_roles, FALSE)) { + $user_1_roles[] = $admin_role; + $user_1_wrapper->roles->set($user_1_roles); + $user_1_wrapper->save(); + } +} + +/** + * Implements hook_uninstall(). + */ +function nexteuropa_user_management_uninstall() { + user_role_delete((int) variable_get('nexteuropa_user_management_user_manager_rid')); +} diff --git a/nexteuropa_user_management.module b/nexteuropa_user_management.module new file mode 100644 index 0000000..bc34e96 --- /dev/null +++ b/nexteuropa_user_management.module @@ -0,0 +1,153 @@ + array( + 'title' => t('Allow to access nexteuropa user management views'), + 'restrict access' => TRUE, + ), + 'nexteuropa manage users non restricted operations' => array( + 'title' => t('Allow to manage users with non restricted operations'), + 'restrict access' => TRUE, + ), + ); +} + +/** + * Implements hook_entity_info_alter(). + */ +function nexteuropa_user_management_entity_info_alter(&$entity_info) { + $entity_info['user']['access callback'] = 'nexteuropa_user_management_metadata_user_access'; +} + +/** + * Access callback for the user entity. + */ +function nexteuropa_user_management_metadata_user_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) { + $account = isset($account) ? $account : $GLOBALS['user']; + if ($op === 'update' && user_access('nexteuropa manage users non restricted operations', $account)) { + return TRUE; + } + + // Call the original core callback too. + return entity_metadata_user_access($op, $entity, $account, $entity_type); +} + +/** + * Implements hook_module_implements_alter(). + * + * To make sure nothing will override our access callback, we need to run last. + * Because the entity module override the access callback, and using this + * technique, using weight is totally useless. + */ +function nexteuropa_user_management_module_implements_alter(&$implementations, $hook) { + if ($hook === 'entity_info_alter') { + // Move our hook implementation to the bottom. + $group = $implementations['nexteuropa_user_management']; + unset($implementations['nexteuropa_user_management']); + $implementations['nexteuropa_user_management'] = $group; + } +} + +/** + * Restrict roles according to the settings.php. + * + * @param array $roles + * A roles list to restrict. The keys should be role ids (rid) the values + * should be the role name. + */ +function _nexteuropa_user_management_restrict_roles(&$roles) { + $banned_roles = variable_get('nexteuropa_user_management_banned_roles', array()); + $banned_role_ids = variable_get('nexteuropa_user_management_banned_role_ids', array( + variable_get('user_admin_role', 0), + variable_get('nexteuropa_user_management_user_manager_rid'), + )); + + // Make sure one of the two options are set, if not, then make it unusable + // the form and provide a message. + if (empty($banned_roles) && empty($banned_role_ids)) { + $roles = array(); + drupal_set_message(t('First you need to setup the banned roles in the settings.php.'), 'error', FALSE); + return; + } + + // Check if at least the variable type is correct to prevent later on + // notifications. + if (!is_array($banned_roles) || !is_array($banned_role_ids)) { + $roles = array(); + drupal_set_message(t('Incorrect parameter type. The set variable should be an array.'), 'error', FALSE); + return; + } + + // Setup replaceable tokens. + $replacement = array( + '' => variable_get('user_admin_role', 0), + '' => variable_get('nexteuropa_user_management_user_manager_rid'), + ); + + // Replace tokens to IDs. + $banned_role_ids = array_map(function ($value) use ($replacement) { + return isset($replacement[$value]) ? $replacement[$value] : $value; + }, $banned_role_ids); + + // Unset banned role by ids. + foreach ($banned_role_ids as $banned_role_id) { + unset($roles[$banned_role_id]); + } + + // Unset banned roles by names. + $roles = array_filter($roles, function ($value) use ($banned_roles) { + return !in_array($value, $banned_roles, FALSE); + }); +} + +/** + * Implements hook_views_default_views_alter(). + */ +function nexteuropa_user_management_views_default_views_alter(&$views) { + if (array_key_exists('nexteuropa_user_management', $views)) { + $admin_rid = variable_get('user_admin_role', 0); + $user_manager_rid = variable_get('nexteuropa_user_management_user_manager_rid'); + + $view = $views['nexteuropa_user_management']; + + $handler = $view->display['default']->handler; + // Add proper roles as filtration. + $handler->display->display_options['arguments']['uid']['validate_options']['roles'] = array( + (int) $admin_rid => $admin_rid, + (int) $user_manager_rid => $user_manager_rid, + ); + + // Remove first and last name if realname module is not installed. + if (!module_exists('realname')) { + /* Display: Master */ + $handler->display->display_options['style_options']['columns'] = array_filter($handler->display->display_options['style_options']['columns'], function ($value) { + return !in_array($value, array('field_firstname', 'field_lastname')); + }); + + unset($handler->display->display_options['style_options']['info']['field_firstname']); + unset($handler->display->display_options['style_options']['info']['field_lastname']); + + /* Field: User: First name */ + unset($handler->display->display_options['fields']['field_firstname']); + /* Field: User: Last name */ + unset($handler->display->display_options['fields']['field_lastname']); + + /* Filter criterion: User: First name (field_firstname) */ + unset($handler->display->display_options['filters']['field_firstname_value']); + + /* Filter criterion: User: Last name (field_lastname) */ + unset($handler->display->display_options['filters']['field_lastname_value']); + } + } +} diff --git a/nexteuropa_user_management.views_default.inc b/nexteuropa_user_management.views_default.inc new file mode 100644 index 0000000..e93f4a8 --- /dev/null +++ b/nexteuropa_user_management.views_default.inc @@ -0,0 +1,340 @@ +name = 'nexteuropa_user_management'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'users'; + $view->human_name = 'Nexteuropa: User management'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'NextEuropa: User management'; + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['access']['perm'] = 'access nexteuropa user management views'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['style_plugin'] = 'table'; + $handler->display->display_options['style_options']['columns'] = array( + 'views_bulk_operations' => 'views_bulk_operations', + 'name' => 'name', + 'field_firstname' => 'field_firstname', + 'field_lastname' => 'field_lastname', + 'mail' => 'mail', + 'status' => 'status', + 'login' => 'login', + 'created' => 'created', + 'edit_node' => 'edit_node', + ); + $handler->display->display_options['style_options']['default'] = 'created'; + $handler->display->display_options['style_options']['info'] = array( + 'views_bulk_operations' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'name' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'field_firstname' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'field_lastname' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'mail' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'status' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'login' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'created' => array( + 'sortable' => 1, + 'default_sort_order' => 'desc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'edit_node' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 1, + ), + ); + $handler->display->display_options['style_options']['sticky'] = TRUE; + /* Field: Bulk operations: User */ + $handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['table'] = 'views_entity_user'; + $handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['display_type'] = '0'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 1; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['row_clickable'] = 1; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array( + 'action::nexteuropa_user_management_block_selected_user_action' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'skip_permission_check' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::nexteuropa_user_management_change_user_roles_action' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'skip_permission_check' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::nexteuropa_user_management_unblock_selected_user_action' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'skip_permission_check' => 0, + 'override_label' => 0, + 'label' => '', + ), + ); + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['label'] = 'Displayed name'; + $handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE; + /* Field: User: First name */ + $handler->display->display_options['fields']['field_firstname']['id'] = 'field_firstname'; + $handler->display->display_options['fields']['field_firstname']['table'] = 'field_data_field_firstname'; + $handler->display->display_options['fields']['field_firstname']['field'] = 'field_firstname'; + /* Field: User: Last name */ + $handler->display->display_options['fields']['field_lastname']['id'] = 'field_lastname'; + $handler->display->display_options['fields']['field_lastname']['table'] = 'field_data_field_lastname'; + $handler->display->display_options['fields']['field_lastname']['field'] = 'field_lastname'; + /* Field: User: E-mail */ + $handler->display->display_options['fields']['mail']['id'] = 'mail'; + $handler->display->display_options['fields']['mail']['table'] = 'users'; + $handler->display->display_options['fields']['mail']['field'] = 'mail'; + $handler->display->display_options['fields']['mail']['link_to_user'] = '0'; + /* Field: User: Active */ + $handler->display->display_options['fields']['status']['id'] = 'status'; + $handler->display->display_options['fields']['status']['table'] = 'users'; + $handler->display->display_options['fields']['status']['field'] = 'status'; + $handler->display->display_options['fields']['status']['label'] = 'Status'; + $handler->display->display_options['fields']['status']['type'] = 'active-blocked'; + $handler->display->display_options['fields']['status']['not'] = 0; + /* Field: User: Last login */ + $handler->display->display_options['fields']['login']['id'] = 'login'; + $handler->display->display_options['fields']['login']['table'] = 'users'; + $handler->display->display_options['fields']['login']['field'] = 'login'; + $handler->display->display_options['fields']['login']['date_format'] = 'custom'; + $handler->display->display_options['fields']['login']['custom_date_format'] = 'd/m/Y H:i:s'; + $handler->display->display_options['fields']['login']['second_date_format'] = 'long'; + /* Field: User: Created date */ + $handler->display->display_options['fields']['created']['id'] = 'created'; + $handler->display->display_options['fields']['created']['table'] = 'users'; + $handler->display->display_options['fields']['created']['field'] = 'created'; + $handler->display->display_options['fields']['created']['label'] = 'Registration date'; + $handler->display->display_options['fields']['created']['date_format'] = 'custom'; + $handler->display->display_options['fields']['created']['custom_date_format'] = 'd/m/Y H:i:s'; + $handler->display->display_options['fields']['created']['second_date_format'] = 'long'; + /* Field: User: Edit link */ + $handler->display->display_options['fields']['edit_node']['id'] = 'edit_node'; + $handler->display->display_options['fields']['edit_node']['table'] = 'users'; + $handler->display->display_options['fields']['edit_node']['field'] = 'edit_node'; + $handler->display->display_options['fields']['edit_node']['label'] = 'Operations'; + /* Contextual filter: Exclude current user from list */ + $handler->display->display_options['arguments']['uid']['id'] = 'uid'; + $handler->display->display_options['arguments']['uid']['table'] = 'users'; + $handler->display->display_options['arguments']['uid']['field'] = 'uid'; + $handler->display->display_options['arguments']['uid']['ui_name'] = 'Exclude current user from list'; + $handler->display->display_options['arguments']['uid']['default_action'] = 'default'; + $handler->display->display_options['arguments']['uid']['exception']['value'] = ''; + $handler->display->display_options['arguments']['uid']['default_argument_type'] = 'current_user'; + $handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['uid']['specify_validation'] = TRUE; + $handler->display->display_options['arguments']['uid']['validate']['type'] = 'user'; + $handler->display->display_options['arguments']['uid']['validate_options']['restrict_roles'] = TRUE; + $handler->display->display_options['arguments']['uid']['not'] = TRUE; + /* Filter criterion: User: Name */ + $handler->display->display_options['filters']['uid']['id'] = 'uid'; + $handler->display->display_options['filters']['uid']['table'] = 'users'; + $handler->display->display_options['filters']['uid']['field'] = 'uid'; + $handler->display->display_options['filters']['uid']['value'] = ''; + $handler->display->display_options['filters']['uid']['group'] = 1; + $handler->display->display_options['filters']['uid']['exposed'] = TRUE; + $handler->display->display_options['filters']['uid']['expose']['operator_id'] = 'uid_op'; + $handler->display->display_options['filters']['uid']['expose']['label'] = 'Ecas username'; + $handler->display->display_options['filters']['uid']['expose']['operator'] = 'uid_op'; + $handler->display->display_options['filters']['uid']['expose']['identifier'] = 'uid'; + $handler->display->display_options['filters']['uid']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 9 => 0, + 8 => 0, + 6 => 0, + 7 => 0, + 10 => 0, + ); + /* Filter criterion: User: First name (field_firstname) */ + $handler->display->display_options['filters']['field_firstname_value']['id'] = 'field_firstname_value'; + $handler->display->display_options['filters']['field_firstname_value']['table'] = 'field_data_field_firstname'; + $handler->display->display_options['filters']['field_firstname_value']['field'] = 'field_firstname_value'; + $handler->display->display_options['filters']['field_firstname_value']['operator'] = 'contains'; + $handler->display->display_options['filters']['field_firstname_value']['group'] = 1; + $handler->display->display_options['filters']['field_firstname_value']['exposed'] = TRUE; + $handler->display->display_options['filters']['field_firstname_value']['expose']['operator_id'] = 'field_firstname_value_op'; + $handler->display->display_options['filters']['field_firstname_value']['expose']['label'] = 'First name'; + $handler->display->display_options['filters']['field_firstname_value']['expose']['operator'] = 'field_firstname_value_op'; + $handler->display->display_options['filters']['field_firstname_value']['expose']['identifier'] = 'field_firstname_value'; + $handler->display->display_options['filters']['field_firstname_value']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 9 => 0, + 8 => 0, + 6 => 0, + 7 => 0, + 10 => 0, + ); + /* Filter criterion: User: Last name (field_lastname) */ + $handler->display->display_options['filters']['field_lastname_value']['id'] = 'field_lastname_value'; + $handler->display->display_options['filters']['field_lastname_value']['table'] = 'field_data_field_lastname'; + $handler->display->display_options['filters']['field_lastname_value']['field'] = 'field_lastname_value'; + $handler->display->display_options['filters']['field_lastname_value']['operator'] = 'contains'; + $handler->display->display_options['filters']['field_lastname_value']['group'] = 1; + $handler->display->display_options['filters']['field_lastname_value']['exposed'] = TRUE; + $handler->display->display_options['filters']['field_lastname_value']['expose']['operator_id'] = 'field_lastname_value_op'; + $handler->display->display_options['filters']['field_lastname_value']['expose']['label'] = 'Last name'; + $handler->display->display_options['filters']['field_lastname_value']['expose']['operator'] = 'field_lastname_value_op'; + $handler->display->display_options['filters']['field_lastname_value']['expose']['identifier'] = 'field_lastname_value'; + $handler->display->display_options['filters']['field_lastname_value']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 9 => 0, + 8 => 0, + 6 => 0, + 7 => 0, + 10 => 0, + ); + /* Filter criterion: User: E-mail */ + $handler->display->display_options['filters']['mail']['id'] = 'mail'; + $handler->display->display_options['filters']['mail']['table'] = 'users'; + $handler->display->display_options['filters']['mail']['field'] = 'mail'; + $handler->display->display_options['filters']['mail']['operator'] = 'contains'; + $handler->display->display_options['filters']['mail']['group'] = 1; + $handler->display->display_options['filters']['mail']['exposed'] = TRUE; + $handler->display->display_options['filters']['mail']['expose']['operator_id'] = 'mail_op'; + $handler->display->display_options['filters']['mail']['expose']['label'] = 'E-mail'; + $handler->display->display_options['filters']['mail']['expose']['operator'] = 'mail_op'; + $handler->display->display_options['filters']['mail']['expose']['identifier'] = 'mail'; + $handler->display->display_options['filters']['mail']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 9 => 0, + 8 => 0, + 6 => 0, + 7 => 0, + 10 => 0, + ); + /* Filter criterion: User: Active */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'users'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 'All'; + $handler->display->display_options['filters']['status']['exposed'] = TRUE; + $handler->display->display_options['filters']['status']['expose']['operator_id'] = ''; + $handler->display->display_options['filters']['status']['expose']['label'] = 'Status'; + $handler->display->display_options['filters']['status']['expose']['operator'] = 'status_op'; + $handler->display->display_options['filters']['status']['expose']['identifier'] = 'status'; + $handler->display->display_options['filters']['status']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 7 => 0, + 6 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 8 => 0, + ); + /* Filter criterion: Filter out anonymous and user 1 */ + $handler->display->display_options['filters']['uid_raw']['id'] = 'uid_raw'; + $handler->display->display_options['filters']['uid_raw']['table'] = 'users'; + $handler->display->display_options['filters']['uid_raw']['field'] = 'uid_raw'; + $handler->display->display_options['filters']['uid_raw']['ui_name'] = 'Filter out anonymous and user 1'; + $handler->display->display_options['filters']['uid_raw']['operator'] = '>'; + $handler->display->display_options['filters']['uid_raw']['value']['value'] = '1'; + + /* Display: NextEuropa: User management */ + $handler = $view->new_display('page', 'NextEuropa: User management', 'neum'); + $handler->display->display_options['path'] = 'admin/nexteuropa-user-management'; + $handler->display->display_options['menu']['type'] = 'tab'; + $handler->display->display_options['menu']['title'] = 'NextEuropa: User management'; + $handler->display->display_options['menu']['weight'] = '0'; + $handler->display->display_options['menu']['context'] = 0; + $handler->display->display_options['menu']['context_only_inline'] = 0; + $handler->display->display_options['tab_options']['weight'] = '0'; + $export['nexteuropa_user_management'] = $view; + + return $export; +}