00001 <?php
00002
00015 import('lib.pkp.classes.form.Form');
00016 import('controllers.tab.settings.form.PressSettingsForm');
00017
00018 class PaymentMethodForm extends PressSettingsForm {
00020 var $paymentPlugins;
00021
00025 function PaymentMethodForm($wizardMode = false) {
00026 $settings = array(
00027 'paymentPluginName' => 'string',
00028 'pressCurrency' => 'string',
00029 );
00030
00031 parent::PressSettingsForm($settings, 'controllers/tab/settings/paymentMethod/form/paymentMethodForm.tpl', $wizardMode);
00032 $this->paymentPlugins =& PluginRegistry::loadCategory('paymethod');
00033 }
00034
00038 function fetch(&$request) {
00039 $templateMgr =& TemplateManager::getManager();
00040 $currencyDao =& DAORegistry::getDAO('CurrencyDAO');
00041 $currencies = array();
00042 foreach ($currencyDao->getCurrencies() as $currency) {
00043 $currencies[$currency->getCodeAlpha()] = $currency->getName();
00044 }
00045 $templateMgr->assign('currencies', $currencies);
00046 return parent::fetch($request);
00047 }
00048
00056 function readInputData(&$request) {
00057 parent::readInputData($request);
00058
00059 $paymentPluginName = $this->getData('paymentPluginName');
00060 if (!isset($this->paymentPlugins[$paymentPluginName])) return false;
00061 $plugin =& $this->paymentPlugins[$paymentPluginName];
00062
00063 $this->readUserVars($plugin->getSettingsFormFieldNames());
00064 }
00065
00069 function execute(&$request) {
00070 $press =& $request->getPress();
00071
00072
00073 $paymentPluginName = $this->getData('paymentPluginName');
00074 if (isset($this->paymentPlugins[$paymentPluginName])) {
00075 $plugin =& $this->paymentPlugins[$paymentPluginName];
00076
00077
00078 foreach ($plugin->getSettingsFormFieldNames() as $settingName) {
00079 $plugin->updateSetting($press->getId(), $settingName, $this->getData($settingName));
00080 }
00081
00082
00083 $notificationDao =& DAORegistry::getDAO('NotificationDAO');
00084 $notificationDao->deleteByAssoc(ASSOC_TYPE_PRESS, $press->getId(), null, NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD, $press->getId());
00085 } else {
00086
00087 $notificationMgr = new NotificationManager();
00088 $notificationMgr->createNotification($request, null, NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD,
00089 $press->getId(), ASSOC_TYPE_PRESS, $press->getId(), NOTIFICATION_LEVEL_NORMAL);
00090 }
00091
00092 return parent::execute($request);
00093 }
00094 }
00095
00096 ?>