Skip to content

Commit d13bbc1

Browse files
jonasraoniasmecher
authored andcommitted
pkp/pkp-lib#7914 Allow the plugin URLs to be accessible for non-public journals
1 parent 9636635 commit d13bbc1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

PLNPlugin.inc.php

+26
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public function register($category, $path, $mainContextId = null) {
9393
HookRegistry::register('LoadHandler', array($this, 'callbackLoadHandler'));
9494
HookRegistry::register('NotificationManager::getNotificationContents', array($this, 'callbackNotificationContents'));
9595
HookRegistry::register('LoadComponentHandler', array($this, 'setupComponentHandlers'));
96+
$this->_disableRestrictions();
9697
}
9798

9899
HookRegistry::register('AcronPlugin::parseCronTab', array($this, 'callbackParseCronTab'));
@@ -118,6 +119,31 @@ public function setupComponentHandlers($hookName, $params) {
118119
return false;
119120
}
120121

122+
/**
123+
* When the request is supposed to be handled by the plugin, this method will disable:
124+
* - Redirecting non-logged users (the staging server) at contexts protected by login
125+
* - Redirecting non-logged users (the staging server) at non-public contexts to the login page (see more at: PKPPageRouter::route())
126+
*/
127+
private function _disableRestrictions() {
128+
$request = $this->getRequest();
129+
// Avoid issues with the APIRouter
130+
if (!($request->getRouter() instanceof PageRouter)) {
131+
return;
132+
}
133+
134+
$page = $request->getRequestedPage();
135+
$operation = $request->getRequestedOp();
136+
$arguments = $request->getRequestedArgs();
137+
if ([$page, $operation] === ['pln', 'deposits'] || [$page, $operation, $arguments[0] ?? ''] === ['gateway', 'plugin', 'PLNGatewayPlugin']) {
138+
define('SESSION_DISABLE_INIT', true);
139+
HookRegistry::register('RestrictedSiteAccessPolicy::_getLoginExemptions', function ($hookName, $args) {
140+
$exemptions =& $args[0];
141+
array_push($exemptions, 'gateway', 'pln');
142+
return false;
143+
});
144+
}
145+
}
146+
121147
/**
122148
* @copydoc Plugin::getActions()
123149
*/

0 commit comments

Comments
 (0)