public function query() {
    $account = $this->view->getUser();
    $this->query->addTable('post__field_visibility');

    $and_condition = db_and();
    $should_add_where_clause = FALSE;
    if (!$account->hasPermission('view public posts')) {
      $and_condition->condition('post__field_visibility.field_visibility_value', '1', '!=');
      $should_add_where_clause = TRUE;
    }
    if (!$account->hasPermission('view community posts')) {
      $and_condition->condition('post__field_visibility.field_visibility_value', '2', '!=');
      $should_add_where_clause = TRUE;
    }
    if ($should_add_where_clause) {
      $this->query->addWhere('visibility', $and_condition);
    }
  }