Example #1
0
 public function execute()
 {
     if (false === ($this->user = GWF_Session::getUser())) {
         return GWF_HTML::err('ERR_LOGIN_REQUIRED');
     }
     if (false === ($this->site = WC_Site::getByID_Class(Common::getGetString('siteid')))) {
         return $this->module->error('err_site');
     }
     if (!GWF_User::isInGroupS(GWF_Group::STAFF)) {
         $this->module->includeClass('WC_SiteAdmin');
         if (!$this->site->isSiteAdmin($this->user)) {
             return GWF_HTML::err('ERR_NO_PERMISSION');
         }
     }
     $this->module->includeClass('WC_Warbox');
     # ADD
     if (isset($_POST['add'])) {
         return $this->onAdd();
         #.$this->templateOverview();
     }
     if (isset($_GET['add'])) {
         return $this->templateAdd();
     }
     # EDIT
     if (false !== ($boxid = Common::getGetString('edit', false))) {
         if (false === ($box = WC_Warbox::getByIDs($boxid, $this->site->getID()))) {
             return $this->module->error('err_site');
         }
     }
     if (isset($_POST['flags'])) {
         GWF_Website::redirect($this->module->getMethodURL('Warflags', '&wbid=' . $boxid));
     }
     if (isset($_POST['edit'])) {
         return $this->onEdit($box);
     }
     if (isset($_GET['edit'])) {
         return $this->templateEdit($box);
     }
     # OVERVIEW
     return $this->templateOverview();
 }
Example #2
0
 /**
  * Link a site.
  * First we check if username/email exists on that site.
  * If so, we check if emails are the same.
  * If not, we send some email, else we just link.
  * @return unknown_type
  */
 private function onLinkSite()
 {
     $form = $this->getFormLink();
     if (false !== ($errors = $form->validate($this->module))) {
         return $errors;
     }
     $user = GWF_Session::getUser();
     $onsitename = Common::getPostString('onsitename', '');
     $onsitemail = Common::getPostString('password_email', '');
     if (false === ($site = WC_Site::getByID_Class(Common::getPost('siteid')))) {
         return $this->module->error('err_site');
     }
     if (false !== WC_RegAt::getRegatRow(GWF_Session::getUserID(), $site->getID())) {
         return $this->module->error('err_already_linked', array($site->displayName()));
     }
     if (!$site->isScored()) {
         return $this->module->error('err_site');
     }
     if (WC_Freeze::isUserFrozenOnSite(GWF_Session::getUserID(), $site->getID())) {
         return $this->module->error('err_site_ban', array($site->displayName()));
     }
     if ($site->isNoV1()) {
         if (!$site->isValidWarboxLink($user, $onsitename)) {
             return $this->module->error('err_warbox_nick');
         }
     }
     if (false === $site->isAccountValid($onsitename, $onsitemail)) {
         $key = $site->getVar('site_classname') === 'HTS' ? 'err_link_account_hts' : 'err_link_account';
         return $this->module->error($key, array($site->displayName()));
     }
     if (false !== ($regat = WC_RegAt::getByOnsitename($site->getID(), $onsitename))) {
         if (false === ($user = $regat->getUser())) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         } else {
             return $this->module->error('err_onsitename_taken', array(htmlspecialchars($onsitename), $site->displayName(), $user->displayUsername()));
         }
     }
     if ($onsitemail !== $user->getValidMail()) {
         return $this->onLinkSiteMail($site, $user, $onsitename, $onsitemail);
     } else {
         return $this->onLinkSiteAfterMail($site, $user, $onsitename);
     }
 }