Example #1
0
 public function getNewsCount()
 {
     $count = 0;
     # Masters
     $this->includeClass('WC_SiteMaster');
     $mastercount = WC_SiteMaster::countMasters($this->cfgSiteMasterTime());
     if ($mastercount > 0) {
         //			$count++;
     }
     # Account Links()
     $count += $this->getNewsCountLinking();
     # Logged in?
     if (false === ($user = GWF_Session::getUser())) {
         return 0;
     }
     $db = gdo_db();
     $userid = $user->getID();
     $sites = GWF_TABLE_PREFIX . 'wc_site';
     $regat = GWF_TABLE_PREFIX . 'wc_regat';
     # Count Chall News
     $query = "SELECT 1 FROM {$regat} JOIN {$sites} ON site_id=regat_sid WHERE regat_challcount != site_challcount AND regat_uid={$userid}";
     if (false === ($result = $db->queryFirst($query, false))) {
         $count += 0;
     } else {
         $count += 1;
     }
     # Count BDay News
     if ($user->isOptionEnabled(GWF_User::SHOW_OTHER_BIRTHDAYS)) {
         $userdata = $user->getUserData();
         $bdm = isset($userdata['birthdaymark']) ? $userdata['birthdaymark'] : '00';
         if ($bdm !== sprintf('%02d', date('W'))) {
             $count += $this->getNewsCountBDay();
         }
     }
     # Regular News
     $count += $this->getRegularNewsCount();
     return $count;
 }
Example #2
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);
 }