<commit_before><?php
/**
 * sfApplyActionsLibrary is an sfActions based library for sfApplyActions class.
 * Inherit it if you want to override any methods, and still use some of the
 * original functionality.
 *
 * @author fizyk
 */
class sfApplyActionsLibrary extends sfActions
{
    //When user is applying for new account
    public function executeApply(sfRequest $request)
    {
        // we're getting default or customized applyForm for the task
        if( !( ($this->form = $this->newForm( 
                sfConfig::get( 'app_sfForkedApply_applyForm', 'sfApplyApplyForm' ))
                ) instanceof sfApplyApplyForm) )
        {
            // if the form isn't instance of sfApplyApplyForm, we don't accept it
            throw new InvalidArgumentException(
                    'The custom apply form should be instance of sfApplyApplyForm' );
        }

        //Code below is used when user is sending his application!
        if( $request->isMethod('post') )
        {
            //gathering form request in one array
            $formValues = $request->getParameter( $this->form->getName() );
            if(sfConfig::get('app_recaptcha_enabled') )
            {
                $captcha = array(
                  'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'),
                  'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'),
                );
                //Adding captcha to form array
                $formValues = array_merge( $formValues, array('captcha' => $captcha)  );
            }
            //binding request form parameters with form
            $this->form->bind($formValues);
            if ($this->form->isValid())
            {
              $guid = "n" . self::createGuid();
              $this->form->setValidate($guid);
              $this->form->save();
              $confirmation = sfConfig::get( 'app_sfForkedApply_confirmation' );
              if( $confirmation['apply'] )
              {
                try
                {
                  //Extracting object and sending creating verification mail
                  $profile = $this->form->getObject();
                  $this->sendVerificationMail($profile);
                  return 'After';
                }
                catch (Exception $e)
                {
                  //Cleaning after possible exception thrown in ::sendVerificationMail() method
                  $profile = $this->form->getObject();
                  $user = $profile->getUser();
                  $user->delete();
                  // You could re-throw $e here if you want to
                  // make it available for debugging purposes
                  return 'MailerError';
                }
              }
              else
              {
                $this->activateUser( $this->form->getObject()->getUser() );
                return $this->redirect( '@homepage' );
              }
            }
        }
    }

    //Processes reset requests
    public function executeResetRequest(sfRequest $request)
    {
        $user = $this->getUser();

        if ($user->isAuthenticated())
        {
            $this->redirect( 'sfApply/reset' );
        }
        else
        {
            // we're getting default or customized resetRequestForm for the task
            if( !( ($this->form = $this->newForm(
                    sfConfig::get( 'app_sfForkedApply_resetRequestForm', 'sfApplyResetRequestForm' ) )
                    ) instanceof sfApplyResetRequestForm) )
            {
                // if the form isn't instance of sfApplySettingsForm, we don't accept it
                throw new InvalidArgumentException( 
                        'The custom resetRequest form should be instance of sfApplyResetRequestForm'
                        );
            }
            if ($request->isMethod('post'))
            {
                //gathering form request in one array
                $formValues = $request->getParameter( $this->form->getName() );
                if(sfConfig::get('app_recaptcha_enabled') )
                {
                    $captcha = array(
                      'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'),
                      'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'),
                    );
                    //Adding captcha to form array
                    $formValues = array_merge( $formValues, array('captcha' => $captcha)  );
                }
                //binding request form parameters with form
                $this->form->bind($formValues);
                if ($this->form->isValid())
                {
                    // The form matches unverified users, but retrieveByUsername does not, so
                    // use an explicit query. We'll special-case the unverified users in
                    // resetRequestBody

                    $username_or_email = $this->form->getValue('username_or_email');
                    if (strpos($username_or_email, '@') !== false)
                    {
                        $user = Doctrine::getTable('sfGuardUser')->createQuery('u')->
                                innerJoin('u.Profile p')->where('p.email = ?', $username_or_email)->
                                fetchOne();

                    }
                    else
                    {
                        $user = Doctrine::getTable('sfGuardUser')->createQuery('u')->
                                where('username = ?', $username_or_email)->fetchOne();
                    }
                    return $this->resetRequestBody($user);
                }
            }
        }
    }

    public function executeConfirm(sfRequest $request)
    {
        $validate = $this->request->getParameter('validate');
        // 0.6.3: oops, this was in sfGuardUserProfilePeer in my application
        // and therefore never got shipped with the plugin until I built
        // a second site and spotted it!
<commit_msg>turning off password change confirmation will make it impossible to access the reset request page if not logged in<commit_after><?php
/**
 * sfApplyActionsLibrary is an sfActions based library for sfApplyActions class.
 * Inherit it if you want to override any methods, and still use some of the
 * original functionality.
 *
 * @author fizyk
 */
class sfApplyActionsLibrary extends sfActions
{
    //When user is applying for new account
    public function executeApply(sfRequest $request)
    {
        // we're getting default or customized applyForm for the task
        if( !( ($this->form = $this->newForm( 
                sfConfig::get( 'app_sfForkedApply_applyForm', 'sfApplyApplyForm' ))
                ) instanceof sfApplyApplyForm) )
        {
            // if the form isn't instance of sfApplyApplyForm, we don't accept it
            throw new InvalidArgumentException(
                    'The custom apply form should be instance of sfApplyApplyForm' );
        }

        //Code below is used when user is sending his application!
        if( $request->isMethod('post') )
        {
            //gathering form request in one array
            $formValues = $request->getParameter( $this->form->getName() );
            if(sfConfig::get('app_recaptcha_enabled') )
            {
                $captcha = array(
                  'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'),
                  'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'),
                );
                //Adding captcha to form array
                $formValues = array_merge( $formValues, array('captcha' => $captcha)  );
            }
            //binding request form parameters with form
            $this->form->bind($formValues);
            if ($this->form->isValid())
            {
              $guid = "n" . self::createGuid();
              $this->form->setValidate($guid);
              $this->form->save();
              $confirmation = sfConfig::get( 'app_sfForkedApply_confirmation' );
              if( $confirmation['apply'] )
              {
                try
                {
                  //Extracting object and sending creating verification mail
                  $profile = $this->form->getObject();
                  $this->sendVerificationMail($profile);
                  return 'After';
                }
                catch (Exception $e)
                {
                  //Cleaning after possible exception thrown in ::sendVerificationMail() method
                  $profile = $this->form->getObject();
                  $user = $profile->getUser();
                  $user->delete();
                  // You could re-throw $e here if you want to
                  // make it available for debugging purposes
                  return 'MailerError';
                }
              }
              else
              {
                $this->activateUser( $this->form->getObject()->getUser() );
                return $this->redirect( '@homepage' );
              }
            }
        }
    }

    //Processes reset requests
    public function executeResetRequest(sfRequest $request)
    {
      $user = $this->getUser();

      if ($user->isAuthenticated())
      {
        $this->redirect( 'sfApply/reset' );
      }
      else
      {
        $confirmation = sfConfig::get( 'app_sfForkedApply_confirmation' );

        $this->forward404If( !$confirmation['reset'] );
        // we're getting default or customized resetRequestForm for the task
        if( !( ($this->form = $this->newForm(
                sfConfig::get( 'app_sfForkedApply_resetRequestForm', 'sfApplyResetRequestForm' ) )
                ) instanceof sfApplyResetRequestForm) )
        {
          // if the form isn't instance of sfApplySettingsForm, we don't accept it
          throw new InvalidArgumentException(
                  'The custom resetRequest form should be instance of sfApplyResetRequestForm'
                  );
        }
        if ($request->isMethod('post'))
        {
          //gathering form request in one array
          $formValues = $request->getParameter( $this->form->getName() );
          if(sfConfig::get('app_recaptcha_enabled') )
          {
            $captcha = array(
              'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'),
              'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'),
            );
            //Adding captcha to form array
            $formValues = array_merge( $formValues, array('captcha' => $captcha)  );
          }
          //binding request form parameters with form
          $this->form->bind($formValues);
          if ($this->form->isValid())
          {
            // The form matches unverified users, but retrieveByUsername does not, so
            // use an explicit query. We'll special-case the unverified users in
            // resetRequestBody

            $username_or_email = $this->form->getValue('username_or_email');
            if (strpos($username_or_email, '@') !== false)
            {
              $user = Doctrine::getTable('sfGuardUser')->createQuery('u')->
                      innerJoin('u.Profile p')->where('p.email = ?', $username_or_email)->
                      fetchOne();

            }
            else
            {
              $user = Doctrine::getTable('sfGuardUser')->createQuery('u')->
                      where('username = ?', $username_or_email)->fetchOne();
            }
            return $this->resetRequestBody($user);
          }
        }
      }
    }

    public function executeConfirm(sfRequest $request)
    {
        $validate = $this->request->getParameter('validate');
        // 0.6.3: oops, this was in sfGuardUserProfilePeer in my application
        // and therefore never got shipped with the plugin until I built
        // a second site and spotted it!

{'fraction_non_alphanumeric': 0.10751165889407062, 'fraction_numerical': 0.0007495003331112591, 'mean_word_length': 1.6358647936786654, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 126, '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': '3388861', 'n_tokens_mistral': 3025, 'n_tokens_neox': 2851, 'n_words': 733}