Exemple #1
0
 /**
  * A score change occured for this site/regat,
  * thus we need to recalc all scores influenced by this site. (or skip that part on DDOS)
  * @param GWF_User $user
  * @param WC_RegAt $regat
  * @param int $new_score
  * @param boolean $recalc_scores
  * @param boolean $onlink
  * @return GWF_Result
  */
 public function onUpdateUserB(GWF_User $user, $regat, $new_score, $recalc_scores = true, $onlink = false, $challs_solved = -1)
 {
     $old_score = $regat->getOnsiteScore();
     $old_totalscore = $this->calcScore($regat);
     $max = $this->getOnsiteScore();
     if ($max <= 0) {
         $solved = $old_solved = 0;
     } else {
         $solved = $new_score / $max;
         $old_solved = $old_score / $max;
     }
     $regat->saveVars(array('regat_solved' => $solved, 'regat_onsitescore' => $new_score, 'regat_lastdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'regat_challsolved' => $challs_solved));
     if ($recalc_scores) {
         $this->recalcSite();
     }
     $new_totalscore = $this->calcScore($regat);
     $scoregain = $new_totalscore - $old_totalscore;
     # Insert into User History
     $comment = $this->getUserHistComment($old_score, $new_score, $onlink, $scoregain);
     $user = GWF_User::getByID($user->getID());
     require_once 'WC_HistoryUser2.php';
     $type = $this->getUserHistType($old_score, $new_score, $onlink);
     if (false === WC_HistoryUser2::insertEntry($user, $this, $type, $new_score, $old_score, $scoregain, $regat->getVar('regat_onsiterank'))) {
         return new GWF_Result(GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__)), true);
     }
     require_once 'WC_SiteMaster.php';
     if ($solved >= 1.0) {
         WC_SiteMaster::markSiteMaster($user->getID(), $this->getID());
     } elseif ($old_solved >= 1.0) {
         WC_SiteMaster::unmarkSiteMaster($user->getID(), $this->getID(), $solved);
     }
     return new GWF_Result(GWF_HTML::lang('You') . ' ' . GWF_HTML::display($comment), false);
 }