Skip to content

Commit

Permalink
Merge pull request #2163 from EIC-EA/EICNET-3000
Browse files Browse the repository at this point in the history
EICNET-3000
  • Loading branch information
arismag authored Mar 12, 2024
2 parents ee75515 + bd52d31 commit c079239
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,10 @@ function _preprocess_discussion_teaser(&$variables, $discussion_type, $node) {
];
}

// Privacy information, if current user is anonymous remove the author.
if (\Drupal::currentUser()->isAnonymous()) {
$teaser['author'] = NULL;
}

$variables['discussion_item'] = $teaser;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ function eic_community_preprocess_node__document(array &$variables) {
$variables['#attached']['library'][] = 'flag/flag.link_ajax';
}

// Privacy information, if current user is anonymous remove the author.
if (\Drupal::currentUser()->isAnonymous()) {
$teaser['author'] = NULL;
}

$variables['document_item'] = $teaser;
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ function eic_community_preprocess_node__event(array &$variables) {
}
}

// Privacy information, if current user is anonymous remove the author.
if (\Drupal::currentUser()->isAnonymous()) {
$teaser['author'] = NULL;
}

// Get the start date of the event.
$start_date = 0;
$end_date = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ function eic_community_preprocess_node__gallery(array &$variables) {
$teaser['flags'] = [];
}

// Privacy information, if current user is anonymous remove the author.
if (\Drupal::currentUser()->isAnonymous()) {
$teaser['author'] = NULL;
}

$teaser['images'] = $images;
$teaser['type'] = [
'label' => $node->type->entity->label(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ function _eic_community_preprocess_node_news_story(array &$variables) {
}

$variables['stats'] = $stats;

// Privacy information, if current user is anonymous remove the author.
if (\Drupal::currentUser()->isAnonymous()) {
$item['author'] = NULL;
}
}

$variables['story_item'] = $item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ function eic_community_preprocess_node__video(array &$variables) {
$teaser['flags'] = [];
}

// Privacy information, if current user is anonymous remove the author.
if (\Drupal::currentUser()->isAnonymous()) {
$teaser['author'] = NULL;
}

// If we have flags, attach the js library.
if (!empty($teaser['flags'])) {
$variables['#attached']['library'][] = 'flag/flag.link_ajax';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ function eic_community_preprocess_node__wiki_page(array &$variables) {
// Remove unwanted items.
$teaser['stats'] = [];

// Privacy information, if current user is anonymous remove the author.
if (\Drupal::currentUser()->isAnonymous()) {
$teaser['author'] = NULL;
}

$variables['story_item'] = $teaser;
break;

Expand Down
5 changes: 5 additions & 0 deletions lib/themes/eic_community/includes/preprocess/groups/group.inc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ function eic_community_preprocess_group__group(array &$variables) {
// @todo Get the real last activity.
$item['timestamp']['label'] = eic_community_get_teaser_time_display($group->get('changed')->value);

// Privacy information, if current user is anonymous remove the author.
if (\Drupal::currentUser()->isAnonymous()) {
$item['owner'] = NULL;
}

// Get group statistics.
$group_statistics = \Drupal::service('eic_group_statistics.helper')->loadGroupStatistics($group);
$item['stats'] = [
Expand Down
6 changes: 4 additions & 2 deletions lib/themes/eic_community/includes/preprocess/users/user.inc
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,18 @@ function _get_profile_image_array(EntityInterface $user, $relative_url = TRUE):
* @throws \Drupal\Core\TypedData\Exception\MissingDataException
*/
function eic_community_get_teaser_user_display(UserInterface $user, $picture_image_style = 'crop_36x36') {
$current_user = \Drupal::currentUser();

// Privacy information. If current user is anonymous set user to 'Someone'.
$author = [
'name' => $user->getDisplayName(),
'name' => $current_user->isAnonymous() ? t('Someone') : $user->getDisplayName(),
];

// We add the user profile page URL if the current user has access to it.
if ($user->toUrl()->access()) {
$author['path'] = $user->toUrl()->toString();
}

$current_user = \Drupal::currentUser();
if (!$user->get('field_media')->isEmpty() && !$current_user->isAnonymous()) {
$media_entity = $user->get('field_media')->entity;
if ($media_entity) {
Expand Down
5 changes: 5 additions & 0 deletions lib/themes/eic_community/includes/preprocess/views.inc
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ function _eic_community_preprocess_views__latest_news_and_stories__homepage(&$va
'stats' => $stats,
];

// Privacy information, if current user is anonymous remove the author.
if (\Drupal::currentUser()->isAnonymous()) {
$item['author'] = NULL;
}

if (!$node_translation->get('field_image')->isEmpty()) {
/** @var \Drupal\media\Entity\Media $media */
$media = \Drupal::service('entity.repository')->getTranslationFromContext($node_translation->get('field_image')->entity, $current_langcode);
Expand Down

0 comments on commit c079239

Please sign in to comment.