Exemplo n.º 1
0
 /**
  * Called to register
  */
 public function register()
 {
     $this->load->spark('robot-helper/1.1');
     $this->load->helper('robot');
     $this->load->helper('form');
     $this->load->library('form_validation');
     $submit = $this->input->post('submit');
     if ($submit) {
         if ($this->form_validation->run('registration')) {
             $this->load->model('contributor');
             $insert = elements(array('username', 'email', 'real_name', 'password', 'website'), $_POST);
             if (Contributor::insert($insert)) {
                 UserHelper::setNotice("Yay! Start contributing sparks!");
                 UserHelper::setLoggedIn(Contributor::findByUsername($insert['username']));
                 UtilityHelper::handleRedirectIfNeeded();
                 redirect(base_url() . 'contributors/' . $insert['username'] . '/profile');
             } else {
                 UserHelper::setNotice("Whoa. That didn't work. Sorry?", FALSE);
             }
         } else {
             UserHelper::setNotice('Whoops. There were some errors. Check below and re-submit!');
         }
     }
     list($question, $answer) = get_spam_check();
     $data['spam_question'] = $question;
     $data['spam_answer'] = $answer;
     $this->load->view('contributors/register', $data);
 }