Skip to content

Commit

Permalink
*7154* Payment clean-up for OMP port
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Feb 16, 2012
1 parent 91abe69 commit e0c2682
Show file tree
Hide file tree
Showing 119 changed files with 747 additions and 677 deletions.
2 changes: 1 addition & 1 deletion classes/author/form/submit/AuthorSubmitStep1Form.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function display() {

// Set up required Payment Related Information
import('classes.payment.ojs.OJSPaymentManager');
$paymentManager =& OJSPaymentManager::getManager();
$paymentManager = new OJSPaymentManager($this->request);
if ( $paymentManager->submissionEnabled() || $paymentManager->fastTrackEnabled() || $paymentManager->publicationEnabled()) {
$templateMgr->assign('authorFees', true);
$completedPaymentDao =& DAORegistry::getDAO('OJSCompletedPaymentDAO');
Expand Down
4 changes: 2 additions & 2 deletions classes/author/form/submit/AuthorSubmitStep5Form.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function display() {

// Set up required Payment Related Information
import('classes.payment.ojs.OJSPaymentManager');
$paymentManager =& OJSPaymentManager::getManager();
$paymentManager = new OJSPaymentManager::getManager($this->request);
if ( $paymentManager->submissionEnabled() || $paymentManager->fastTrackEnabled() || $paymentManager->publicationEnabled()) {
$templateMgr->assign('authorFees', true);
$completedPaymentDao =& DAORegistry::getDAO('OJSCompletedPaymentDAO');
Expand Down Expand Up @@ -91,7 +91,7 @@ function readInputData() {
*/
function validate() {
import('classes.payment.ojs.OJSPaymentManager');
$paymentManager =& OJSPaymentManager::getManager();
$paymentManager = new OJSPaymentManager($this->request);
if ( $paymentManager->submissionEnabled() ) {
if (!parent::validate()) return false;

Expand Down
2 changes: 1 addition & 1 deletion classes/notification/NotificationManager.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ function getSubscriptionSettings(&$request) {
if (!$journal) return array();

import('classes.payment.ojs.OJSPaymentManager');
$paymentManager =& OJSPaymentManager::getManager();
$paymentManager = new OJSPaymentManager($request);

$settings = array('subscriptionsEnabled' => $paymentManager->acceptSubscriptionPayments(),
'allowRegReviewer' => $journal->getSetting('allowRegReviewer'),
Expand Down
56 changes: 26 additions & 30 deletions classes/payment/ojs/OJSPaymentManager.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,19 @@

class OJSPaymentManager extends PaymentManager {
/**
* Get an instance of the payment manager.
* @return OJSPaymentManager
* Constructor
* @param $request PKPRequest
*/
function &getManager() {
static $manager;
if (!isset($manager)) {
$manager = new OJSPaymentManager();
}
return $manager;
function OJSPaymentManager(&$request) {
parent::PaymentManager($request);
}

/**
* Determine whether the payment system is configured.
* @return boolean true iff configured
*/
function isConfigured() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return parent::isConfigured() && $journal->getSetting('journalPaymentsEnabled');
}

Expand All @@ -69,34 +65,34 @@ function &createQueuedPayment($journalId, $type, $userId, $assocId, $amount, $cu

switch ($type) {
case PAYMENT_TYPE_PURCHASE_ARTICLE:
$payment->setRequestUrl(Request::url(null, 'article', 'view', $assocId));
$payment->setRequestUrl($this->request->url(null, 'article', 'view', $assocId));
break;
case PAYMENT_TYPE_PURCHASE_ISSUE:
$payment->setRequestUrl(Request::url(null, 'issue', 'view', $assocId));
$payment->setRequestUrl($this->request->url(null, 'issue', 'view', $assocId));
break;
case PAYMENT_TYPE_MEMBERSHIP:
$payment->setRequestUrl(Request::url(null, 'user'));
$payment->setRequestUrl($this->request->url(null, 'user'));
break;
case PAYMENT_TYPE_PURCHASE_SUBSCRIPTION:
case PAYMENT_TYPE_RENEW_SUBSCRIPTION:
$payment->setRequestUrl(Request::url(null, 'user', 'subscriptions'));
$payment->setRequestUrl($this->request->url(null, 'user', 'subscriptions'));
break;
case PAYMENT_TYPE_DONATION:
$payment->setRequestUrl(Request::url(null, 'donations', 'thankYou'));
$payment->setRequestUrl($this->request->url(null, 'donations', 'thankYou'));
break;
case PAYMENT_TYPE_FASTTRACK:
case PAYMENT_TYPE_PUBLICATION:
case PAYMENT_TYPE_SUBMISSION:
$authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
$authorSubmission =& $authorSubmissionDao->getAuthorSubmission($assocId);
if ($authorSubmission->getSubmissionProgress()!=0) {
$payment->setRequestUrl(Request::url(null, 'author', 'submit', $authorSubmission->getSubmissionProgress(), array('articleId' => $assocId)));
$payment->setRequestUrl($this->request->url(null, 'author', 'submit', $authorSubmission->getSubmissionProgress(), array('articleId' => $assocId)));
} else {
$payment->setRequestUrl(Request::url(null, 'author'));
$payment->setRequestUrl($this->request->url(null, 'author'));
}
break;
case PAYMENT_TYPE_GIFT:
$payment->setRequestUrl(Request::url(null, 'gifts', 'thankYou'));
$payment->setRequestUrl($this->request->url(null, 'gifts', 'thankYou'));
break;
default:
// Invalid payment type
Expand Down Expand Up @@ -132,7 +128,7 @@ function &createCompletedPayment($queuedPayment, $payMethod) {
* @return boolean true iff this fee is enabled.
*/
function donationEnabled() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return $this->isConfigured() && $journal->getSetting('donationFeeEnabled');
}

Expand All @@ -141,7 +137,7 @@ function donationEnabled() {
* @return boolean true iff this fee is enabled.
*/
function submissionEnabled() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return $this->isConfigured() && $journal->getSetting('submissionFeeEnabled') && $journal->getSetting('submissionFee') > 0;
}

Expand All @@ -150,7 +146,7 @@ function submissionEnabled() {
* @return boolean true iff this fee is enabled.
*/
function fastTrackEnabled() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return $this->isConfigured() && $journal->getSetting('fastTrackFeeEnabled') && $journal->getSetting('fastTrackFee') > 0;
}

Expand All @@ -159,7 +155,7 @@ function fastTrackEnabled() {
* @return boolean true iff this fee is enabled.
*/
function publicationEnabled() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return $this->isConfigured() && $journal->getSetting('publicationFeeEnabled') && $journal->getSetting('publicationFee') > 0;
}

Expand All @@ -168,7 +164,7 @@ function publicationEnabled() {
* @return boolean true iff this fee is enabled.
*/
function membershipEnabled() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return $this->isConfigured() && $journal->getSetting('membershipFeeEnabled') && $journal->getSetting('membershipFee') > 0;
}

Expand All @@ -177,7 +173,7 @@ function membershipEnabled() {
* @return boolean true iff this fee is enabled.
*/
function purchaseArticleEnabled() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return $this->isConfigured() && $journal->getSetting('purchaseArticleFeeEnabled') && $journal->getSetting('purchaseArticleFee') > 0;
}

Expand All @@ -186,7 +182,7 @@ function purchaseArticleEnabled() {
* @return boolean true iff this fee is enabled.
*/
function purchaseIssueEnabled() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return $this->isConfigured() && $journal->getSetting('purchaseIssueFeeEnabled') && $journal->getSetting('purchaseIssueFee') > 0;
}

Expand All @@ -195,7 +191,7 @@ function purchaseIssueEnabled() {
* @return boolean true iff this fee is enabled.
*/
function onlyPdfEnabled() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return $this->isConfigured() && $journal->getSetting('restrictOnlyPdf');
}

Expand All @@ -204,7 +200,7 @@ function onlyPdfEnabled() {
* @return boolean true iff this fee is enabled.
*/
function acceptSubscriptionPayments() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return $this->isConfigured() && $journal->getSetting('acceptSubscriptionPayments');
}

Expand All @@ -213,7 +209,7 @@ function acceptSubscriptionPayments() {
* @return boolean true iff this fee is enabled.
*/
function acceptGiftPayments() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return $this->acceptGiftSubscriptionPayments();
}

Expand All @@ -222,7 +218,7 @@ function acceptGiftPayments() {
* @return boolean true iff this fee is enabled.
*/
function acceptGiftSubscriptionPayments() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
return $this->isConfigured() && $journal->getSetting('acceptGiftSubscriptionPayments');
}

Expand All @@ -231,7 +227,7 @@ function acceptGiftSubscriptionPayments() {
* @return PaymentPlugin
*/
function &getPaymentPlugin() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
$paymentMethodPluginName = $journal->getSetting('paymentMethodPluginName');
$paymentMethodPlugin = null;
if (!empty($paymentMethodPluginName)) {
Expand Down Expand Up @@ -451,7 +447,7 @@ function fulfillQueuedPayment(&$queuedPayment, $payMethodPluginName = null) {
'recipientFirstName' => $recipientFirstName,
'buyerFullName' => $buyerFullName,
'giftDetails' => $giftDetails,
'giftUrl' => Request::url($journal->getPath(), 'user', 'gifts'),
'giftUrl' => $request->url($journal->getPath(), 'user', 'gifts'),
'username' => $user->getUsername(),
'giftContactSignature' => $giftContactSignature
);
Expand Down
32 changes: 28 additions & 4 deletions classes/plugins/PaymethodPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PaymethodPlugin extends Plugin {
* Constructor
*/
function PaymethodPlugin() {
parent::plugin();
parent::Plugin();
}

/**
Expand Down Expand Up @@ -62,10 +62,21 @@ function getTemplatePath() {
return parent::getTemplatePath() . 'templates' . DIRECTORY_SEPARATOR ;
}

function displayPaymentForm($queuedPaymentId, $key, &$queuedPayment) {
/**
* Display the payment form.
* @param $queuedPaymentId int
* @param $key string
* @param $queuedPayment QueuedPayment
* @param $request PKPRequest
*/
function displayPaymentForm($queuedPaymentId, $key, &$queuedPayment, $request) {
assert(false); // Should always be overridden
}

/**
* Determine whether or not the payment plugin is configured for use.
* @return boolean
*/
function isConfigured() {
return false; // Abstract; should be implemented in subclasses
}
Expand All @@ -74,6 +85,8 @@ function isConfigured() {
* This is a hook wrapper that is responsible for calling
* displayPaymentSettingsForm. Subclasses should override
* displayPaymentSettingsForm as necessary.
* @param $hookName string
* @param $args array
*/
function _smartyDisplayPaymentSettingsForm($hookName, $args) {
$params =& $args[0];
Expand All @@ -86,21 +99,32 @@ function _smartyDisplayPaymentSettingsForm($hookName, $args) {
return false;
}

/**
* Display the payment settings form.
* @param $params array
* @param $smarty Smarty
*/
function displayPaymentSettingsForm(&$params, &$smarty) {
return $smarty->fetch($this->getTemplatePath() . 'settingsForm.tpl');
}

/**
* Fetch the settings form field names.
* @return array
*/
function getSettingsFormFieldNames() {
return array(); // Subclasses should override
}

/**
* Handle an incoming request from a user callback or an external
* payment processing system.
* @param $args array
* @param $request PKPRequest
*/
function handle($args) {
function handle($args, &$request) {
// Subclass should override.
Request::redirect(null, null, 'index');
$request->redirect(null, null, 'index');
}
}

Expand Down
12 changes: 8 additions & 4 deletions classes/subscription/SubscriptionAction.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,10 @@ function updateSubscriptionType() {

/**
* Display subscription policies for the current journal.
* @param $args array
* @param $request PKPRequest
*/
function subscriptionPolicies() {
function subscriptionPolicies($args, &$request) {
import('classes.subscription.form.SubscriptionPolicyForm');

$templateMgr =& TemplateManager::getManager();
Expand All @@ -541,7 +543,7 @@ function subscriptionPolicies() {
}

import('classes.payment.ojs.OJSPaymentManager');
$paymentManager =& OJSPaymentManager::getManager();
$paymentManager = new OJSPaymentManager($request);
$templateMgr->assign('acceptSubscriptionPayments', $paymentManager->acceptSubscriptionPayments());

$subscriptionPolicyForm = new SubscriptionPolicyForm();
Expand All @@ -555,8 +557,10 @@ function subscriptionPolicies() {

/**
* Save subscription policies for the current journal.
* @param $args array
* @param $request PKPRequest
*/
function saveSubscriptionPolicies($args = array()) {
function saveSubscriptionPolicies($args, &$request) {
import('classes.subscription.form.SubscriptionPolicyForm');

$subscriptionPolicyForm = new SubscriptionPolicyForm();
Expand All @@ -570,7 +574,7 @@ function saveSubscriptionPolicies($args = array()) {
}

import('classes.payment.ojs.OJSPaymentManager');
$paymentManager =& OJSPaymentManager::getManager();
$paymentManager = new OJSPaymentManager($request);
$templateMgr->assign('acceptSubscriptionPayments', $paymentManager->acceptSubscriptionPayments());

if ($subscriptionPolicyForm->validate()) {
Expand Down
14 changes: 8 additions & 6 deletions classes/subscription/form/GiftIndividualSubscriptionForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import('lib.pkp.classes.form.Form');

class GiftIndividualSubscriptionForm extends Form {
/** @var $request PKPRequest */
var $request;

/** @var userId int the buyer associated with the gift purchase */
var $buyerUserId;
Expand All @@ -30,12 +32,12 @@ class GiftIndividualSubscriptionForm extends Form {
* Constructor
* @param buyerUserId int
*/
function GiftIndividualSubscriptionForm($buyerUserId = null) {
function GiftIndividualSubscriptionForm($request, $buyerUserId = null) {
parent::Form('subscription/giftIndividualSubscriptionForm.tpl');

$this->buyerUserId = isset($buyerUserId) ? (int) $buyerUserId : null;

$journal =& Request::getJournal();
$this->request =& $request;
$journal =& $this->request->getJournal();
$journalId = $journal->getId();

$subscriptionTypeDao =& DAORegistry::getDAO('SubscriptionTypeDAO');
Expand Down Expand Up @@ -82,7 +84,7 @@ function GiftIndividualSubscriptionForm($buyerUserId = null) {
* Display the form.
*/
function display() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('supportedLocales', $journal->getSupportedLocaleNames());
$templateMgr->assign_by_ref('subscriptionTypes', $this->subscriptionTypes);
Expand Down Expand Up @@ -115,13 +117,13 @@ function readInputData() {
* Queue payment and save gift details.
*/
function execute() {
$journal =& Request::getJournal();
$journal =& $this->request->getJournal();
$journalId = $journal->getId();

// Create new gift and save details
import('classes.gift.Gift');
import('classes.payment.ojs.OJSPaymentManager');
$paymentManager =& OJSPaymentManager::getManager();
$paymentManager = new OJSPaymentManager($this->request);
$paymentPlugin =& $paymentManager->getPaymentPlugin();

$gift = new Gift();
Expand Down
Loading

0 comments on commit e0c2682

Please sign in to comment.