private function onEdit() { $form = $this->formEdit(); if (false !== ($error = $form->validate($this->module))) { return $error . $this->templateEdit(); } $data = array('wf_cat' => $form->getVar('wf_cat'), 'wf_score' => $form->getVar('wf_score'), 'wf_title' => $form->getVar('wf_title'), 'wf_url' => $form->getVar('wf_url'), 'wf_authors' => $form->getVar('wf_authors'), 'wf_status' => $form->getVar('wf_status'), 'wf_login' => $form->getVar('wf_login'), 'wf_created_at' => $form->getVar('wf_created_at')); $f = $form->getVar('password'); if ($f !== '') { $data['wf_flag_enc'] = WC_Warflag::hashPassword($f); } if (!$this->flag->saveVars($data)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateOverview(); } $site = $this->warbox->getSite(); if ($site->isLinear()) { $site->saveVar('site_maxscore', WC_Warflag::getTotalscoreForSite($site)); } $this->warbox->recalcTotalscore(); $site->recalcSite(); return $this->module->message('msg_edit_flag') . $this->templateOverview(); }
/** * Recalc the score for this site. * @return boolean */ private function recalcScore() { if ($this->isLinear()) { $wc = Module_WeChall::instance(); $wc->includeClass('WC_Warbox'); $wc->includeClass('WC_Warflag'); $basescore = WC_Warflag::getTotalscoreForSite($this); if ($this->isNoV1()) { // WC_RegAt::calcTotalscores() } } else { $basescore = $this->getBasescore(); $average = $this->getAverage(); $challcnt = $this->getChallcount(); $spc = $this->getVar('site_spc'); $basescore += $spc * $challcnt; $basescore += $basescore - $average * $basescore; $basescore = intval(round($basescore)); } if ($basescore !== $this->getVar('site_score')) { require_once 'WC_HistorySite.php'; if (false === WC_HistorySite::insertEntry($this->getID(), $this->getScore(), $this->getUsercount(), $this->getChallcount())) { echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); return false; } return $this->saveVar('site_score', $basescore); } return true; }