You are here

function social_group_preprocess_profile in Open Social 8.9

Same name and namespace in other branches
  1. 8 modules/social_features/social_group/social_group.module \social_group_preprocess_profile()
  2. 8.2 modules/social_features/social_group/social_group.module \social_group_preprocess_profile()
  3. 8.3 modules/social_features/social_group/social_group.module \social_group_preprocess_profile()
  4. 8.4 modules/social_features/social_group/social_group.module \social_group_preprocess_profile()
  5. 8.5 modules/social_features/social_group/social_group.module \social_group_preprocess_profile()
  6. 8.6 modules/social_features/social_group/social_group.module \social_group_preprocess_profile()
  7. 8.7 modules/social_features/social_group/social_group.module \social_group_preprocess_profile()
  8. 8.8 modules/social_features/social_group/social_group.module \social_group_preprocess_profile()
  9. 10.3.x modules/social_features/social_group/social_group.module \social_group_preprocess_profile()
  10. 10.0.x modules/social_features/social_group/social_group.module \social_group_preprocess_profile()
  11. 10.1.x modules/social_features/social_group/social_group.module \social_group_preprocess_profile()
  12. 10.2.x modules/social_features/social_group/social_group.module \social_group_preprocess_profile()

Implements hook_preprocess_HOOK().

File

modules/social_features/social_group/social_group.module, line 1368
The Social group module.

Code

function social_group_preprocess_profile(&$variables) {
  $group = _social_group_get_current_group();
  if ($group instanceof Group && $variables['elements']['#view_mode'] == 'teaser') {
    $account = $variables['elements']['#profile']
      ->get('uid')->entity;
    if (!($member = $group
      ->getMember($account))) {
      return;
    }
    $roles = $member
      ->getRoles();
    if (isset($roles[$group
      ->bundle() . '-group_manager'])) {
      $variables['badges'] = [
        [
          'label' => t('Group manager'),
          'classes' => [
            'badge-secondary teaser__badge',
          ],
        ],
      ];
    }
  }
}