コード例 #1
0
 /**
  * Create action : create and generate a new achievement
  * @access public
  * @return void
  */
 public function create()
 {
     $this->_open_form();
     if ($this->request->is_post()) {
         if (!$this->form->is_valid($this->params['achievement'])) {
             $this->flash['error'] = __('Fail to create achievement : Check data.');
             return;
         }
         $this->achievement = new Achievement($this->form->cleaned_data);
         $this->achievement->creator_id = $this->session['user']->id;
         if (!$this->achievement->save()) {
             $this->form->errors = $this->achievement->errors;
             $this->flash['error'] = __('Fail to create achievement : Check data.');
             return;
         }
         must_regenerate_achievement($this->achievement);
         $this->redirect_to(home_url());
         $mailer = new ApplicationMailer();
         $mailer->send_achievement_created_notification($this->achievement);
     }
 }