Skip to content

Commit

Permalink
pkp/pkp-lib#9296 Sandbox settings
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir authored and asmecher committed Feb 15, 2024
1 parent ce77f23 commit 95cd926
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
4 changes: 4 additions & 0 deletions config.TEMPLATE.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@
; 0, unvalidated accounts will never be removed. Use this setting to automatically remove bot registrations.
user_validation_period = 28

; Turn sandbox mode to On in order to prevent the software from interacting with outside systems.
; Use this for development or testing purposes.
sandbox = Off


;;;;;;;;;;;;;;;;;;;;;
; Database Settings ;
Expand Down
6 changes: 6 additions & 0 deletions plugins/generic/datacite/DataciteExportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ public function exportAsDownload(Context $context, array $objects, ?bool $noVali
*/
public function depositXML($object, $context, $filename)
{
// Application is set to sandbox mode and will not run the features of plugin
if (Config::getVar('general', 'sandbox', false)) {
error_log('Application is set to sandbox mode and datacite will not do any deposition');
return false;
}

$request = Application::get()->getRequest();
// Get the DOI and the URL for the object.
$doi = $object->getStoredPubId('doi');
Expand Down
10 changes: 10 additions & 0 deletions plugins/paymethod/paypal/PaypalPaymentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use APP\core\Request;
use APP\template\TemplateManager;
use Omnipay\PayPal\Message\RestAuthorizeResponse;
use PKP\config\Config;
use PKP\form\Form;
use PKP\payment\QueuedPayment;

Expand Down Expand Up @@ -49,6 +50,15 @@ public function __construct($paypalPaymentPlugin, $queuedPayment)
*/
public function display($request = null, $template = null)
{
// Application is set to sandbox mode and will not run the features of plugin
if (Config::getVar('general', 'sandbox', false)) {
error_log('Application is set to sandbox mode and no payment will be done via paypal');
TemplateManager::getManager($request)
->assign('message', 'common.sandbox')
->display('frontend/pages/message.tpl');
return;
}

try {
$journal = $request->getJournal();
$paymentManager = Application::getPaymentManager($journal);
Expand Down
18 changes: 13 additions & 5 deletions plugins/paymethod/paypal/PaypalPaymentPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use APP\template\TemplateManager;
use Illuminate\Support\Collection;
use Omnipay\Omnipay;
use PKP\config\Config;
use PKP\db\DAORegistry;
use PKP\plugins\Hook;
use PKP\plugins\PaymethodPlugin;
Expand Down Expand Up @@ -60,12 +61,13 @@ public function getDescription()
*/
public function register($category, $path, $mainContextId = null)
{
if (parent::register($category, $path, $mainContextId)) {
$this->addLocaleData();
Hook::add('Form::config::before', $this->addSettings(...));
return true;
if (!parent::register($category, $path, $mainContextId)) {
return false;
}
return false;

$this->addLocaleData();
Hook::add('Form::config::before', $this->addSettings(...));
return true;
}

/**
Expand Down Expand Up @@ -175,6 +177,12 @@ public function isConfigured($context)
*/
public function handle($args, $request)
{
// Application is set to sandbox mode and will not run the features of plugin
if (Config::getVar('general', 'sandbox', false)) {
error_log('Application is set to sandbox mode and no payment will be done via paypal');
return;
}

$journal = $request->getJournal();
$queuedPaymentDao = DAORegistry::getDAO('QueuedPaymentDAO'); /** @var \PKP\payment\QueuedPaymentDAO $queuedPaymentDao */
try {
Expand Down

0 comments on commit 95cd926

Please sign in to comment.