<commit_before><?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */

class CommunityMemberTable extends opAccessControlDoctrineTable
{
  public function retrieveByMemberIdAndCommunityId($memberId, $communityId)
  {
    $query = $this->createQuery()
        ->where('member_id = ?', $memberId)
        ->andWhere('community_id = ?', $communityId);

    $object = $query->fetchOne();
    $query->free();

    return $object;
  }

  protected function isPosition($memberId, $communityId, $position)
  {
    $object = $this->retrieveByMemberIdAndCommunityId($memberId, $communityId);
    if ($object)
    {
      $result = $object->hasPosition($position);
      $object->free(true);

      return $result;
    }
    return false;
  }

  public function isMember($memberId, $communityId)
  {
    $object = $this->retrieveByMemberIdAndCommunityId($memberId, $communityId);
    if ($object)
    {
      $object->free(true);

      return !$this->isPreMember($memberId, $communityId);
    }
    return false;
  }

  public function isPreMember($memberId, $communityId)
  {
    $object = $this->retrieveByMemberIdAndCommunityId($memberId, $communityId);
    if ($object && $object->getIsPre())
    {
      $object->free(true);

      return true;
    }
    return false;
  }

  public function isAdmin($memberId, $communityId)
  {
    return $this->isPosition($memberId, $communityId, 'admin');
  }

  public function isSubAdmin($memberId, $communityId)
  {
    return $this->isPosition($memberId, $communityId, 'sub_admin');
  }
<commit_msg>Revert "improved performance while join member to community (#927)" (fixes #3445)<commit_after><?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */

class CommunityMemberTable extends opAccessControlDoctrineTable
{
  public function retrieveByMemberIdAndCommunityId($memberId, $communityId)
  {
    return $this->createQuery()
        ->where('member_id = ?', $memberId)
        ->andWhere('community_id = ?', $communityId)
        ->fetchOne();
  }

  protected function isPosition($memberId, $communityId, $position)
  {
    $object = $this->retrieveByMemberIdAndCommunityId($memberId, $communityId);
    if ($object)
    {
      return $object->hasPosition($position);
    }
    return false;
  }

  public function isMember($memberId, $communityId)
  {
    if ($this->retrieveByMemberIdAndCommunityId($memberId, $communityId))
    {
      return !$this->isPreMember($memberId, $communityId);
    }
    return false;
  }

  public function isPreMember($memberId, $communityId)
  {
    $object = $this->retrieveByMemberIdAndCommunityId($memberId, $communityId);
    if ($object && $object->getIsPre())
    {
      return true;
    }
    return false;
  }

  public function isAdmin($memberId, $communityId)
  {
    return $this->isPosition($memberId, $communityId, 'admin');
  }

  public function isSubAdmin($memberId, $communityId)
  {
    return $this->isPosition($memberId, $communityId, 'sub_admin');
  }

{'fraction_non_alphanumeric': 0.13285671730711945, 'fraction_numerical': 0.002085195114685731, 'mean_word_length': 3.7496463932107496, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1363824', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1018, 'n_words': 235}