Skip to content

Commit

Permalink
*5868* remove instances of HandlerValidatorCustom from OJS, introduce…
Browse files Browse the repository at this point in the history
… OjsJournalMustPublish policy
  • Loading branch information
jnugent committed Jun 21, 2013
1 parent 0de0f95 commit fdfafde
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 6 deletions.
44 changes: 44 additions & 0 deletions classes/security/authorization/OjsJournalMustPublishPolicy.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* @file classes/security/authorization/OjsAuthorDashboardAccessPolicy.inc.php

This comment has been minimized.

Copy link
@bozana

bozana Jun 27, 2013

Contributor

the file name is wrong, should be OjsJournalMustPublishPolicy.inc.php

*
* Copyright (c) 2000-2013 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class OjsAuthorDashboardAccessPolicy
* @ingroup security_authorization
*
* @brief Class to control access to OMP author dashboard.
*/

import('lib.pkp.classes.security.authorization.PolicySet');
import('lib.pkp.classes.security.authorization.AuthorizationPolicy');

class OjsJournalMustPublishPolicy extends AuthorizationPolicy {

var $_context;

/**
* Constructor
* @param $request PKPRequest
* @param $args array request arguments
* @param $roleAssignments array
*/
function OjsJournalMustPublishPolicy($request) {
parent::AuthorizationPolicy('user.authorization.journalDoesNotPublish');
$this->_context = $request->getContext();
}

//
// Implement template methods from AuthorizationPolicy
//
function effect() {

if (!$this->_context || $this->_context->getSetting('publishingMode') == PUBLISHING_MODE_NONE) {

This comment has been minimized.

Copy link
@bozana

bozana Jun 27, 2013

Contributor

shouldn't this be:
if ($this->_context && $this->_context->getSetting('publishingMode') == PUBLISHING_MODE_NONE) {...

This comment has been minimized.

Copy link
@jnugent

jnugent Jun 27, 2013

Author Member

I don't think so -- the first test enforces the presence of a context (a journal in this case). I think we want that, no?

This comment has been minimized.

Copy link
@bozana

bozana Jun 27, 2013

Contributor

Hmmm... I think that therefore there is ContextRequiredPolicy. Or, at least for the SearchHandler this is not correctly -- there don't have to be a context, but if there is one it has to be in the right publishing mode.

This comment has been minimized.

Copy link
@jnugent

jnugent Jun 27, 2013

Author Member

Fair enough -- I assumed that we needed a context in order to search. I will defer to your expertise on this one and make the change to the policy :)

This comment has been minimized.

Copy link
@bozana

bozana Jun 27, 2013

Contributor

;-) Well, my expertise... lets see where this will lead us :-D
This policy is also always used with ContextRequiredPolicy till now, so I assume this shouldn't be chacked here too (if I understand the ContextRequiredPolicy correctly)

return AUTHORIZATION_DENY;
}

return AUTHORIZATION_PERMIT;
}
}
?>
6 changes: 4 additions & 2 deletions pages/article/ArticleHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class ArticleHandler extends Handler {
function ArticleHandler($request) {
parent::Handler($request);
$router = $request->getRouter();

$this->addCheck(new HandlerValidatorCustom($this, false, null, null, create_function('$journal', 'return $journal->getSetting(\'publishingMode\') != PUBLISHING_MODE_NONE;'), array($router->getContext($request))));
}

/**
Expand All @@ -49,6 +47,10 @@ function ArticleHandler($request) {
function authorize($request, &$args, $roleAssignments) {
import('lib.pkp.classes.security.authorization.ContextRequiredPolicy');
$this->addPolicy(new ContextRequiredPolicy($request));

import('classes.security.authorization.OjsJournalMustPublishPolicy');
$this->addPolicy(new OjsJournalMustPublishPolicy($request));

return parent::authorize($request, $args, $roleAssignments);
}

Expand Down
6 changes: 4 additions & 2 deletions pages/issue/IssueHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class IssueHandler extends Handler {
**/
function IssueHandler() {
parent::Handler();

$this->addCheck(new HandlerValidatorCustom($this, false, null, null, create_function('$journal', 'return $journal->getSetting(\'publishingMode\') != PUBLISHING_MODE_NONE;'), array(Request::getJournal())));
}

/**
Expand All @@ -40,6 +38,10 @@ function IssueHandler() {
function authorize($request, &$args, $roleAssignments) {
import('lib.pkp.classes.security.authorization.ContextRequiredPolicy');
$this->addPolicy(new ContextRequiredPolicy($request));

import('classes.security.authorization.OjsJournalMustPublishPolicy');
$this->addPolicy(new OjsJournalMustPublishPolicy($request));

return parent::authorize($request, $args, $roleAssignments);
}

Expand Down
17 changes: 16 additions & 1 deletion pages/search/SearchHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,22 @@ class SearchHandler extends Handler {
**/
function SearchHandler() {
parent::Handler();
$this->addCheck(new HandlerValidatorCustom($this, false, null, null, create_function('$journal', 'return !$journal || $journal->getSetting(\'publishingMode\') != PUBLISHING_MODE_NONE;'), array(Request::getJournal())));
}

/**
* @see PKPHandler::authorize()
* @param $request PKPRequest
* @param $args array
* @param $roleAssignments array
*/
function authorize($request, &$args, $roleAssignments) {
import('lib.pkp.classes.security.authorization.ContextRequiredPolicy');
$this->addPolicy(new ContextRequiredPolicy($request));

import('classes.security.authorization.OjsJournalMustPublishPolicy');
$this->addPolicy(new OjsJournalMustPublishPolicy($request));

return parent::authorize($request, $args, $roleAssignments);
}

/**
Expand Down
17 changes: 16 additions & 1 deletion plugins/generic/lucene/LuceneHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,22 @@ function LuceneHandler($request) {
parent::Handler();
$router = $request->getRouter();
$journal = $router->getContext($request);
$this->addCheck(new HandlerValidatorCustom($this, false, null, null, create_function('$journal', 'return !$journal || $journal->getSetting(\'publishingMode\') != PUBLISHING_MODE_NONE;'), array($journal)));

This comment has been minimized.

Copy link
@bozana

bozana Jun 26, 2013

Contributor

Do then $router and $journal have to be here?

This comment has been minimized.

Copy link
@jnugent

jnugent Jun 26, 2013

Author Member

Nope! Want me to remove them, or were you working on the class also?

This comment has been minimized.

Copy link
@bozana

bozana Jun 26, 2013

Contributor

Thanks Jason! I will remove them from here, because I am just trying to integrate our changes, but you could remove $journal from ArtilceHandler above :-) Team work :-) Thanks!

}

/**
* @see PKPHandler::authorize()
* @param $request PKPRequest
* @param $args array
* @param $roleAssignments array
*/
function authorize($request, &$args, $roleAssignments) {
import('lib.pkp.classes.security.authorization.ContextRequiredPolicy');
$this->addPolicy(new ContextRequiredPolicy($request));

import('classes.security.authorization.OjsJournalMustPublishPolicy');
$this->addPolicy(new OjsJournalMustPublishPolicy($request));

return parent::authorize($request, $args, $roleAssignments);
}


Expand Down

0 comments on commit fdfafde

Please sign in to comment.