classes/manager/form/PaymentSettingsForm.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 import('form.Form');
00017 
00018 class PaymentSettingsForm extends Form {
00020    var $errors;
00021 
00023    var $plugins;
00024 
00028    function PaymentSettingsForm() {
00029       parent::Form('manager/paymentSettingsForm.tpl');
00030 
00031       // Load the plugins.
00032       $this->plugins =& PluginRegistry::loadCategory('paymethod');
00033 
00034       // Add form checks
00035       $this->addCheck(new FormValidatorInSet($this, 'paymentMethodPluginName', 'optional', 'manager.payment.paymentPluginInvalid', array_keys($this->plugins)));
00036       $this->addCheck(new FormValidatorPost($this));
00037    }
00038 
00042    function display() {
00043       $templateMgr =& TemplateManager::getManager();
00044       $templateMgr->assign_by_ref('paymentMethodPlugins', $this->plugins);
00045       parent::display();
00046    }
00047 
00051    function initData() {
00052       $schedConf =& Request::getSchedConf();
00053 
00054       // Allow the current selection to supercede the stored value
00055       $paymentMethodPluginName = Request::getUserVar('paymentMethodPluginName');
00056       if (empty($paymentMethodPluginName) || !in_array($paymentMethodPluginName, array_keys($this->plugins))) {
00057          $paymentMethodPluginName = $schedConf->getSetting('paymentMethodPluginName');
00058       }
00059 
00060       $this->_data = array(
00061          'paymentMethodPluginName' => $paymentMethodPluginName
00062       );
00063 
00064       if (isset($this->plugins[$paymentMethodPluginName])) {
00065          $plugin =& $this->plugins[$paymentMethodPluginName];
00066          foreach ($plugin->getSettingsFormFieldNames() as $field) {
00067             $this->_data[$field] = $plugin->getSetting($schedConf->getConferenceId(), $schedConf->getId(), $field);
00068          }
00069       }
00070    }
00071 
00075    function readInputData() {
00076       $this->readUserVars(array(
00077          'paymentMethodPluginName'
00078       ));
00079 
00080       $paymentMethodPluginName = $this->getData('paymentMethodPluginName');
00081       if (isset($this->plugins[$paymentMethodPluginName])) {
00082          $plugin =& $this->plugins[$paymentMethodPluginName];
00083          $this->readUserVars($plugin->getSettingsFormFieldNames());
00084       }
00085 
00086    }
00087 
00091    function execute() {
00092       $schedConf =& Request::getSchedConf();
00093 
00094       // Save the general settings for the form
00095       foreach (array('paymentMethodPluginName') as $schedConfSettingName) {
00096          $schedConf->updateSetting($schedConfSettingName, $this->getData($schedConfSettingName));
00097       }
00098 
00099       // Save the specific settings for the plugin
00100       $paymentMethodPluginName = $this->getData('paymentMethodPluginName');
00101       if (isset($this->plugins[$paymentMethodPluginName])) {
00102          $plugin =& $this->plugins[$paymentMethodPluginName];
00103          foreach ($plugin->getSettingsFormFieldNames() as $field) {
00104             $plugin->updateSetting($schedConf->getConferenceId(), $schedConf->getId(), $field, $this->getData($field));
00105          }
00106       }
00107    }
00108 }
00109 
00110 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7