00001 <?php
00002
00015
00016 import('controllers.tab.settings.ManagerSettingsTabHandler');
00017
00018 class DistributionSettingsTabHandler extends ManagerSettingsTabHandler {
00019
00020
00024 function DistributionSettingsTabHandler() {
00025 parent::ManagerSettingsTabHandler();
00026
00027
00028 $this->addRoleAssignment(
00029 ROLE_ID_PRESS_MANAGER,
00030 array('getPaymentMethods', 'getPaymentFormContents')
00031 );
00032 $this->setPageTabs(array(
00033 'indexing' => 'controllers.tab.settings.indexing.form.IndexingForm',
00034 'paymentMethod' => 'controllers.tab.settings.paymentMethod.form.PaymentMethodForm',
00035 ));
00036 }
00037
00043 function getPaymentMethods($args, &$request) {
00044
00045 $pluginNames = array(__('manager.paymentMethod.none'));
00046 $pluginNames += array_map(
00047 create_function('$a', 'return $a->getDisplayName();'),
00048 PluginRegistry::loadCategory('paymethod')
00049 );
00050 $jsonMessage = new JSONMessage(true, $pluginNames);
00051 return $jsonMessage->getString();
00052 }
00053
00059 function getPaymentFormContents($args, &$request) {
00060 $paymentPluginName = $request->getUserVar('paymentPluginName');
00061 $plugins =& PluginRegistry::loadCategory('paymethod');
00062 if (!isset($plugins[$paymentPluginName])) {
00063
00064 $jsonMessage = new JSONMessage(false);
00065 } else {
00066
00067 $plugin =& $plugins[$paymentPluginName];
00068 $params = array();
00069 $templateMgr =& TemplateManager::getManager();
00070
00071
00072 $press =& $request->getPress();
00073 foreach ($plugin->getSettingsFormFieldNames() as $fieldName) {
00074 $templateMgr->assign($fieldName, $plugin->getSetting($press->getId(), $fieldName));
00075 }
00076
00077 $jsonMessage = new JSONMessage(true, $plugin->displayPaymentSettingsForm($params, $templateMgr));
00078 }
00079 return $jsonMessage->getString();
00080 }
00081 }
00082
00083 ?>