17 import(
'lib.pkp.classes.controllers.grid.GridHandler');
20 import(
'lib.pkp.classes.linkAction.request.AjaxModal');
31 parent::__construct();
33 array(ROLE_ID_AUTHOR, ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT),
34 array(
'fetchGrid',
'fetchRow'));
36 array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT),
37 array(
'addGalley',
'editGalley',
'editGalleyTab',
'updateGalley',
'deleteGalley',
'identifiers',
'updateIdentifiers',
'clearPubId',
'saveSequence'));
76 return '$.pkp.controllers.grid.articleGalleys.ArticleGalleyGridHandler';
82 function authorize($request, &$args, $roleAssignments) {
83 $this->_request = $request;
85 import(
'lib.pkp.classes.security.authorization.WorkflowStageAccessPolicy');
88 import(
'lib.pkp.classes.security.authorization.PublicationAccessPolicy');
91 if ($request->getUserVar(
'representationId')) {
92 import(
'lib.pkp.classes.security.authorization.internal.RepresentationRequiredPolicy');
96 return parent::authorize($request, $args, $roleAssignments);
103 parent::initialize($request, $args);
104 $this->
setTitle(
'submission.layout.galleys');
108 LOCALE_COMPONENT_PKP_SUBMISSION,
109 LOCALE_COMPONENT_PKP_USER,
110 LOCALE_COMPONENT_PKP_EDITOR,
111 LOCALE_COMPONENT_APP_EDITOR
114 import(
'controllers.grid.articleGalleys.ArticleGalleyGridCellProvider');
130 $request->getRouter()->url($request,
null,
null,
'addGalley',
null, $this->getRequestArgs()),
131 __(
'submission.layout.newGalley'),
134 __(
'grid.action.addGalley'),
148 import(
'lib.pkp.classes.controllers.grid.feature.OrderGridItemsFeature');
159 return $row->getSequence();
167 $galley = $galleyDao->getById($rowId);
168 $galley->setSequence($newSequence);
169 $galleyDao->updateObject($galley);
180 import(
'controllers.grid.articleGalleys.ArticleGalleyGridRow');
203 function loadData($request, $filter =
null) {
219 $representation = $representationDao->getById($request->getUserVar(
'representationId'));
220 import(
'controllers.tab.pubIds.form.PublicIdentifiersForm');
223 return new JSONMessage(
true, $form->fetch($request));
234 $representation = $representationDao->getById($request->getUserVar(
'representationId'));
235 import(
'controllers.tab.pubIds.form.PublicIdentifiersForm');
237 $form->readInputData();
238 if ($form->validate()) {
242 return new JSONMessage(
true, $form->fetch($request));
253 if (!$request->checkCSRF())
return new JSONMessage(
false);
257 $representation = $representationDao->getById($request->getUserVar(
'representationId'));
258 import(
'controllers.tab.pubIds.form.PublicIdentifiersForm');
260 $form->clearPubId($request->getUserVar(
'pubIdPlugIn'));
271 import(
'controllers.grid.articleGalleys.form.ArticleGalleyForm');
277 $galleyForm->initData();
278 return new JSONMessage(
true, $galleyForm->fetch($request));
289 if (!$galley || !$request->checkCSRF())
return new JSONMessage(
false);
292 $galleyDao->deleteObject($galley);
294 if ($galley->getFileId()) {
295 import(
'lib.pkp.classes.submission.SubmissionFile');
296 $publication =
Services::get(
'publication')->get($galley->getData(
'publicationId'));
301 $galleyFiles = $submissionFileDao->getLatestRevisionsByAssocId(ASSOC_TYPE_GALLEY, $galley->getId(), $publication->getData(
'submissionId'), SUBMISSION_FILE_PROOF);
302 foreach ($galleyFiles as $file) {
303 $sharedFileGalleys = $articleGalleyDao->getByFileId($file->getFileId())->toArray();
304 if (empty($sharedFileGalleys)) {
305 $submissionFileDao->deleteAllRevisionsByAssocId(ASSOC_TYPE_SUBMISSION_FILE, $file->getFileId(), SUBMISSION_FILE_DEPENDENT);
310 $sharedFileGalleys = $articleGalleyDao->getByFileId($galley->getFileId())->toArray();
311 if (empty($sharedFileGalleys)) {
313 $submissionFileDao->deleteAllRevisionsById($galley->getFileId());
318 $notificationDao->deleteByAssoc(ASSOC_TYPE_REPRESENTATION, $galley->getId());
320 if ($this->
getSubmission()->getStageId() == WORKFLOW_STAGE_ID_EDITING ||
321 $this->
getSubmission()->getStageId() == WORKFLOW_STAGE_ID_PRODUCTION) {
324 $notificationMgr->updateNotification(
326 array(NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER, NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS),
328 ASSOC_TYPE_SUBMISSION,
336 $articleSearchIndex->submissionChangesFinished();
352 $templateMgr->assign(array(
355 'representationId' => $galley->getId(),
357 $publisherIdEnabled = in_array(
'galley', (array) $request->getContext()->getData(
'enablePublisherId'));
358 $pubIdsEnabled =
false;
360 foreach ($pubIdPlugins as $pubIdPlugin) {
361 if ($pubIdPlugin->isObjectTypeEnabled(
'Representation', $request->getContext()->getId())) {
362 $pubIdsEnabled =
true;
366 if ($publisherIdEnabled || $pubIdsEnabled) {
367 $templateMgr->assign(
'enableIdentifiers',
true);
369 return new JSONMessage(
true, $templateMgr->fetch(
'controllers/grid/articleGalleys/editFormat.tpl'));
380 import(
'controllers.grid.articleGalleys.form.ArticleGalleyForm');
387 $galleyForm->initData();
388 return new JSONMessage(
true, $galleyForm->fetch($request));
400 import(
'controllers.grid.articleGalleys.form.ArticleGalleyForm');
402 $galleyForm->readInputData();
404 if ($galleyForm->validate()) {
405 $galley = $galleyForm->execute();
407 if ($this->
getSubmission()->getStageId() == WORKFLOW_STAGE_ID_EDITING ||
408 $this->
getSubmission()->getStageId() == WORKFLOW_STAGE_ID_PRODUCTION) {
411 $notificationMgr->updateNotification(
413 array(NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER, NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS),
415 ASSOC_TYPE_SUBMISSION,
422 return new JSONMessage(
true, $galleyForm->fetch($request));
428 function fetchRow($args, $request) {
429 $json = parent::fetchRow($args, $request);
431 $galley = $row->getData();
432 if ($galley->getRemoteUrl()==
'' && !$galley->getFileId()) {
433 $json->setEvent(
'uploadFile', $galley->getId());
450 return $this->
getPublication()->getData(
'status') !== STATUS_PUBLISHED &&
452 WORKFLOW_STAGE_ID_PRODUCTION,
453 WORKFLOW_TYPE_EDITORIAL,