/**
  * @see	\wcf\system\option\IOptionType::validate()
  */
 public function validate(Option $option, $newValue)
 {
     if (!is_array($newValue)) {
         $newValue = array();
     }
     $selectOptions = PaymentMethodHandler::getInstance()->getPaymentMethodSelection();
     foreach ($newValue as $optionName) {
         if (!isset($selectOptions[$optionName])) {
             throw new UserInputException($option->optionName, 'validationFailed');
         }
     }
 }
 /**
  * Returns list of purchase buttons.
  * 
  * @return	array<string>
  */
 public function getPurchaseButtons()
 {
     $objectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.payment.type', 'com.woltlab.wcf.payment.type.paidSubscription');
     $buttons = array();
     foreach (PaymentMethodHandler::getInstance()->getPaymentMethods() as $paymentMethod) {
         // check if payment method supports recurring payments
         if ($this->isRecurring && !$paymentMethod->supportsRecurringPayments()) {
             continue;
         }
         // check supported currencies
         if (!in_array($this->currency, $paymentMethod->getSupportedCurrencies())) {
             continue;
         }
         $buttons[] = $paymentMethod->getPurchaseButton($this->cost, $this->currency, WCF::getLanguage()->get($this->title), $objectTypeID . ':' . WCF::getUser()->userID . ':' . $this->subscriptionID, LinkHandler::getInstance()->getLink('PaidSubscriptionReturn'), LinkHandler::getInstance()->getLink(), $this->isRecurring, $this->subscriptionLength, $this->subscriptionLengthUnit);
     }
     return $buttons;
 }
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     I18nHandler::getInstance()->register('description');
     I18nHandler::getInstance()->register('title');
     // get available user groups
     $this->availableUserGroups = UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
     if (!count(PaymentMethodHandler::getInstance()->getPaymentMethods())) {
         throw new NamedUserException(WCF::getLanguage()->get('wcf.acp.paidSubscription.error.noPaymentMethods'));
     }
     // get available currencies
     foreach (PaymentMethodHandler::getInstance()->getPaymentMethods() as $paymentMethod) {
         $this->availableCurrencies = array_merge($this->availableCurrencies, $paymentMethod->getSupportedCurrencies());
     }
     $this->availableCurrencies = array_unique($this->availableCurrencies);
     sort($this->availableCurrencies);
     // get available subscriptions
     $this->getAvailableSubscriptions();
 }