-
Notifications
You must be signed in to change notification settings - Fork 11
/
oe_authentication.module
61 lines (52 loc) · 1.87 KB
/
oe_authentication.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* @file
* OpenEuropa Authentication module.
*/
declare(strict_types=1);
/**
* Implements hook_user_cancel_methods_alter().
*
* Remove the option to delete users while keeping the option to block them.
*/
function oe_authentication_user_cancel_methods_alter(&$methods) {
if (\Drupal::currentUser()->id() == 1) {
return;
}
$restricted_options = [
'user_cancel_reassign',
'user_cancel_delete',
];
foreach ($restricted_options as $restricted_option) {
unset($methods[$restricted_option]);
}
}
/**
* Implements hook_menu_local_actions_alter().
*
* Change the title for the Add Cas users link added by the Cas module.
*/
function oe_authentication_menu_local_actions_alter(&$local_actions) {
if (isset($local_actions['cas.bulk_add_cas_users'])) {
$local_actions['cas.bulk_add_cas_users']['title'] = t('Add EU Login user');
}
}
/**
* Implements hook_form_form_id_alter().
*
* Replace CAS from strings in the "bulk add users" form.
*/
function oe_authentication_form_bulk_add_cas_users_alter(&$form, &$form_state, $form_id) {
if (isset($form['intro']['#markup'])) {
$form['intro']['#markup'] = t('Use this form to pre-register one or more users, allowing them to log in using EU Login.');
}
if (isset($form['cas_usernames']['#title'])) {
$form['cas_usernames']['#title'] = t('EU Login username(s)');
}
if (isset($form['roles']['#description'])) {
$form['roles']['#description'] = t('Optionally assign one or more roles to each user. Note that if you have EU Login configured to assign roles during automatic registration on login, those will be ignored.');
}
if (isset($form['extra_info']['#markup'])) {
$form['extra_info']['#markup'] = t('Note that because EU Login attributes are only available when a user has logged in, any role or field assignment based on attributes will not be available using this form.');
}
}