Skip to content

Commit

Permalink
Merge pull request #1 from pkp/master
Browse files Browse the repository at this point in the history
OJS update
  • Loading branch information
Vitaliy-1 authored Mar 5, 2018
2 parents 5580f36 + b2ba081 commit 7970375
Show file tree
Hide file tree
Showing 1,913 changed files with 12,558 additions and 9,268 deletions.
4 changes: 2 additions & 2 deletions api/v1/_submissions/BackendSubmissionsHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @file api/v1/_submissions/BackendSubmissionsHandler.inc.php
*
* Copyright (c) 2014-2017 Simon Fraser University
* Copyright (c) 2003-2017 John Willinsky
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2003-2018 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class BackendSubmissionsHandler
Expand Down
4 changes: 2 additions & 2 deletions api/v1/_submissions/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/**
* @file api/v1/_submissions/index.php
*
* Copyright (c) 2014-2017 Simon Fraser University
* Copyright (c) 2003-2017 John Willinsky
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2003-2018 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @ingroup api_v1_backend
Expand Down
111 changes: 90 additions & 21 deletions api/v1/issues/IssueHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @file api/v1/issues/IssueHandler.inc.php
*
* Copyright (c) 2014-2017 Simon Fraser University
* Copyright (c) 2003-2017 John Willinsky
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2003-2018 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class IssueHandler
Expand Down Expand Up @@ -83,33 +83,102 @@ function authorize($request, &$args, $roleAssignments) {
* @return Response
*/
public function getIssueList($slimRequest, $response, $args) {

$request = $this->getRequest();
$currentUser = $request->getUser();
$context = $request->getContext();
$data = array();
$issueService = ServicesContainer::instance()->get('issue');

$volume = $this->getParameter('volume', null);
$number = $this->getParameter('number', null);
$year = $this->getParameter('year', null);
if (!$context) {
return $response->withStatus(404)->withJsonError('api.submissions.404.resourceNotFound');
}

if (($volume && !ctype_digit($volume))
|| ($number && !is_string($number))
|| ($year && !ctype_digit($year))) {
return $response->withStatus(400)->withJsonError('api.submissions.400.invalidIssueIdentifiers');
$defaultParams = array(
'count' => 20,
'offset' => 0,
);

$requestParams = array_merge($defaultParams, $slimRequest->getQueryParams());

$params = array();

// Process query params to format incoming data as needed
foreach ($requestParams as $param => $val) {
switch ($param) {

case 'orderBy':
if (in_array($val, array('datePublished', 'lastModified'))) {
$params[$param] = $val;
}
break;

case 'orderDirection':
$params[$param] = $val === 'ASC' ? $val : 'DESC';
break;

// Enforce a maximum count to prevent the API from crippling the
// server
case 'count':
$params[$param] = min(100, (int) $val);
break;

case 'offset':
$params[$param] = (int) $val;
break;

// Always convert volume, number and year values to array
case 'volumes':
case 'volume':
case 'numbers':
case 'number':
case 'years':
case 'year':

// Support deprecated `year`, `number` and `volume` params
if (substr($param, -1) === 's') {
$param = substr($param, 0, -1);
}

if (is_string($val) && strpos($val, ',') > -1) {
$val = explode(',', $val);
} elseif (!is_array($val)) {
$val = array($val);
}
$params[$param] = array_map('intval', $val);
break;

case 'isPublished':
$params[$param] = $val ? true : false;
break;
}
}

$issueDao = DAORegistry::getDAO('IssueDAO');
$issues = $issueDao->getPublishedIssuesByNumber($context->getId(), $volume, $number, $year);

while ($issue = $issues->next()) {
$data[] = ServicesContainer::instance()
->get('issue')
->getSummaryProperties($issue, array(
'request' => $request,
'slimRequest' => $slimRequest,
));
\HookRegistry::call('API::issues::params', array(&$params, $slimRequest));

// You must be a manager or site admin to access unpublished Issues
$isAdmin = $currentUser->hasRole(array(ROLE_ID_MANAGER, ROLE_ID_SITE_ADMIN), $context->getId());
if (isset($params['isPublished']) && !$params['isPublished'] && !$isAdmin) {
return $response->withStatus(403)->withJsonError('api.submissions.403.unpublishedIssues');
} elseif (!$isAdmin) {
$params['isPublished'] = true;
}

$items = array();
$issues = $issueService->getIssues($context->getId(), $params);
if (!empty($issues)) {
$propertyArgs = array(
'request' => $request,
'slimRequest' => $slimRequest,
);
foreach ($issues as $issue) {
$items[] = $issueService->getSummaryProperties($issue, $propertyArgs);
}
}

$data = array(
'itemsMax' => $issueService->getIssuesMaxCount($context->getId(), $params),
'items' => $items,
);

return $response->withJson($data, 200);
}

Expand Down
4 changes: 2 additions & 2 deletions api/v1/issues/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/**
* @file api/v1/issues/index.php
*
* Copyright (c) 2014-2017 Simon Fraser University
* Copyright (c) 2003-2017 John Willinsky
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2003-2018 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @ingroup api_v1_issues
Expand Down
61 changes: 57 additions & 4 deletions api/v1/submissions/SubmissionHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @file api/v1/submission/SubmissionHandler.inc.php
*
* Copyright (c) 2014-2017 Simon Fraser University
* Copyright (c) 2003-2017 John Willinsky
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2003-2018 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class SubmissionHandler
Expand Down Expand Up @@ -42,6 +42,16 @@ public function __construct() {
'handler' => array($this, 'getGalleys'),
'roles' => $roles
),
array(
'pattern' => $this->getEndpointPattern() . '/{submissionId}/participants',
'handler' => array($this, 'getParticipants'),
'roles' => array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR),
),
array(
'pattern' => $this->getEndpointPattern() . '/{submissionId}/participants/{stageId}',
'handler' => array($this, 'getParticipants'),
'roles' => array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR),
),
),
);
parent::__construct();
Expand All @@ -58,7 +68,7 @@ function authorize($request, &$args, $roleAssignments) {
$routeName = $route->getName();
}

if ($routeName === 'getSubmission' || $routeName === 'getGalleys') {
if ($routeName === 'getSubmission' || $routeName === 'getGalleys' || $routeName === 'getParticipants') {
import('lib.pkp.classes.security.authorization.SubmissionAccessPolicy');
$this->addPolicy(new SubmissionAccessPolicy($request, $args, $roleAssignments));
}
Expand Down Expand Up @@ -107,7 +117,7 @@ public function getSubmissionList($slimRequest, $response, $args) {
}

$data = array(
'maxItems' => $submissionService->getSubmissionsMaxCount($context->getId(), $params),
'itemsMax' => $submissionService->getSubmissionsMaxCount($context->getId(), $params),
'items' => $items,
);

Expand Down Expand Up @@ -186,6 +196,49 @@ public function getGalleys($slimRequest, $response, $args) {
return $response->withJson($data, 200);
}

/**
* Get the participants assigned to a submission
*
* This does not return reviewers.
*
* @param $slimRequest Request Slim request object
* @param $response Response object
* @param array $args arguments
*
* @return Response
*/
public function getParticipants($slimRequest, $response, $args) {
$request = $this->getRequest();
$context = $request->getContext();
$submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
$stageId = isset($args['stageId']) ? $args['stageId'] : null;

if (!$submission) {
return $response->withStatus(404)->withJsonError('api.submissions.404.resourceNotFound');
}

$data = array();

$userService = ServicesContainer::instance()->get('user');

$users = $userService->getUsers($context->getId(), array(
'count' => 100, // high upper-limit
'assignedToSubmission' => $submission->getId(),
'assignedToSubmissionStage' => $stageId,
));
if (!empty($users)) {
$args = array(
'request' => $request,
'slimRequest' => $slimRequest,
);
foreach ($users as $user) {
$data[] = $userService->getSummaryProperties($user, $args);
}
}

return $response->withJson($data, 200);
}

/**
* Convert params passed to list requests. Coerce type and only return
* white-listed params.
Expand Down
4 changes: 2 additions & 2 deletions api/v1/submissions/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/**
* @file api/v1/submissions/index.php
*
* Copyright (c) 2014-2017 Simon Fraser University
* Copyright (c) 2003-2017 John Willinsky
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2003-2018 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @ingroup api_v1_submissions
Expand Down
19 changes: 19 additions & 0 deletions api/v1/users/UserHandler.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* @file api/v1/users/UserHandler.inc.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2003-2018 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class UserHandler
* @ingroup api_v1_users
*
* @brief Handle API requests for user operations.
*
*/

import('lib.pkp.api.v1.users.PKPUserHandler');

class UserHandler extends PKPUserHandler { }
20 changes: 20 additions & 0 deletions api/v1/users/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* @defgroup api_v1_users User API requests
*/

/**
* @file api/v1/users/index.php
*
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2003-2018 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @ingroup api_v1_users
* @brief Handle requests for user API functions.
*
*/

import('api.v1.users.UserHandler');
return new UserHandler();
4 changes: 2 additions & 2 deletions classes/article/Article.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/**
* @file classes/article/Article.inc.php
*
* Copyright (c) 2014-2017 Simon Fraser University
* Copyright (c) 2003-2017 John Willinsky
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2003-2018 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class Article
Expand Down
4 changes: 2 additions & 2 deletions classes/article/ArticleDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @file classes/article/ArticleDAO.inc.php
*
* Copyright (c) 2014-2017 Simon Fraser University
* Copyright (c) 2003-2017 John Willinsky
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2003-2018 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class ArticleDAO
Expand Down
4 changes: 2 additions & 2 deletions classes/article/ArticleGalley.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @file classes/article/ArticleGalley.inc.php
*
* Copyright (c) 2014-2017 Simon Fraser University
* Copyright (c) 2003-2017 John Willinsky
* Copyright (c) 2014-2018 Simon Fraser University
* Copyright (c) 2003-2018 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class ArticleGalley
Expand Down
Loading

0 comments on commit 7970375

Please sign in to comment.