<commit_before><?php

/**
 * PluginUserLoginHistoryTable
 * 
 * This class has been auto-generated by the Doctrine ORM Framework
 */
class PluginUserLoginHistoryTable extends Doctrine_Table
{
    /**
     * Returns an instance of this class.
     *
     * @return object PluginUserLoginHistoryTable
     */
    public static function getInstance()
    {
        return Doctrine_Core::getTable('PluginUserLoginHistory');
    }

  static public function writeLoginHistory(sfEvent $event)
  {
    $params = $event->getParameters();
    if(true === $params['authenticated'])
    {
      $history = new UserLoginHistory();
      $history->ip = getenv('HTTP_X_FORWARDED_FOR') ? getenv('HTTP_X_FORWARDED_FOR') : getenv('REMOTE_ADDR');
      $history->User = $event->getSubject()->getGuardUser();
      $history->save();
    }
  }
}<commit_msg>implemented logout history<commit_after><?php

/**
 * PluginUserLoginHistoryTable
 * 
 * This class has been auto-generated by the Doctrine ORM Framework
 */
class PluginUserLoginHistoryTable extends Doctrine_Table
{
    /**
     * Returns an instance of this class.
     *
     * @return object PluginUserLoginHistoryTable
     */
    public static function getInstance()
    {
        return Doctrine_Core::getTable('PluginUserLoginHistory');
    }

  static public function writeLoginHistory(sfEvent $event)
  {
    $sessionUser = $event->getSubject();
    $params = $event->getParameters();
    if(true === $params['authenticated'])
    {
      $userId = $sessionUser->getGuardUser()->id;
      $sessionUser->setAttribute('user_id', $userId, 'sfDoctrineGuardLoginHistoryPlugin');
      self::createHistoryEntry('login', $userId);
    }
    else
    {
      $userId = $sessionUser->getAttributeHolder()->remove('user_id', null, 'sfDoctrineGuardLoginHistoryPlugin');
      self::createHistoryEntry('logout', $userId);
    }
  }

  protected static function createHistoryEntry($state, $userId)
  {
    $history = new UserLoginHistory();
    $history->state = $state;
    $history->user_id = $userId;
    $history->ip = getenv('HTTP_X_FORWARDED_FOR') ? getenv('HTTP_X_FORWARDED_FOR') : getenv('REMOTE_ADDR');
    $history->save();
  }
}
{'fraction_non_alphanumeric': 0.13167587476979742, 'fraction_numerical': 0.0, 'mean_word_length': 3.7863436123348015, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6268614', 'n_tokens_mistral': 647, 'n_tokens_neox': 637, 'n_words': 125}