You are here

public function PostAccountStream::query in Open Social 8.5

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()
  2. 8 modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()
  3. 8.2 modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()
  4. 8.3 modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()
  5. 8.4 modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()
  6. 8.6 modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()
  7. 8.7 modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()
  8. 8.8 modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()
  9. 10.3.x modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()
  10. 10.0.x modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()
  11. 10.1.x modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()
  12. 10.2.x modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php \Drupal\social_post\Plugin\views\filter\PostAccountStream::query()

Query for the activity stream on the account pages.

Overrides FilterPluginBase::query

File

modules/social_features/social_post/src/Plugin/views/filter/PostAccountStream.php, line 39

Class

PostAccountStream
Filters post on my stream.

Namespace

Drupal\social_post\Plugin\views\filter

Code

public function query() {

  // Profile user.
  $account_profile = \Drupal::routeMatch()
    ->getParameter('user');

  // Visibility logic when visiting a post stream on account page:
  // - All the posts to community, public by the account user.
  // - All the posts to the user by other users in the community.
  // Same logic for users who are visiting another OR own profile.
  $this->query
    ->addTable('post__field_visibility');
  $this->query
    ->addTable('post__field_recipient_user');
  $or_condition = db_or();

  // Or posted by the user to the community.
  $public_community_condition = db_and();
  $public_community_condition
    ->condition('post_field_data.user_id', $account_profile
    ->id(), '=');
  $public_community_condition
    ->condition('post__field_visibility.field_visibility_value', [
    '1',
    '2',
  ], 'IN');
  $or_condition
    ->condition($public_community_condition);

  // Or posted to the user by the community.
  $recipient_condition = db_and();
  $recipient_condition
    ->condition('post__field_visibility.field_visibility_value', '0', '=');
  $recipient_condition
    ->condition('post__field_recipient_user.field_recipient_user_target_id', $account_profile
    ->id(), '=');
  $or_condition
    ->condition($recipient_condition);
  $this->query
    ->addWhere('visibility', $or_condition);
}