function recalculate_score($id)
 {
     $score_to_calculate = User_score::get_score_for_recalculate($id);
     $score_only = User_score::find($id);
     $file_only = Ranked_file::find($score_to_calculate[0]->file_id);
     $this->data['score'] = $score_to_calculate;
     $user_percent = calculate_dp_percent($score_to_calculate[0]) / 100;
     if ($user_percent < 0.91) {
         $this->data['new_difficulty'] = "Score below 91%, not calculated.";
     } else {
         if ($user_percent > 0.97) {
             $user_percent = 0.97;
         }
         $this->_process_everything($file_only->raw_file, $file_only->rate, $user_percent);
         $applied_difficulty = $this->data['user_score_goal_result'];
         $score_only->applied_score = $applied_difficulty;
         $score_only->save();
         $this->data['new_difficulty'] = $applied_difficulty;
     }
     $this->layout_view = "ajax";
     $this->content_view = "ajax/recalculate_score";
 }
 public function remove($score_id = null)
 {
     $this->require_login();
     if (!$score_id) {
         redirect('home');
     } else {
         if (User_score::count(array('conditions' => array('id = ?', $score_id))) != 1) {
             redirect('home');
         } else {
             $user_score = User_score::find($score_id);
             $write_mod_log = false;
             if ($user_score->user_id != $this->session->userdata('user_id')) {
                 if ($this->session->userdata('user_level') < 2) {
                     redirect('home');
                 } else {
                     $write_mod_log = true;
                 }
             }
             $this->data['user_score'] = $user_score;
             $song = Ranked_file::find($user_score->file_id);
             $this->data['song'] = $song;
             $user_score->status = "removed";
             $user_score->save();
             $scores_user = User::find($user_score->user_id);
             if ($write_mod_log) {
                 $log_string = $this->session->userdata('username') . " (" . $this->session->userdata('display_name') . ") removed user score: " . $scores_user->username . " (" . $scores_user->display_name . ") " . $song->title . " " . number_format($song->rate, 2) . "x";
                 write_to_mod_log($log_string);
             }
             $this->content_view = "scores/removed";
         }
     }
 }
 function pending_scores($id = null, $status = null)
 {
     if (!empty($id) && !empty($status) && ($status == "pending" || $status == "below_aa" || $status == "approved" || $status == "rejected")) {
         $id = intval($id);
         $sf = User_score::find($id);
         $sf->status = $status;
         $sf->save();
     }
     $this->data['subtitle'] = "Approve Pending Scores";
     $this->data['scores'] = User_score::get_pending_scores();
     $this->content_view = "mod/pending_scores";
 }