Assume a list of entities, created by the Views module. For example a list of "All blocked/active users" which looks like so:
User name Active Created date Last login
Hillary.Trump No 06/18/2016 - 13:45
Donald.Clinton No 06/18/2016 - 13:42
Someone.Else Yes 05/12/2016 - 12:09 09/17/2017 - 11:18
Pierre.Vriens Yes 03/11/2016 - 21:05 10/06/2017 - 16:04
Dries.Buytaert Yes 11/23/2015 - 10:11 09/17/2017 - 10:38
Anonymous No
The goal is to use the Rules module to change the status for selected users from blocked
to active
. This should be possible by also using the Rules Link module, based on what's mentioned on the project page of this module, i.e.:
Features: ... The links are usually displayed using Views...
Usages: ... The Rules Link module will create a Views field for each link, which can be hidden, using the visibility conditions ...
My question: How to show authorized users a link for relevant Views results using the Rules Link module? Some more details about my question:
- The links should be shown within an extra column, (say) as last column to the right.
- Authorized users: the extra column should only be shown to users with permission to use (click) the link, say to users with role "Administrator".
- Relevant: the link should only be shown for users for which the value of the Active column is
No
. Obviously, for Anonymous it doesn't make sense to show that link (since you cannot change the status for Anonymous toactive
.
For the sake of completeness, here is an export of my (extremely basic) view related to the sample above (also note the view_of_users
path in it):
$view = new view();
$view->name = 'view_of_users';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'users';
$view->human_name = 'View of Users';
$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'] = 'All blocked/active Users';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'administer users';
$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(
'name' => 'name',
'rid' => 'rid',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'name' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'rid' => array(
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
/* 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'] = 'User name';
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE;
/* 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']['not'] = 0;
/* 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']['date_format'] = 'short';
$handler->display->display_options['fields']['created']['second_date_format'] = 'long';
/* 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'] = 'short';
$handler->display->display_options['fields']['login']['second_date_format'] = 'long';
/* Sort criterion: User: Created date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'users';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'view_of_users';