<commit_before><?

Class Controller_Registration extends Controller_Lattice {

  protected $_actionsThatGetLayout = array(
    'index',
  );

  protected $errors = NULL;
  private $user_id = NULL;

  public function action_index(){
    $this->registrationView();
  }

  public function action_create(){
    //run form validation

    $errors = $this->createUser($_POST['username'], $_POST['password'], $_POST['firstname'], $_POST['lastname'], $_POST['email']);
    if($this->errors){
      $this->registrationView();
    } else {
      $confirmation = new Confirmation('registration'
        , $_POST['email'],
        'registration',
        'confirmed', 
        array($this->user_id)
      );
      $confirmation->send();

      $view = new View('confirmationRequired');
      $this->response->body($view->render());
    }
  } 

  public function action_confirmed($user_id){
    $user = ORM::Factory('user',$user_id);
    $user->status = 'ACTIVE';
    $user->save();

    $view = new View('registrationConfirmed');
    $this->response->body($view->render());
  }

  protected function registrationView($errors=NULL){
    $view = new View('registration');<commit_msg>Added error case to registration controller<commit_after><?

Class Controller_Registration extends Controller_Lattice {

  protected $_actionsThatGetLayout = array(
    'index',
  );

  protected $errors = NULL;
  private $user_id = NULL;

  public function action_index(){
    $this->registrationView();
  }

  public function action_create(){
    //run form validation

    $errors = $this->createUser($_POST['username'], $_POST['password'], $_POST['firstname'], $_POST['lastname'], $_POST['email']);
    if($this->errors){
      $this->registrationView();
    } else {
      $confirmation = new Confirmation('registration'
        , $_POST['email'],
        'registration',
        'confirmed', 
        array($this->user_id)
      );
      $confirmation->send();

      $view = new View('confirmationRequired');
      $this->response->body($view->render());
    }
  } 

  public function action_confirmed($user_id){
    $user = ORM::Factory('user',$user_id);
    if(!$user->loaded()){
      $this->response->body('Invalid Confirmation - User Does Not Exist');
      return;
    }
    $user->status = 'ACTIVE';
    $user->save();

    $view = new View('registrationConfirmed');
    $this->response->body($view->render());
  }

  protected function registrationView($errors=NULL){
    $view = new View('registration');
{'fraction_non_alphanumeric': 0.16954600241060666, 'fraction_numerical': 0.0, 'mean_word_length': 3.5604395604395602, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, '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': '4884392', 'n_tokens_mistral': 733, 'n_tokens_neox': 700, 'n_words': 140}