<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.
 */

/**
 * sfOpenPNEMemberAction
 *
 * @package    OpenPNE
 * @subpackage action
 * @author     <NAME> <<EMAIL>>
 */
abstract class sfOpenPNEMemberAction extends sfActions
{
  public function preExecute()
  {
    $this->id = $this->getRequestParameter('id', $this->getUser()->getMemberId());

    $this->relation = Doctrine::getTable('MemberRelationship')->retrieveByFromAndTo($this->getUser()->getMemberId(), $this->id);
    if (!$this->relation) {
      $this->relation = new MemberRelationship();
      $this->relation->setMemberIdFrom($this->getUser()->getMemberId());
      $this->relation->setMemberIdTo($this->id);
    }
  }

 /**
  * Executes login action
  *
  * @param sfRequest $request A request object
  */
  public function executeLogin($request)
  {
    $this->getUser()->logout();

    $this->forms = $this->getUser()->getAuthForms();

    if ($request->hasParameter('authMode'))
    {
      if ($uri = $this->getUser()->login())
      {
        $this->redirectIf($this->getUser()->hasCredential('SNSRegisterBegin'), 'member/registerInput');
        $this->redirectIf($this->getUser()->hasCredential('SNSRegisterFinish'), $this->getUser()->getRegisterEndAction());
        $this->redirectIf($this->getUser()->hasCredential('SNSMember'), $uri);
      }
      return sfView::ERROR;
    }

    return sfView::SUCCESS;
  }

 /**
  * Executes logout action
  *
  * @param sfRequest $request A request object
  */
  public function executeLogout($request)
  {
    $this->getUser()->logout();
    $this->redirect('member/login');
  }

 /**
  * Executes register action
  *
  * @param sfRequest $request A request object
  */
  public function executeRegisterInput($request)
  {
    opActivateBehavior::disable();
    $mode = (sfConfig::get('app_is_mobile') ? 'mobile' : 'pc');
    $this->forward404Unless(opToolkit::isEnabledRegistration($mode));

    $this->form = $this->getUser()->getAuthAdapter()->getAuthRegisterForm();

    if ($request->isMethod('post'))
    {
      $this->form->bindAll($request);
      if ($this->form->isValidAll())
      {
        $result = $this->getUser()->register($this->form);
        opActivateBehavior::enable();
        $this->redirectIf($result, $this->getUser()->getRegisterEndAction());
      }
    }

    opActivateBehavior::enable();
    return sfView::SUCCESS;
  }

 /**
  * Executes home action
  *
  * @param sfRequest $request A request object
  */
  public function executeHome($request)
  {
    $this->getUser()->getMember()->updateLastLoginTime();
    return sfView::SUCCESS;
  }

 /**
  * Executes search action
  *
  * @param sfRequest $request A request object
  */
  public function executeSearch($request)
  {
    $params = $request->getParameter('member', array());

    $this->filters = new opMemberProfileSearchForm();
    $this->filters->bind($params);

    if (!isset($this->size))
    {
      $this->size = 20;
    }

    $this->pager = new sfDoctrinePager('Member', $this->size);
    $q = $this->filters->getQuery()->orderBy('id');
    $this->pager->setQuery($q);
    $this->pager->setPage($request->getParameter('page', 1));
    $this->pager->init();

    return sfView::SUCCESS;
  }

