baseline
[omp.pkp.sfu.ca.git] / classes / plugins / PaymethodPlugin.inc.php
bloba66f19b175990b45697af9c373f2a02f89fab328
1 <?php
3 /**
4 * @file classes/plugins/PaymethodPlugin.inc.php
6 * Copyright (c) 2006-2007 Gunther Eysenbach, Juan Pablo Alperin, MJ Suhonos
7 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
9 * @class PaymethodPlugin
10 * @ingroup plugins
12 * @brief Abstract class for paymethod plugins
16 import('plugins.Plugin');
18 class PaymethodPlugin extends Plugin {
19 /**
20 * Constructor
22 function PaymethodPlugin() {
25 /**
26 * Called as a plugin is registered to the registry. Subclasses over-
27 * riding this method should call the parent method first.
28 * @param $category String Name of category plugin was registered to
29 * @param $path String The path the plugin was found in
30 * @return boolean True iff plugin initialized successfully; if false,
31 * the plugin will not be registered.
33 function register($category, $path) {
34 $success = parent::register($category, $path);
35 if ($success) {
36 HookRegistry::register('Template::Manager::Payment::displayPaymentSettingsForm', array(&$this, '_smartyDisplayPaymentSettingsForm'));
38 return $success;
41 /**
42 * Get the name of this plugin. The name must be unique within
43 * its category, and should be suitable for part of a filename
44 * (ie short, no spaces, and no dependencies on cases being unique).
45 * @return String name of plugin
47 function getName() {
48 return 'PaymethodPlugin';
51 /**
52 * Get a description of this plugin.
54 function getDescription() {
55 return 'This is the base payment method plugin class. It contains no concrete implementation. Its functions must be overridden by subclasses to provide actual functionality.';
58 /**
59 * Get the Template path for this plugin.
60 */
61 function getTemplatePath() {
62 return parent::getTemplatePath() . 'templates' . DIRECTORY_SEPARATOR ;
65 function displayPaymentForm($queuedPaymentId, $key, &$queuedPayment) {
66 die('ABSTRACT METHOD');
69 function isConfigured() {
70 return false; // Abstract; should be implemented in subclasses
73 /**
74 * This is a hook wrapper that is responsible for calling
75 * displayPaymentSettingsForm. Subclasses should override
76 * displayPaymentSettingsForm as necessary.
78 function _smartyDisplayPaymentSettingsForm($hookName, $args) {
79 $params =& $args[0];
80 $smarty =& $args[1];
81 $output =& $args[2];
83 if (isset($params['plugin']) && $params['plugin'] == $this->getName()) {
84 $output .= $this->displayPaymentSettingsForm($params, $smarty);
86 return false;
89 function displayPaymentSettingsForm(&$params, &$smarty) {
90 return $smarty->fetch($this->getTemplatePath() . 'settingsForm.tpl');
93 function getSettingsFormFieldNames() {
94 return array(); // Subclasses should override
97 /**
98 * Handle an incoming request from a user callback or an external
99 * payment processing system.
101 function handle($args) {
102 // Subclass should override.
103 Request::redirect(null, null, 'index');