plugins =& PluginRegistry::loadCategory('paymethod'); // Add form checks $this->addCheck(new FormValidatorInSet($this, 'paymentMethodPluginName', 'optional', 'manager.payment.paymentPluginInvalid', array_keys($this->plugins))); $this->addCheck(new FormValidatorPost($this)); } /** * Display the form. */ function display() { $templateMgr = &TemplateManager::getManager(); $templateMgr->assign_by_ref('paymentMethodPlugins', $this->plugins); parent::display(); } /** * Initialize form data from current group group. */ function initData() { $schedConf =& Request::getSchedConf(); // Allow the current selection to supercede the stored value $paymentMethodPluginName = Request::getUserVar('paymentMethodPluginName'); if (empty($paymentMethodPluginName) || !in_array($paymentMethodPluginName, array_keys($this->plugins))) { $paymentMethodPluginName = $schedConf->getSetting('paymentMethodPluginName'); } if (!isset($this->plugins[$paymentMethodPluginName])) { // Choose an arbitrary default if no valid plugin chosen $paymentMethodPluginName = array_shift(array_keys($this->plugins)); } // A valid payment method plugin should now be chosen. $paymentMethodPlugin =& $this->plugins[$paymentMethodPluginName]; $this->_data = array( 'paymentMethodPluginName' => $paymentMethodPluginName ); if (isset($this->plugins[$paymentMethodPluginName])) { $plugin =& $this->plugins[$paymentMethodPluginName]; foreach ($plugin->getSettingsFormFieldNames() as $field) { $this->_data[$field] = $plugin->getSetting($schedConf->getConferenceId(), $schedConf->getSchedConfId(), $field); } } } /** * Assign form data to user-submitted data. */ function readInputData() { $this->readUserVars(array( 'paymentMethodPluginName' )); $paymentMethodPluginName = $this->getData('paymentMethodPluginName'); if (isset($this->plugins[$paymentMethodPluginName])) { $plugin =& $this->plugins[$paymentMethodPluginName]; $this->readUserVars($plugin->getSettingsFormFieldNames()); } } /** * Save settings */ function execute() { $schedConf =& Request::getSchedConf(); // Save the general settings for the form foreach (array('paymentMethodPluginName') as $schedConfSettingName) { $schedConf->updateSetting($schedConfSettingName, $this->getData($schedConfSettingName)); } // Save the specific settings for the plugin $paymentMethodPluginName = $this->getData('paymentMethodPluginName'); if (isset($this->plugins[$paymentMethodPluginName])) { $plugin =& $this->plugins[$paymentMethodPluginName]; foreach ($plugin->getSettingsFormFieldNames() as $field) { $plugin->updateSetting($schedConf->getConferenceId(), $schedConf->getSchedConfId(), $field, $this->getData($field)); } } } } ?>