-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*8147* Move dashboard submission grids to PKP lib
- Loading branch information
Showing
4 changed files
with
286 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
controllers/grid/submissions/assignedSubmissions/AssignedSubmissionsListGridHandler.inc.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
?> |
71 changes: 71 additions & 0 deletions
71
controllers/grid/submissions/mySubmissions/MySubmissionsListGridHandler.inc.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
?> |
101 changes: 101 additions & 0 deletions
101
...llers/grid/submissions/unassignedSubmissions/UnassignedSubmissionsListGridHandler.inc.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
?> |