Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
CatalogEntryTabHandler.inc.php
1 <?php
2 
16 // Import the base Handler.
17 import('lib.pkp.controllers.tab.publicationEntry.PublicationEntryTabHandler');
18 
24  parent::PublicationEntryTabHandler();
25  $this->addRoleAssignment(
26  array(ROLE_ID_SUB_EDITOR, ROLE_ID_MANAGER),
27  array(
28  'catalogMetadata',
29  'publicationMetadata',
30  'uploadCoverImage',
31  )
32  );
33  }
34 
35 
36  //
37  // Public handler methods
38  //
39 
46  function catalogMetadata($args, $request) {
47  import('controllers.tab.catalogEntry.form.CatalogEntryCatalogMetadataForm');
48 
49  $submission = $this->getSubmission();
50  $stageId = $this->getStageId();
51  $user = $request->getUser();
52 
53  $catalogEntryCatalogMetadataForm = new CatalogEntryCatalogMetadataForm($submission->getId(), $user->getId(), $stageId, array('displayedInContainer' => true));
54 
55  $catalogEntryCatalogMetadataForm->initData($args, $request);
56  $json = new JSONMessage(true, $catalogEntryCatalogMetadataForm->fetch($request));
57  return $json->getString();
58  }
59 
66  function publicationMetadata($args, $request) {
67 
68  $publicationFormatId = (int) $request->getUserVar('publicationFormatId');
69  $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
70 
71  $submission = $this->getSubmission();
72  $stageId = $this->getStageId();
73 
74  $publicationFormat = $publicationFormatDao->getById($publicationFormatId, $submission->getId());
75 
76  if (!$publicationFormat) {
77  $json = new JSONMessage(false, __('monograph.publicationFormat.formatDoesNotExist'));
78  return $json->getString();
79  }
80 
81  import('controllers.tab.catalogEntry.form.CatalogEntryFormatMetadataForm');
82  $catalogEntryPublicationMetadataForm = new CatalogEntryFormatMetadataForm($submission->getId(), $publicationFormatId, $publicationFormat->getPhysicalFormat(), $stageId, array('displayedInContainer' => true, 'tabPos' => $this->getTabPosition()));
83  $catalogEntryPublicationMetadataForm->initData($args, $request);
84  $json = new JSONMessage(true, $catalogEntryPublicationMetadataForm->fetch($request));
85  return $json->getString();
86  }
87 
94  function uploadCoverImage($args, $request) {
95  $user = $request->getUser();
96 
97  import('lib.pkp.classes.file.TemporaryFileManager');
98  $temporaryFileManager = new TemporaryFileManager();
99  $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
100  if ($temporaryFile) {
101  $json = new JSONMessage(true);
102  $json->setAdditionalAttributes(array(
103  'temporaryFileId' => $temporaryFile->getId()
104  ));
105  } else {
106  $json = new JSONMessage(false, __('common.uploadFailed'));
107  }
108 
109  return $json->getString();
110  }
111 
115  function _getFormFromCurrentTab(&$form, &$notificationKey, $request) {
116  parent::_getFormFromCurrentTab($form, $notificationKey, $request); // give PKP-lib a chance to set the form and key.
117 
118  if (!$form) { // nothing applicable in parent.
119  $submission = $this->getSubmission();
120  switch ($this->getCurrentTab()) {
121  case 'catalog':
122  import('controllers.tab.catalogEntry.form.CatalogEntryCatalogMetadataForm');
123  $user = $request->getUser();
124  $form = new CatalogEntryCatalogMetadataForm($submission->getId(), $user->getId(), $this->getStageId(), array('displayedInContainer' => true, 'tabPos' => $this->getTabPosition()));
125  $notificationKey = 'notification.savedCatalogMetadata';
126  SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_CATALOG_METADATA_UPDATE, 'submission.event.catalogMetadataUpdated');
127  break;
128  default: // publication format tabs
129  import('controllers.tab.catalogEntry.form.CatalogEntryFormatMetadataForm');
130  $publicationFormatId = $request->getUserVar('publicationFormatId');
131 
132  // perform some validation to make sure this format is enabled and assigned to this monograph
133  $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO');
134  $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
135  $publishedMonograph = $publishedMonographDao->getById($submission->getId());
136  $formats = $publicationFormatDao->getBySubmissionId($submission->getId());
137  $form = null;
138  while ($format = $formats->next()) {
139  if ($format->getId() == $publicationFormatId) {
140  $form = new CatalogEntryFormatMetadataForm($submission->getId(), $publicationFormatId, $format->getId(), $this->getStageId(), array('displayedInContainer' => true, 'tabPos' => $this->getTabPosition()));
141  $notificationKey = 'notification.savedPublicationFormatMetadata';
142  SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_PUBLICATION_FORMAT_METADATA_UPDATE, 'submission.event.publicationMetadataUpdated', array('formatName' => $format->getLocalizedName()));
143  break;
144  }
145  }
146  break;
147  }
148  }
149  }
150 
157  $submission = $this->getSubmission();
158  import('controllers.modals.submissionMetadata.form.CatalogEntrySubmissionReviewForm');
159  return new CatalogEntrySubmissionReviewForm($submission->getId(), $this->getStageId(), array('displayedInContainer' => true));
160  }
161 
166  function _getHandlerClassPath() {
167  return 'modals.submissionMetadata.CatalogEntryHandler';
168  }
169 }
170 
171 ?>
static & getDAO($name, $dbconn=null)
Handle AJAX operations for tabs on the New Catalog Entry management page.
Displays a submission&#39;s metadata view.
addRoleAssignment($roleIds, $operations)
Class to represent a JSON (Javascript Object Notation) message.
Parent class for forms used by the various publication formats.
_getFormFromCurrentTab(&$form, &$notificationKey, $request)
static logEvent($request, $submission, $eventType, $messageKey, $params=array())
Base handler for AJAX operations for tabs on the Publication Entry management pages.