Skip to content

Commit

Permalink
*8147* Move dashboard submission grids to PKP lib
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Mar 7, 2013
1 parent 0ff65c0 commit 762302f
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classes/security/PKPRole.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
define('ROLE_ID_REVIEWER', 0x00001000);
define('ROLE_PATH_REVIEWER', 'reviewer');

define('ROLE_ID_ASSISTANT', 0x00001001);
define('ROLE_ID_ASSISTANT', 0x00001001);

define('ROLE_ID_READER', 0x00100000);
define('ROLE_PATH_READER', 'reader');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

/**
* @file controllers/grid/submissions/assignedSubmissions/AssignedSubmissionsListGridHandler.inc.php
*
* Copyright (c) 2000-2013 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class AssignedSubmissionsListGridHandler
* @ingroup controllers_grid_submissions_assignedSubmissions
*
* @brief Handle submissions list grid requests (submissions the user is assigned to).
*/

// Import grid base classes.
import('lib.pkp.controllers.grid.submissions.SubmissionsListGridHandler');
import('lib.pkp.controllers.grid.submissions.SubmissionsListGridRow');

// Filter editor
define('FILTER_EDITOR_ALL', 0);
define('FILTER_EDITOR_ME', 1);

class AssignedSubmissionsListGridHandler extends SubmissionsListGridHandler {
/**
* Constructor
*/
function AssignedSubmissionsListGridHandler() {
parent::SubmissionsListGridHandler();
$this->addRoleAssignment(
array(ROLE_ID_SITE_ADMIN, ROLE_ID_MANAGER, ROLE_ID_SERIES_EDITOR, ROLE_ID_REVIEWER, ROLE_ID_ASSISTANT),
array('fetchGrid', 'fetchRow', 'deleteSubmission')
);
}


//
// Implement template methods from PKPHandler
//
/**
* @see PKPHandler::initialize()
*/
function initialize(&$request) {
parent::initialize($request);

// Set title.
$this->setTitle('common.queue.long.myAssigned');
}


//
// Implement template methods from SubmissionListGridHandler
//
/**
* @see SubmissionListGridHandler::getSubmissions()
*/
function getSubmissions(&$request, $userId) {
$submissionDao = Application::getSubmissionDAO();
$userGroupDao = DAORegistry::getDAO('UserGroupDAO');
$signoffDao = DAORegistry::getDAO('SignoffDAO');
$stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
$authorDao = DAORegistry::getDAO('AuthorDAO');

// Get submissions the user is a stage participant for
$signoffs = $signoffDao->getByUserId($userId);

$authorUserGroupIds = $userGroupDao->getUserGroupIdsByRoleId(ROLE_ID_AUTHOR);

$data = array();

// get signoffs and stage assignments
$stageAssignments = $stageAssignmentDao->getByUserId($userId);
while($stageAssignment = $stageAssignments->next()) {
$submission = $submissionDao->getById($stageAssignment->getSubmissionId());
if ($submission->getDateSubmitted() == null) { continue; }; // Still incomplete, don't add to assigned submissions grid.

if ($submission->getDatePublished() != null) { continue; } // This is published, don't add to the submissions grid

// Check if user is a submitter of this submission.
if ($userId == $submission->getUserId()) { continue; }; // It will be in the 'my submissions' grid.

$submissionId = $submission->getId();
$data[$submissionId] = $submission;
}

while($signoff = $signoffs->next()) {
// If it is a submission signoff (and not, say, a file signoff) and
// If this is an author signoff, do not include (it will be in the 'my submissions' grid)
if( $signoff->getAssocType() == ASSOC_TYPE_SUBMISSION &&
!in_array($signoff->getUserGroupId(), $authorUserGroupIds)) {
$submission = $submissionDao->getById($signoff->getAssocId());
$submissionId = $submission->getId();
$data[$submissionId] = $submission;
}
}

// Get submissions the user is reviewing
$reviewerSubmissionDao = DAORegistry::getDAO('ReviewerSubmissionDAO'); /* @var $reviewerSubmissionDao ReviewerSubmissionDAO */
$reviewerSubmissions = $reviewerSubmissionDao->getReviewerSubmissionsByReviewerId($userId);
while($reviewerSubmission = $reviewerSubmissions->next()) {
$submissionId = $reviewerSubmission->getId();
if (!isset($data[$submissionId])) {
// Only add if not already provided above --
// otherwise reviewer workflow link may
// clobber editorial workflow link
$data[$submissionId] = $reviewerSubmission;
}
}

return $data;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/**
* @file controllers/grid/submissions/mySubmissions/MySubmissionsListGridHandler.inc.php
*
* Copyright (c) 2000-2013 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class MySubmissionsListGridHandler
* @ingroup controllers_grid_submissions_mySubmissions
*
* @brief Handle author's submissions list grid requests (submissions the user has made).
*/

// Import grid base classes.
import('lib.pkp.controllers.grid.submissions.SubmissionsListGridHandler');
import('lib.pkp.controllers.grid.submissions.SubmissionsListGridRow');

// Import 'my submissions' list specific grid classes.
import('lib.pkp.controllers.grid.submissions.mySubmissions.MySubmissionsListGridCellProvider');

class MySubmissionsListGridHandler extends SubmissionsListGridHandler {
/**
* Constructor
*/
function MySubmissionsListGridHandler() {
parent::SubmissionsListGridHandler();
$this->addRoleAssignment(
array(ROLE_ID_MANAGER, ROLE_ID_SERIES_EDITOR, ROLE_ID_ASSISTANT, ROLE_ID_AUTHOR),
array('fetchGrid', 'fetchRow', 'deleteSubmission')
);
}

//
// Implement template methods from PKPHandler
//
/**
* @see PKPHandler::initialize()
*/
function initialize(&$request) {
parent::initialize($request);

$titleColumn = $this->getColumn('title');
$titleColumn->setCellProvider(new MySubmissionsListGridCellProvider());
}


//
// Implement template methods from SubmissionListGridHandler
//
/**
* @see SubmissionListGridHandler::getSubmissions()
*/
function getSubmissions($request, $userId) {
$this->setTitle('submission.mySubmissions');

$submissionDao = Application::getSubmissionDAO();
$submissions = $submissionDao->getByUserId($userId);
$data = array();
while ($submission = $submissions->next()) {
if ($submission->getDatePublished() == null) {
$submissionId = $submission->getId();
$data[$submissionId] = $submission;
}
}

return $data;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php

/**
* @file controllers/grid/submissions/unassignedSubmissions/UnassignedSubmissionsListGridHandler.inc.php
*
* Copyright (c) 2000-2013 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class UnassignedSubmissionsListGridHandler
* @ingroup controllers_grid_submissions_unassignedSubmissions
*
* @brief Handle unassigned submissions list grid requests.
*/

// Import grid base classes.
import('lib.pkp.controllers.grid.submissions.SubmissionsListGridHandler');
import('lib.pkp.controllers.grid.submissions.SubmissionsListGridRow');

// Filter editor
define('FILTER_EDITOR_ALL', 0);
define('FILTER_EDITOR_ME', 1);

class UnassignedSubmissionsListGridHandler extends SubmissionsListGridHandler {
/**
* Constructor
*/
function UnassignedSubmissionsListGridHandler() {
parent::SubmissionsListGridHandler();
$this->addRoleAssignment(
array(ROLE_ID_MANAGER, ROLE_ID_SERIES_EDITOR),
array('fetchGrid', 'fetchRow', 'deleteSubmission')
);
}


//
// Implement template methods from PKPHandler
//
/**
* @see PKPHandler::initialize()
*/
function initialize(&$request) {
parent::initialize($request);

// Set title.
$this->setTitle('common.queue.long.submissionsUnassigned');

// Add editor specific locale component.
AppLocale::requireComponents(LOCALE_COMPONENT_APP_EDITOR);
}


//
// Implement template methods from SubmissionListGridHandler
//
/**
* @see SubmissionListGridHandler::getSubmissions()
*/
function getSubmissions($request, $userId) {
$submissionDao = Application::getSubmissionDAO(); /* @var $submissionDao SubmissionDAO */

// Determine whether this is a Series Editor or Manager.
// Managers can access all submissions, Series Editors
// only assigned submissions.
$user = $request->getUser();

// Get all submissions for all contexts that user is
// enrolled in as manager or series editor.
$roleDao = DAORegistry::getDAO('RoleDAO');
$contextDao = Application::getContextDAO();
$contexts = $contextDao->getAll();

$accessibleSubmissions = array();
while ($context = $contexts->next()) {
$isManager = $roleDao->userHasRole($context->getId(), $userId, ROLE_ID_MANAGER);
$isSeriesEditor = $roleDao->userHasRole($context->getId(), $userId, ROLE_ID_SERIES_EDITOR);

if (!$isManager && !$isSeriesEditor) {
continue;
}

$submissionFactory = $submissionDao->getBySubEditorId(
$context->getId(),
$isManager?null:$userId
);

if (!$submissionFactory->wasEmpty()) {
$stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
while ($submission = $submissionFactory->next()) {
if ($submission->getDatePublished() == null && !$stageAssignmentDao->editorAssignedToStage($submission->getId())) {
$accessibleSubmissions[$submission->getId()] = $submission;
}
}
}
}

return $accessibleSubmissions;
}
}

?>

0 comments on commit 762302f

Please sign in to comment.