Open Monograph Press  3.3.0
WorkflowHandler.inc.php
1 <?php
2 
16 import('lib.pkp.pages.workflow.PKPWorkflowHandler');
17 
18 // Access decision actions constants.
19 import('classes.workflow.EditorDecisionActionsManager');
20 
25  function __construct() {
26  parent::__construct();
27 
28  $this->addRoleAssignment(
29  array(ROLE_ID_SUB_EDITOR, ROLE_ID_MANAGER, ROLE_ID_ASSISTANT),
30  array(
31  'access', 'index', 'submission',
32  'editorDecisionActions', // Submission & review
33  'internalReview', // Internal review
34  'externalReview', // External review
35  'editorial',
36  'production',
37  'submissionHeader',
38  'submissionProgressBar',
39  )
40  );
41  }
42 
43 
44  //
45  // Public handler methods
46  //
52  function internalReview($args, $request) {
53  $this->_redirectToIndex($args, $request);
54  }
55 
60  function setupIndex($request) {
61  parent::setupIndex($request);
62 
63  $templateMgr = TemplateManager::getManager($request);
64  $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
65 
66  $submissionContext = $request->getContext();
67  if ($submission->getContextId() !== $submissionContext->getId()) {
68  $submissionContext = Services::get('context')->get($submission->getContextId());
69  }
70 
71  $supportedFormLocales = $submissionContext->getSupportedFormLocales();
72  $localeNames = AppLocale::getAllLocales();
73  $locales = array_map(function($localeKey) use ($localeNames) {
74  return ['key' => $localeKey, 'label' => $localeNames[$localeKey]];
75  }, $supportedFormLocales);
76 
77  $latestPublication = $submission->getLatestPublication();
78 
79  $submissionApiUrl = $request->getDispatcher()->url($request, ROUTE_API, $submissionContext->getData('urlPath'), 'submissions/' . $submission->getId());
80  $latestPublicationApiUrl = $request->getDispatcher()->url($request, ROUTE_API, $submissionContext->getData('urlPath'), 'submissions/' . $submission->getId() . '/publications/' . $latestPublication->getId());
81  $temporaryFileApiUrl = $request->getDispatcher()->url($request, ROUTE_API, $submissionContext->getData('urlPath'), 'temporaryFiles');
82 
83  $chaptersGridUrl = $request->getDispatcher()->url(
84  $request,
85  ROUTE_COMPONENT,
86  null,
87  'grid.users.chapter.ChapterGridHandler',
88  'fetchGrid',
89  null,
90  [
91  'submissionId' => $submission->getId(),
92  'publicationId' => '__publicationId__',
93  ]
94  );
95 
96  import('classes.file.PublicFileManager');
97  $publicFileManager = new PublicFileManager();
98  $baseUrl = $request->getBaseUrl() . '/' . $publicFileManager->getContextFilesPath($submissionContext->getId());
99 
100  $audienceForm = new APP\components\forms\submission\AudienceForm($submissionApiUrl, $submission);
101  $catalogEntryForm = new APP\components\forms\publication\CatalogEntryForm($latestPublicationApiUrl, $locales, $latestPublication, $submission, $baseUrl, $temporaryFileApiUrl);
102  $publicationDatesForm = new APP\components\forms\submission\PublicationDatesForm($submissionApiUrl, $submission);
103 
104  $templateMgr->setConstants([
105  'FORM_AUDIENCE',
106  'FORM_CATALOG_ENTRY',
107  'WORK_TYPE_AUTHORED_WORK',
108  'WORK_TYPE_EDITED_VOLUME',
109  ]);
110 
111  $components = $templateMgr->getState('components');
112  $components[FORM_AUDIENCE] = $audienceForm->getConfig();
113  $components[FORM_CATALOG_ENTRY] = $catalogEntryForm->getConfig();
114  $components[FORM_PUBLICATION_DATES] = $publicationDatesForm->getConfig();
115 
116  $publicationFormIds = $templateMgr->getState('publicationFormIds');
117  $publicationFormIds[] = FORM_CATALOG_ENTRY;
118 
119  $templateMgr->setState([
120  'components' => $components,
121  'chaptersGridUrl' => $chaptersGridUrl,
122  'publicationFormIds' => $publicationFormIds,
123  'editedVolumeLabel' => __('submission.workflowType.editedVolume.label'),
124  'monographLabel' => __('common.publication'),
125  ]);
126 
127  $templateMgr->assign([
128  'pageComponent' => 'WorkflowPage',
129  ]);
130  }
131 
132 
133  //
134  // Protected helper methods
135  //
141  protected function getEditorAssignmentNotificationTypeByStageId($stageId) {
142  switch ($stageId) {
143  case WORKFLOW_STAGE_ID_SUBMISSION:
144  return NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_SUBMISSION;
145  case WORKFLOW_STAGE_ID_INTERNAL_REVIEW:
146  return NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_INTERNAL_REVIEW;
147  case WORKFLOW_STAGE_ID_EXTERNAL_REVIEW:
148  return NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EXTERNAL_REVIEW;
149  case WORKFLOW_STAGE_ID_EDITING:
150  return NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EDITING;
151  case WORKFLOW_STAGE_ID_PRODUCTION:
152  return NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_PRODUCTION;
153  }
154  return null;
155  }
156 
160  protected function _getRepresentationsGridUrl($request, $submission) {
161  return $request->getDispatcher()->url(
162  $request,
163  ROUTE_COMPONENT,
164  null,
165  'grid.catalogEntry.PublicationFormatGridHandler',
166  'fetchGrid',
167  null,
168  [
169  'submissionId' => $submission->getId(),
170  'publicationId' => '__publicationId__',
171  ]
172  );
173  }
174 }
PKPHandler\addRoleAssignment
addRoleAssignment($roleIds, $operations)
Definition: PKPHandler.inc.php:213
PKPLocale\getAllLocales
static & getAllLocales()
Definition: PKPLocale.inc.php:537
WorkflowHandler\__construct
__construct()
Definition: WorkflowHandler.inc.php:25
PKPWorkflowHandler
Definition: PKPWorkflowHandler.inc.php:24
WorkflowHandler\getEditorAssignmentNotificationTypeByStageId
getEditorAssignmentNotificationTypeByStageId($stageId)
Definition: WorkflowHandler.inc.php:141
WorkflowHandler\_getRepresentationsGridUrl
_getRepresentationsGridUrl($request, $submission)
Definition: WorkflowHandler.inc.php:160
PublicFileManager
Wrapper class for uploading files to a site/press' public directory.
Definition: PublicFileManager.inc.php:19
PKPWorkflowHandler\_redirectToIndex
_redirectToIndex($args, $request)
Definition: PKPWorkflowHandler.inc.php:460
APP\components\forms\submission\PublicationDatesForm
Definition: PublicationDatesForm.inc.php:21
WorkflowHandler\setupIndex
setupIndex($request)
Definition: WorkflowHandler.inc.php:60
PKPTemplateManager\getManager
static & getManager($request=null)
Definition: PKPTemplateManager.inc.php:1239
APP\components\forms\publication\CatalogEntryForm
Definition: CatalogEntryForm.inc.php:25
APP\components\forms\submission\AudienceForm
Definition: AudienceForm.inc.php:21
PKPHandler\getAuthorizedContextObject
& getAuthorizedContextObject($assocType)
Definition: PKPHandler.inc.php:174
WorkflowHandler\internalReview
internalReview($args, $request)
Definition: WorkflowHandler.inc.php:52
WorkflowHandler
Handle requests for the submssion workflow.
Definition: WorkflowHandler.inc.php:21
PKPServices\get
static get($service)
Definition: PKPServices.inc.php:49