Exemple #1
0
 private function onFreeze()
 {
     $form = $this->formFreeze();
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     $userid = $this->user->getID();
     $siteid = $this->site->getID();
     if (WC_Freeze::isUserFrozenOnSite($userid, $siteid)) {
         return $this->module->message('msg_frozen', array($this->user->displayUsername(), $this->site->displayName()));
     }
     $old_totalscore = $this->user->getVar('user_level');
     # Is linked?
     if (false !== ($row = WC_RegAt::getRegatRow($userid, $siteid))) {
         # Unlink
         if (false === WC_RegAt::unlink($userid, $siteid)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         $this->site->increase('site_linkcount', -1);
         WC_RegAt::calcTotalscores();
         #($this->user);
     }
     # Insert event.
     $rank = WC_RegAt::calcExactRank($this->user);
     $this->user = GWF_User::getByID($userid);
     $totalscore = $this->user->getVar('user_level');
     WC_HistoryUser2::insertEntry($this->user, $this->site, 'ban', 0, $row->getOnsiteScore(), $totalscore - $old_totalscore);
     # Insert Freeze
     if (false === WC_Freeze::freezeUser($userid, $siteid)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     # All done :)
     return $this->module->message('msg_frozen', array($this->user->displayUsername(), $this->site->displayName()));
 }
Exemple #2
0
 private function onUnLinkSite($array)
 {
     if (false !== ($error = GWF_Form::validateCSRF_WeakS())) {
         return GWF_HTML::error('WeChall', $error);
     }
     if (!is_array($array)) {
         return '';
     }
     // TODO: Replace with appropiate PHP function
     foreach ($array as $siteid => $stub) {
         break;
     }
     if (false === ($site = WC_Site::getByID($siteid))) {
         return $this->module->error('err_site');
     }
     $user = GWF_Session::getUser();
     $userid = GWF_Session::getUserID();
     $old_totalscore = $user->getVar('user_level');
     if (WC_Freeze::isUserFrozen($userid)) {
         return $this->module->error('err_frozen');
     }
     if (false === ($regat = WC_RegAt::getRegatRow($userid, $site->getID()))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === WC_RegAt::unlink($userid, $site->getID())) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $site->increase('site_linkcount', -1);
     WC_RegAt::calcTotalscores();
     # (GWF_Session::getUser());
     $user = GWF_User::getByID($userid);
     $new_totalscore = $user->getVar('user_level');
     require_once GWF_CORE_PATH . 'module/WeChall/WC_HistoryUser2.php';
     WC_HistoryUser2::insertEntry($user, $site, 'unlink', 0, $regat->getOnsiteScore(), $new_totalscore - $old_totalscore);
     return $this->module->message('msg_site_unlinked', array($site->displayName()));
 }