00001 <?php
00002
00016 import('form.Form');
00017
00018 class PaymentSettingsForm extends Form {
00020 var $validCurrencies;
00021
00023 var $settings;
00024
00026 var $errors;
00027
00032 function PaymentSettingsForm() {
00033
00034 parent::Form('manager/payments/paymentSettings.tpl');
00035
00036 $this->settings = array(
00037 'journalPaymentsEnabled' => 'bool',
00038 'currency' => 'string',
00039 'submissionFeeEnabled' => 'bool',
00040 'submissionFee' => 'float',
00041 'submissionFeeName' => 'string',
00042 'submissionFeeDescription' => 'string',
00043 'publicationFeeEnabled' => 'bool',
00044 'publicationFee' => 'float',
00045 'publicationFeeName' => 'string',
00046 'publicationFeeDescription' => 'string',
00047 'fastTrackFeeEnabled' => 'bool',
00048 'fastTrackFee' => 'float',
00049 'fastTrackFeeName' => 'string',
00050 'fastTrackFeeDescription' => 'string',
00051 'purchaseArticleFeeEnabled' => 'bool',
00052 'purchaseArticleFee' => 'float',
00053 'purchaseArticleFeeName' => 'string',
00054 'purchaseArticleFeeDescription' => 'string',
00055 'membershipFeeEnabled' => 'bool',
00056 'membershipFee' => 'float',
00057 'membershipFeeName' => 'string',
00058 'membershipFeeDescription' => 'string',
00059 'waiverPolicy' => 'string',
00060 'donationFeeEnabled' => 'bool',
00061 'donationFeeName' => 'string',
00062 'donationFeeDescription' => 'string',
00063 'restrictOnlyPdf' => 'bool',
00064 'acceptSubscriptionPayments' => 'bool'
00065 );
00066
00067 $this->addCheck(new FormValidatorCustom($this, 'submissionFee', 'optional', 'manager.payment.form.numeric', create_function('$submissionFee', 'return is_numeric($submissionFee) && $submissionFee >= 0;')));
00068 $this->addCheck(new FormValidatorCustom($this, 'publicationFee', 'optional', 'manager.payment.form.numeric', create_function('$publicationFee', 'return is_numeric($publicationFee) && $publicationFee >= 0;')));
00069 $this->addCheck(new FormValidatorCustom($this, 'fastTrackFee', 'optional', 'manager.payment.form.numeric', create_function('$fastTrackFee', 'return is_numeric($fastTrackFee) && $fastTrackFee >= 0;')));
00070 $this->addCheck(new FormValidatorCustom($this, 'purchaseArticleFee', 'optional', 'manager.payment.form.numeric', create_function('$purchaseArticleFee', 'return is_numeric($purchaseArticleFee) && $purchaseArticleFee >= 0;')));
00071 $this->addCheck(new FormValidatorCustom($this, 'membershipFee', 'optional', 'manager.payment.form.numeric', create_function('$membershipFee', 'return is_numeric($membershipFee) && $membershipFee >= 0;')));
00072
00073
00074 $currencyDao = &DAORegistry::getDAO('CurrencyDAO');
00075 $currencies = &$currencyDao->getCurrencies();
00076 $this->validCurrencies = array();
00077 while (list(, $currency) = each($currencies)) {
00078 $this->validCurrencies[$currency->getCodeAlpha()] = $currency->getName() . ' (' . $currency->getCodeAlpha() . ')';
00079 }
00080
00081
00082 $this->addCheck(new FormValidator($this, 'currency', 'required', 'manager.subscriptionTypes.form.currencyRequired'));
00083 $this->addCheck(new FormValidatorInSet($this, 'currency', 'required', 'manager.subscriptionTypes.form.currencyValid', array_keys($this->validCurrencies)));
00084
00085 }
00086
00091 function getLocaleFieldNames() {
00092 return array('submissionFeeName', 'submissionFeeDescription', 'publicationFeeName', 'publicationFeeDescription', 'waiverPolicy', 'fastTrackFeeName', 'fastTrackFeeDescription', 'purchaseArticleFeeName', 'purchaseArticleFeeDescription', 'membershipFeeName', 'membershipFeeDescription', 'donationFeeName', 'donationFeeDescription');
00093 }
00094
00098 function display() {
00099 $templateMgr = &TemplateManager::getManager();
00100 $templateMgr->assign('validCurrencies', $this->validCurrencies);
00101 parent::display();
00102 }
00103
00107 function initData() {
00108 $journal = &Request::getJournal();
00109 foreach ($this->settings as $settingName => $settingType) {
00110 $this->_data[$settingName] = $journal->getSetting($settingName);
00111 }
00112 }
00113
00117 function readInputData() {
00118 $this->readUserVars(array_keys($this->settings));
00119 }
00120
00124 function save() {
00125 $journal = &Request::getJournal();
00126 $settingsDao = &DAORegistry::getDAO('JournalSettingsDAO');
00127
00128 foreach ($this->_data as $name => $value) {
00129 $isLocalized = in_array($name, $this->getLocaleFieldNames());
00130 $settingsDao->updateSetting(
00131 $journal->getJournalId(),
00132 $name,
00133 $value,
00134 $this->settings[$name],
00135 $isLocalized
00136 );
00137 }
00138
00139 }
00140
00141 }
00142 ?>