예제 #1
0
파일: ChallEdit.php 프로젝트: sinfocol/gwf3
 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;
 }