• Main Page
  • Modules
  • Classes
  • Files
  • File List

controllers/tab/settings/DistributionSettingsTabHandler.inc.php

00001 <?php
00002 
00015 // Import the base Handler.
00016 import('controllers.tab.settings.ManagerSettingsTabHandler');
00017 
00018 class DistributionSettingsTabHandler extends ManagerSettingsTabHandler {
00019 
00020 
00024    function DistributionSettingsTabHandler() {
00025       parent::ManagerSettingsTabHandler();
00026       // In addition to the operations permitted by the parent
00027       // class, allow Payment AJAX extras.
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       // Expose names of payment plugins to template.
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          // Invalid plugin name
00064          $jsonMessage = new JSONMessage(false);
00065       } else {
00066          // Fetch and return the JSON-encoded form contents
00067          $plugin =& $plugins[$paymentPluginName];
00068          $params = array(); // Blank -- OJS compatibility. Need to supply by reference.
00069          $templateMgr =& TemplateManager::getManager();
00070 
00071          // Expose current settings to the template
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 ?>

Generated on Mon Sep 17 2012 13:58:56 for Open Monograph Press by  doxygen 1.7.1