/**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     NewsletterUtil::sendUserValidationEmail($this->user);
     $this->saved();
     //resetting variables
     $this->username = '';
     $this->user = null;
     WCF::getTPL()->assign('success', true);
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     $subscriber = new NewsletterSubscriber($this->subscriberID);
     if ($subscriber->userID) {
         $user = new User($subscriber->userID);
         NewsletterUtil::sendUserValidationEmail($user);
     } else {
         NewsletterUtil::sendGuestValidationEmail($subscriber);
     }
     $this->executed();
     HeaderUtil::redirect('index.php?page=NewsletterSubscriberList&success=success&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (!isset($eventObj->activeOptions['acceptNewsletter'])) {
         return;
     }
     $optionGeneral = $eventObj->activeOptions['acceptNewsletter'];
     $optionEmail = $eventObj->activeOptions['acceptNewsletterAsEmail'];
     $optionPM = $eventObj->activeOptions['acceptNewsletterAsPM'];
     $sql = 'SELECT COUNT(userID) AS count
     		FROM wcf' . WCF_N . '_' . $this->subscriberTable . '
     		WHERE userID = ' . intval(WCF::getUser()->userID);
     $existCount = WCF::getDB()->getFirstRow($sql);
     $sql = 'SELECT COUNT(userID) AS count
     		FROM wcf' . WCF_N . '_' . $this->activationTable . '
     		WHERE userID = ' . intval(WCF::getUser()->userID);
     $activationCount = WCF::getDB()->getFirstRow($sql);
     if ($optionGeneral['optionValue'] && !$existCount['count'] && ($optionEmail['optionValue'] || $optionPM['optionValue']) && !$activationCount['count']) {
         NewsletterUtil::sendUserValidationEmail();
     } elseif (!$optionGeneral['optionValue']) {
         $editor = WCF::getUser()->getEditor();
         $options = array('acceptNewsletter' => 0);
         $editor->updateOptions($options);
         $this->deleteSubscriber();
     } elseif ($optionGeneral['optionValue'] && $existCount['count'] && !$optionEmail['optionValue'] && !$optionPM['optionValue']) {
         $editor = WCF::getUser()->getEditor();
         $options = array('acceptNewsletter' => 0);
         $editor->updateOptions($options);
         $this->deleteSubscriber();
     } elseif ($optionGeneral['optionValue'] && !$existCount['count'] && !$optionEmail['optionValue'] && !$optionPM['optionValue']) {
         $editor = WCF::getUser()->getEditor();
         $options = array('acceptNewsletter' => 0);
         $editor->updateOptions($options);
         $this->deleteSubscriber();
     } else {
     }
     WCF::getCache()->clear(WCF_DIR . 'cache/', 'cache.newsletter-subscriber-' . PACKAGE_ID . '.php', true);
 }