Пример #1
0
 public function onAddSite()
 {
     $form = $this->getForm();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateSiteAdd();
     }
     $site = new WC_Site(array('site_status' => 'wanted', 'site_name' => $form->getVar('site_name'), 'site_classname' => $form->getVar('site_classname'), 'site_country' => 0, 'site_language' => 0, 'site_joindate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'site_launchdate' => '', 'site_authkey' => GWF_Random::randomKey(32), 'site_xauthkey' => GWF_Random::randomKey(32), 'site_irc' => '', 'site_url' => '', 'site_url_mail' => '', 'site_url_score' => '', 'site_url_profile' => '', 'site_score' => 0, 'site_basescore' => 0, 'site_avg' => 0, 'site_vote_dif' => 0, 'site_vote_fun' => 0, 'site_challcount' => 0, 'site_usercount' => 0, 'site_visit_in' => 0, 'site_visit_out' => 0, 'site_options' => 0, 'site_boardid' => 0, 'site_threadid' => 0, 'site_tags' => ''));
     if (false === $site->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     Module_WeChall::includeVotes();
     if (false === $site->onCreateVotes()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     Module_WeChall::includeForums();
     if (false === $site->onCreateBoard()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $site->onCreateThread($this->module)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteDescr.php';
     if (false === WC_SiteDescr::insertDescr($site->getID(), 1, 'Please edit me :)')) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_site_added');
 }
Пример #2
0
 private function onReset(WC_Challenge $chall)
 {
     require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
     # Remove solved
     $cid = $chall->getID();
     $solved = GDO::table('WC_ChallSolved');
     if (false === $solved->update("csolve_date='', csolve_options=0", "csolve_cid={$cid}")) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $affected = $solved->affectedRows();
     $back = GWF_HTML::message('WeChall', "Reset {$affected} players that have solved it.");
     # Remove from users from groups
     $gid = $chall->getGID();
     $usergroup = GDO::table('GWF_UserGroup');
     if (false === $usergroup->deleteWhere("ug_groupid={$gid}")) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $affected = $usergroup->affectedRows();
     $back .= GWF_HTML::message('WeChall', "Removed {$affected} players from the challenge group.");
     # Reset votes
     Module_WeChall::includeVotes();
     if (false === $chall->getVotesDif()->resetVotesSameSettings()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $chall->getVotesEdu()->resetVotesSameSettings()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $chall->getVotesFun()->resetVotesSameSettings()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $chall->onRecalcVotes()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     # reset solve count and various vars
     if (false === $chall->saveVars(array('chall_solvecount' => 0, 'chall_views' => 0, 'chall_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND)))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $back;
 }