 /**
  * Executes profile action
  *
  * @param sfRequest $request A request object
  */
  public function executeProfile($request)
  {
    $this->redirectIf($this->relation->isAccessBlocked(), '@error');

    $id = $this->getRequestParameter('id', $this->getUser()->getMemberId());
    $this->member = Doctrine::getTable('Member')->find($id);
    
    $this->forward404Unless($this->member, 'Undefined member.');

    if (!$this->friendsSize)<commit_msg>#4148 fixed the ascending-order of member list in member search. it should be descending.<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.
 */

/**
 * sfOpenPNEMemberAction
 *
 * @package    OpenPNE
 * @subpackage action
 * @author     <NAME> <<EMAIL>>
 */
abstract class sfOpenPNEMemberAction extends sfActions
{
  public function preExecute()
  {
    $this->id = $this->getRequestParameter('id', $this->getUser()->getMemberId());

    $this->relation = Doctrine::getTable('MemberRelationship')->retrieveByFromAndTo($this->getUser()->getMemberId(), $this->id);
    if (!$this->relation) {
      $this->relation = new MemberRelationship();
      $this->relation->setMemberIdFrom($this->getUser()->getMemberId());
      $this->relation->setMemberIdTo($this->id);
    }
  }

 /**
  * Executes login action
  *
  * @param sfRequest $request A request object
  */
  public function executeLogin($request)
  {
    $this->getUser()->logout();

    $this->forms = $this->getUser()->getAuthForms();

    if ($request->hasParameter('authMode'))
    {
      if ($uri = $this->getUser()->login())
      {
        $this->redirectIf($this->getUser()->hasCredential('SNSRegisterBegin'), 'member/registerInput');
        $this->redirectIf($this->getUser()->hasCredential('SNSRegisterFinish'), $this->getUser()->getRegisterEndAction());
        $this->redirectIf($this->getUser()->hasCredential('SNSMember'), $uri);
      }
      return sfView::ERROR;
    }

    return sfView::SUCCESS;
  }

 /**
  * Executes logout action
  *
  * @param sfRequest $request A request object
  */
  public function executeLogout($request)
  {
    $this->getUser()->logout();
    $this->redirect('member/login');
  }

 /**
  * Executes register action
  *
  * @param sfRequest $request A request object
  */
  public function executeRegisterInput($request)
  {
    opActivateBehavior::disable();
    $mode = (sfConfig::get('app_is_mobile') ? 'mobile' : 'pc');
    $this->forward404Unless(opToolkit::isEnabledRegistration($mode));

    $this->form = $this->getUser()->getAuthAdapter()->getAuthRegisterForm();

    if ($request->isMethod('post'))
    {
      $this->form->bindAll($request);
      if ($this->form->isValidAll())
      {
        $result = $this->getUser()->register($this->form);
        opActivateBehavior::enable();
        $this->redirectIf($result, $this->getUser()->getRegisterEndAction());
      }
    }

    opActivateBehavior::enable();
    return sfView::SUCCESS;
  }

 /**
  * Executes home action
  *
  * @param sfRequest $request A request object
  */
  public function executeHome($request)
  {
    $this->getUser()->getMember()->updateLastLoginTime();
    return sfView::SUCCESS;
  }

 /**
  * Executes search action
  *
  * @param sfRequest $request A request object
  */
  public function executeSearch($request)
  {
    $params = $request->getParameter('member', array());

    $this->filters = new opMemberProfileSearchForm();
    $this->filters->bind($params);

    if (!isset($this->size))
    {
      $this->size = 20;
    }

    $this->pager = new sfDoctrinePager('Member', $this->size);
    $q = $this->filters->getQuery()->orderBy('id desc');
    $this->pager->setQuery($q);
    $this->pager->setPage($request->getParameter('page', 1));
    $this->pager->init();

    return sfView::SUCCESS;
  }

 /**
  * Executes profile action
  *
  * @param sfRequest $request A request object
  */
  public function executeProfile($request)
  {
    $this->redirectIf($this->relation->isAccessBlocked(), '@error');

    $id = $this->getRequestParameter('id', $this->getUser()->getMemberId());
    $this->member = Doctrine::getTable('Member')->find($id);
    
    $this->forward404Unless($this->member, 'Undefined member.');

    if (!$this->friendsSize)
{'fraction_non_alphanumeric': 0.17926813719240087, 'fraction_numerical': 0.002805049088359046, 'mean_word_length': 3.646919431279621, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 185, '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': '4880745', 'n_tokens_mistral': 2424, 'n_tokens_neox': 2366, 'n_words': 445}