private function onAdd() { $form = $this->formAdd(); if (false !== ($error = $form->validate($this->module))) { return $error . $this->templateAdd(); } $f = $form->getVar('password'); $flag_enc = WC_Warflag::hashPassword($f); $flag = new WC_Warflag(array('wf_id' => '0', 'wf_wbid' => $this->warbox->getID(), 'wf_order' => WC_Warflag::getNextOrder($this->warbox), '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_flag_enc' => $flag_enc, 'wf_created_at' => $form->getVar('wf_created_at'), 'wf_last_solved_at' => NULL, 'wf_last_solved_by' => NULL)); if (!$flag->insert()) { 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->increase('wb_challs'); $this->warbox->increase('wb_flags'); $this->warbox->recalcTotalscore(); $site->recalcSite(); return $this->module->message('msg_add_flag') . $this->templateOverview(); }