Exemple #1
0
 public function validate_subscr(Module_Forum $module, $arg)
 {
     if (!GWF_ForumOptions::isValidSubscr($arg)) {
         return $this->module->lang('err_subscr_mode');
     }
     if ($arg !== 'none' && !GWF_Session::getUser()->hasValidMail()) {
         return $this->module->lang('err_no_valid_mail');
     }
     return false;
 }
Exemple #2
0
 private function showUser(GWF_User $user, $api_key)
 {
     if (false !== ($error = $this->module->isExcludedFromAPI($user, $api_key))) {
         return $error;
     }
     $private_mode = $this->module->isAPIKeyCorrect($user, $api_key);
     require_once GWF_CORE_PATH . 'module/WeChall/WC_RegAt.php';
     if (false === ($regats = WC_RegAt::getRegats($user->getID(), 'regat_solved ASC'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     require_once GWF_CORE_PATH . 'module/Forum/GWF_ForumOptions.php';
     if (false === ($fopts = GWF_ForumOptions::getUserOptions($user, false))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $unknown = GWF_HTML::lang('unknown');
     if ('0' === ($countryid = $user->getVar('user_countryid'))) {
         $country = false;
         $cname = $unknown;
         $crank = $unknown;
     } else {
         $country = GWF_Country::getByID($countryid);
         $cname = $country->displayName();
         $crank = WC_RegAt::calcExactCountryRank($user);
     }
     $back = '';
     $back .= 'Username:'******'user_name') . PHP_EOL;
     $back .= 'Country:' . $cname . PHP_EOL;
     $back .= 'Totalscore:' . $user->getVar('user_level') . PHP_EOL;
     $back .= 'GlobalRank:' . WC_RegAt::calcExactRank($user) . PHP_EOL;
     $back .= 'CountryRank:' . $crank . PHP_EOL;
     $back .= $this->contactData($user);
     $back .= 'ForumPosts:' . $fopts->getVar('fopt_posts') . PHP_EOL;
     $back .= 'ForumThanks:' . $fopts->getVar('fopt_thanks') . PHP_EOL;
     $back .= 'ForumVoteUp:' . $fopts->getVar('fopt_upvotes') . PHP_EOL;
     $back .= 'ForumVoteDown:' . $fopts->getVar('fopt_downvotes') . PHP_EOL;
     $back .= $this->regatData($user, $regats);
     if ($private_mode === true) {
         $back .= $this->privateData($user);
     }
     return $back;
 }
Exemple #3
0
 public function canSubscribe()
 {
     if (false === ($user = GWF_Session::getUser())) {
         return false;
     }
     if (false === $user->hasValidMail()) {
         return false;
     }
     if (GWF_ForumSubscription::hasSubscribedManually($user, $this->getID())) {
         return false;
     }
     if (false === ($options = GWF_ForumOptions::getUserOptions($user))) {
         return false;
     }
     if ($options->isSubscribeAll()) {
         return false;
     }
     if ($options->isSubscribeOwn() && $this->hasUserPosted($user)) {
         return false;
     }
     return true;
 }
 private static function sendSubscriptionB(Module_Forum $module, GWF_ForumThread $thread, GWF_User $user, $postername, $msg_block, $msg_count, $boardText, $threadTitle, $sender)
 {
     $userid = $user->getID();
     $username = $user->displayUsername();
     if (false === ($receiver = $user->getValidMail())) {
         GWF_Log::logCron('[ERROR] User ' . $username . ' has no valid email.');
         return false;
     }
     if (false === ($options = GWF_ForumOptions::getUserOptions($user))) {
         GWF_Log::logCron('[ERROR] User ' . $username . ' has no valid forum options.');
     }
     $token = $options->getVar('fopt_token');
     $href = Common::getAbsoluteURL($thread->getLastPageHREF(false), false);
     $showLink = GWF_HTML::anchor($href, $href);
     $href = Common::getAbsoluteURL($thread->getExternalUnSubscribeHREF($userid, $token, true), false);
     $unsubLink = GWF_HTML::anchor($href, $href);
     $href = Common::getAbsoluteURL($thread->getExternalUnSubscribeAllHREF($userid, $token, true), false);
     $unsubLinkAll = GWF_HTML::anchor($href, $href);
     $mail = new GWF_Mail();
     $mail->setSender($sender);
     $mail->setReceiver($receiver);
     $mail->setSubject($module->langUser($user, 'submail_subj', array($threadTitle, $postername, $boardText)));
     $mail->setBody($module->langUser($user, 'submail_body', array($username, $msg_count, $boardText, $threadTitle, $msg_block, $showLink, $unsubLink, $unsubLinkAll)));
     if (false === $mail->sendToUser($user)) {
         GWF_Log::logCron('[ERROR] Can not send mail to ' . $username . '; EMail: ' . $receiver);
     } else {
         GWF_Log::logCron('[+] Successfully sent Email to ' . $username . '; EMail: ' . $receiver);
     }
 }
Exemple #5
0
 /**
  * Unsubscribe from all threads.
  * @param string $token
  * @return html
  */
 private function onUnSubscribeExtAll($token)
 {
     if (false === $this->checkExternalToken($token)) {
         return $this->module->error('err_token');
     }
     if (false === GWF_ForumSubscription::unsubscribeAll($this->user->getID())) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $this->options->saveSubscription(GWF_ForumOptions::SUBSCRIBE_NONE)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_unsub_all', array(GWF_WEB_ROOT . 'forum'));
 }
Exemple #6
0
 public function canSubscribe()
 {
     $fopts = GWF_ForumOptions::getUserOptionsS();
     if ($fopts->getVar('fopt_subscr') === GWF_ForumOptions::SUBSCRIBE_ALL) {
         return false;
     }
     if (GWF_ForumSubscrBoard::hasSubscribed(GWF_Session::getUserID(), $this->getID())) {
         return false;
     }
     return true;
 }
Exemple #7
0
 private function countDownVote($userid, $amount)
 {
     $this->increase('post_votes_down', $amount);
     $this->getThread()->increase('thread_votes_down', $amount);
     # Increase Users total vote counter
     if (false !== ($user = $this->getUser(false))) {
         if (false !== ($options = GWF_ForumOptions::getUserOptions($user))) {
             $options->increase('fopt_downvotes', $amount);
         }
     }
 }
Exemple #8
0
 private function getSignature(GWF_User $user)
 {
     return GWF_ForumOptions::getUserOptions($user, true)->getVar('fopt_signature');
 }