Ejemplo n.º 1
0
 /**
  * On Register we link you to wechall.
  * @param GWF_User $user
  * @param array $args
  * @return string error msg 
  */
 public function hookRegister(GWF_User $user, array $args)
 {
     # Link to WeChall
     if (false === ($site = WC_Site::getWeChall())) {
         return true;
     }
     require_once 'WC_RegAt.php';
     $regat = new WC_RegAt(array('regat_uid' => $user->getID(), 'regat_sid' => $site->getID(), 'regat_onsitename' => $user->getVar('user_name'), 'regat_onsitescore' => 0, 'regat_challcount' => $site->getVar('site_challcount'), 'regat_options' => 0, 'regat_langid' => $site->getLangID(), 'regat_tagbits' => $site->getTagBits()));
     if (false === $regat->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $site->increase('site_linkcount', 1)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     require_once 'WC_FirstLink.php';
     if (false === WC_FirstLink::insertFirstLink($user, $site, $user->getVar('user_name'), 0)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return true;
 }
Ejemplo n.º 2
0
 public function onLinkSiteAfterMail(WC_Site $site, GWF_User $user, $onsitename)
 {
     if (WC_Freeze::isUserFrozenOnSite($user->getID(), $site->getID())) {
         return $this->module->error('err_site_ban', array($site->displayName()));
     }
     if ($site->isUserLinked($user)) {
         return $this->module->error('err_already_linked', array($site->displayName()));
     }
     $siteid = $site->getVar('site_id');
     $userid = $user->getVar('user_id');
     if (false !== WC_RegAt::getUserByOnsiteName($onsitename, $siteid)) {
         return $this->module->error('err_already_linked2', array(GWF_HTML::display($onsitename), $site->displayName()));
     }
     $options = 0;
     $options |= $site->isDefaultHidden() ? WC_RegAt::HIDE_SITENAME : 0;
     $regat = new WC_RegAt(array('regat_uid' => $userid, 'regat_sid' => $siteid, 'regat_onsitename' => $onsitename, 'regat_onsitescore' => 0, 'regat_challcount' => $site->getVar('site_challcount'), 'regat_options' => $options, 'regat_langid' => $site->getLangID(), 'regat_tagbits' => $site->getTagBits(), 'regat_linkdate' => GWF_Time::getDate(GWF_Date::LEN_DAY)));
     if (false === $regat->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $site->increase('site_linkcount', 1)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $error = $site->onUpdateUser($user, true, true);
     if (false === ($regat2 = WC_RegAt::getRegatRow($userid, $siteid))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_FirstLink.php';
     if (false === WC_FirstLink::insertFirstLink($user, $site, $onsitename, $regat2->getOnsiteScore())) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $error->display($this->module->lang('btn_linked_sites')) . $this->module->message('msg_site_linked', array($site->displayName()));
 }