/**
  * Set_winner action : set the winner of an achievement
  * (the achievement state changes to unlocked)
  * @access public
  * @return void
  */
 public function set_winner()
 {
     if (!$this->_load_achievement()) {
         $this->redirect_to(home_url());
         return;
     }
     if (!$this->achievement->is_locked() || !$this->session['user']->is_creator_of($this->achievement)) {
         $this->flash['error'] = __('You can\'t modify this achievement.');
         $this->redirect_to(home_url());
         return;
     }
     $this->_open_setWinnerForm();
     if ($this->request->is_post()) {
         if (!$this->form->is_valid($this->params['achievement'])) {
             $this->flash['error'] = __('Fail to set the winner : Check data.');
             return;
         }
         $this->achievement->state = 'unlocked';
         $this->achievement->winner_id = $this->form->cleaned_data['winner_id'];
         $this->winner = $this->form->cleaned_data['winner'];
         if (!$this->achievement->save()) {
             $this->form->errors = $this->achievement->errors;
             $this->flash['error'] = __('Fail to set the winner : Check data.');
             return;
         }
         must_regenerate_achievement($this->achievement);
         must_regenerate_userImage($this->winner);
         $this->redirect_to(home_url());
         $mailer = new ApplicationMailer();
         $mailer->send_achievement_won_notification($this->achievement);
     }
 }