<commit_before><?php

/**
 * article actions.
 *
 * @package    blueprint
 * @subpackage article
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class builderActions extends sfActions
{

    public function executeIndex(sfWebRequest $request)
    {
        $this->form_id = $request->getParameter('id');
        $this->forward404Unless($this->risk_builder = Doctrine_Core::getTable('RiskBuilder')->find($this->form_id));
        $this->account = $this->risk_builder->getAccount();
        $this->form = new RiskBuilderForm($this->risk_builder);
        $this->flight_information = FlightInformationFieldTable::getAllFields($this->risk_builder->getId());
        $this->risk_factors = RiskFactorFieldTable::getAllRiskFactors($this->risk_builder->getId());

        $this->flight = new Flight();
        $this->data_fields = $this->flight->generateFromDB($this->account);
        $this->preview_form = new FlightForm(null, array('user' => $this->getUser()->getGuardUser(), 'account' => $this->account));


        if($request->isMethod('post')){
            $this->form->bind($request->getPostParameter($this->form->getName()));
            if($this->form->isValid()){
                $this->form->save();
                $this->redirect("@settings?account_id={$this->account->getId()}");
            }
        }
    }

    public function executePreviewSubmit(sfWebRequest $request) {
        $this->setLayout(false);
        $this->forward404unless($request->isXmlHttpRequest());
        $this->form_id = $request->getParameter('id');
        $this->forward404Unless($this->risk_builder = Doctrine_Core::getTable('RiskBuilder')->find($this->form_id));
        $this->account = $this->risk_builder->getAccount();
        $this->form = new RiskBuilderForm($this->risk_builder);
        $this->users = sfGuardUserTable::getPilotsByAccountArray($this->account->getId());



        if($request->isMethod('post')){
            $this->form->bind($request->getPostParameter($this->form->getName()));
            if($this->form->isValid()){
                $this->flight = new Flight();
                $this->data_fields = json_decode($this->flight->generateFromDBAndForm($this->account, $this->form), true);
                $this->preview_form = new FlightForm(null, array('user' => $this->getUser()->getGuardUser(), 'account' => $this->account));
                $form_data = $this->getPartial('flight/form', array('form' => $this->preview_form, 'data' => $this->data_fields, 'users' => $this->users));
                echo json_encode(array('result' => 'OK', 'form_data' => $form_data));
            }
        }
        return sfView::NONE;
    }

    public function executeSaveRiskFactor(sfWebRequest $request) {
        $this->setLayout(false);
        $this->forward404unless($request->isXmlHttpRequest());
        $form = new RiskFactorOptionsForm();
        if($request->isMethod('post')){
            $form->bind($request->getParameter($form->getName()));
            if($form->isValid()){
                $form->save();
                $risk_builder = Doctrine_Core::getTable('RiskBuilder')->find($request->getParameter('form_builder_id'));
                $account = $risk_builder->getAccount();
                if(!$account->getHasModifiedForm){
                    $account->setHasModifiedForm(true);
                    $account->save();
                }
                $form->getObject()->setRiskBuilder($risk_builder);
                $form->getObject()->setPosition(RiskFactorFieldTable::getMaxPosition() + 1);
                $form->getObject()->save();

                echo json_encode(
                    array(
                        'result' => 'OK',
                        'risk_id' => $form->getObject()->getId(),
                        'new_form_num' => $request->getParameter('new_form_num'),
                        'question' => $form->getObject()->getQuestion()
                    )
                );
            } else {
                echo json_encode(
                    array(
                        'result' => 'Failed',
                    )
                );

            }<commit_msg>Risk Assessment Email<commit_after><?php

/**
 * article actions.
 *
 * @package    blueprint
 * @subpackage article
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class builderActions extends sfActions
{

    public function executeIndex(sfWebRequest $request)
    {
        $this->form_id = $request->getParameter('id');
        $this->forward404Unless($this->risk_builder = Doctrine_Core::getTable('RiskBuilder')->find($this->form_id));
        $this->account = $this->risk_builder->getAccount();
        $this->form = new RiskBuilderForm($this->risk_builder);
        $this->flight_information = FlightInformationFieldTable::getAllFields($this->risk_builder->getId());
        $this->risk_factors = RiskFactorFieldTable::getAllRiskFactors($this->risk_builder->getId());

        $this->flight = new Flight();
        $this->data_fields = $this->flight->generateFromDB($this->account);
        $this->preview_form = new FlightForm(null, array('user' => $this->getUser()->getGuardUser(), 'account' => $this->account));


        if($request->isMethod('post')){
            $this->form->bind($request->getPostParameter($this->form->getName()));
            if($this->form->isValid()){
                $this->form->save();
                $this->redirect("@settings?account_id={$this->account->getId()}");
            }
        }
    }

    public function executePreviewSubmit(sfWebRequest $request) {
        $this->setLayout(false);
        $this->forward404unless($request->isXmlHttpRequest());
        $this->form_id = $request->getParameter('id');
        $this->forward404Unless($this->risk_builder = Doctrine_Core::getTable('RiskBuilder')->find($this->form_id));
        $this->account = $this->risk_builder->getAccount();
        $this->form = new RiskBuilderForm($this->risk_builder);
        $this->users = sfGuardUserTable::getPilotsByAccountArray($this->account->getId());



        if($request->isMethod('post')){
            $this->form->bind($request->getPostParameter($this->form->getName()));
            if($this->form->isValid()){
                $this->flight = new Flight();
                $this->data_fields = json_decode($this->flight->generateFromDBAndForm($this->account, $this->form), true);
                $this->preview_form = new FlightForm(null, array('user' => $this->getUser()->getGuardUser(), 'account' => $this->account));
                $form_data = $this->getPartial('flight/form', array('form' => $this->preview_form, 'data' => $this->data_fields, 'users' => $this->users));
                echo json_encode(array('result' => 'OK', 'form_data' => $form_data));
            }
        }
        return sfView::NONE;
    }

    public function executeSaveRiskFactor(sfWebRequest $request) {
        $this->setLayout(false);
        $this->forward404unless($request->isXmlHttpRequest());
        $form = new RiskFactorOptionsForm();
        if($request->isMethod('post')){
            $form->bind($request->getParameter($form->getName()));
            if($form->isValid()){
                $form->save();
                $risk_builder = Doctrine_Core::getTable('RiskBuilder')->find($request->getParameter('form_builder_id'));
                $account = $risk_builder->getAccount();
                if(!$account->getHasModifiedForm()){
                    $account->setHasModifiedForm(true);
                    $account->save();
                }
                $form->getObject()->setRiskBuilder($risk_builder);
                $form->getObject()->setPosition(RiskFactorFieldTable::getMaxPosition() + 1);
                $form->getObject()->save();

                echo json_encode(
                    array(
                        'result' => 'OK',
                        'risk_id' => $form->getObject()->getId(),
                        'new_form_num' => $request->getParameter('new_form_num'),
                        'question' => $form->getObject()->getQuestion()
                    )
                );
            } else {
                echo json_encode(
                    array(
                        'result' => 'Failed',
                    )
                );

            }
{'fraction_non_alphanumeric': 0.17142177841179268, 'fraction_numerical': 0.007608178792201617, 'mean_word_length': 2.3909713825070535, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 239, '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': '7245761', 'n_tokens_mistral': 2416, 'n_tokens_neox': 2236, 'n_words': 296}