admin menu per admin | group admin | group member; ouatt_users curom module

This commit is contained in:
2022-11-07 17:02:12 +01:00
parent f9e76d4e4c
commit f523aa1b25
14 changed files with 285 additions and 114 deletions

View File

@@ -0,0 +1,8 @@
name: Où Atterrir Users
type: module
description: 'Où Atterrir Users.'
package: Ouatterrir
core: 8.x
# dependencies:
# - user
core_version_requirement: ^8 || ^9

View File

@@ -0,0 +1,44 @@
<?php
/**
* @file
* Contains admin_menus.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function ouatt_users_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the editors_menus module.
case 'help.page.ouatt_users':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Où Atterrir users twicks module') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function ouatt_users_form_user_register_form_alter(&$form, $form_state, $form_id) {
$curuser = \Drupal::currentUser();
$curroles = $curuser->getRoles();
if ( in_array('group_admin', $curroles) && !in_array(['admin', 'root'], $curroles) ){
// role. Group admin can only create "groupe member" user
$form['role_change']['widget']['#default_value'] = ['group_member'];
$form['role_change']['#disabled'] = true;
$form['role_change']['#attributes']['class'][] = 'js-hide';
// status. Always active
$form['account']['status']['#default_value'] = 1;
$form['account']['status']['#disabled'] = true;
$form['account']['status']['#attributes']['class'][] = 'js-hide';
}
}