function social_group_menu_local_tasks_alter in Open Social 8
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
- 8.2 modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
- 8.3 modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
- 8.4 modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
- 8.5 modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
- 8.6 modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
- 8.7 modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
- 8.8 modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
- 10.3.x modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
- 10.0.x modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
- 10.1.x modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
- 10.2.x modules/social_features/social_group/social_group.module \social_group_menu_local_tasks_alter()
Implements hook_menu_local_tasks_alter().
File
- modules/
social_features/ social_group/ social_group.module, line 803 - The Social group module.
Code
function social_group_menu_local_tasks_alter(&$data, $route_name) {
// Rename Group "Related Entities" tab.
if (isset($data['tabs'][0]['group.content']['#link'])) {
$data['tabs'][0]['group.content']['#link']['title'] = t('Manage members');
}
// Change the default 'View' tab title.
if (isset($data['tabs'][0]['group.view']['#link'])) {
$data['tabs'][0]['group.view']['#link']['title'] = t('Stream');
}
// Remove Edit tab. Edit will always go through Floating Edit Button.
if (isset($data['tabs'][0]['group.edit_form'])) {
unset($data['tabs'][0]['group.edit_form']);
}
$user = \Drupal::currentUser();
// Get the Group object from the route.
$group = Drupal::routeMatch()
->getParameter('group');
if ($group instanceof GroupInterface) {
/** @var \Drupal\group\Entity\GroupTypeInterface $group_type */
$group_type = $group
->getGroupType()
->id();
// Check if it's a closed group.
if ($group_type == 'closed_group') {
// And if the user is not user 1.
if ($user
->id() != 1) {
if ($user
->hasPermission('manage all groups')) {
return;
}
elseif (!$group
->getMember($user)) {
// Disable these local tasks.
$data['tabs'][0]['group.view'] = [];
$data['tabs'][0]['group.content'] = [];
$data['tabs'][0]['social_group.events'] = [];
$data['tabs'][0]['social_group.topics'] = [];
}
}
}
}
}