Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
CatalogEntrySubmissionReviewForm.inc.php
1 <?php
2 
16 import('lib.pkp.classes.form.Form');
17 
18 // Use this class to handle the submission metadata.
19 import('controllers.modals.submissionMetadata.form.SubmissionMetadataViewForm');
20 
22 
29  function CatalogEntrySubmissionReviewForm($monographId, $stageId = null, $formParams = null) {
30  parent::SubmissionMetadataViewForm($monographId, $stageId, $formParams, 'controllers/modals/submissionMetadata/form/catalogEntrySubmissionReviewForm.tpl');
31  AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON, LOCALE_COMPONENT_APP_SUBMISSION);
32  if (array_key_exists('expeditedSubmission', $formParams)) {
33  // If we are expediting, make the confirmation checkbox mandatory.
34  $request = Application::getRequest();
35  $context = $request->getContext();
36  $this->addCheck(new FormValidator($this, 'confirm', 'required', 'submission.catalogEntry.confirm.required'));
37  $this->addCheck(new FormValidatorRegExp($this, 'price', 'optional', 'grid.catalogEntry.validPriceRequired', '/^(([1-9]\d{0,2}(,\d{3})*|[1-9]\d*|0|)(.\d{2})?|([1-9]\d{0,2}(,\d{3})*|[1-9]\d*|0|)(.\d{2})?)$/'));
38  }
39  }
40 
44  function readInputData() {
45  parent::readInputData();
46 
47  // Read in the additional confirmation checkbox
48  $this->readUserVars(array('confirm'));
49  }
50 
54  function fetch($request) {
55 
56  $templateMgr = TemplateManager::getManager($request);
57 
58  // Make this available for expedited submissions.
59  $salesTypes = array(
60  'openAccess' => 'payment.directSales.openAccess',
61  'directSales' => 'payment.directSales.directSales',
62  'notAvailable' => 'payment.directSales.notAvailable',
63  );
64 
65  $templateMgr->assign('salesTypes', $salesTypes);
66  return parent::fetch($request);
67  }
68 
72  function execute($request) {
73  parent::execute($request);
74 
75  $monograph = $this->getSubmission();
76  $monographDao = DAORegistry::getDAO('MonographDAO');
77  $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO');
78  $publishedMonograph = $publishedMonographDao->getById($monograph->getId(), null, false);
79  $isExistingEntry = $publishedMonograph?true:false;
80 
81  import('classes.publicationFormat.PublicationFormatTombstoneManager');
82  $publicationFormatTombstoneMgr = new PublicationFormatTombstoneManager();
83  $press = $request->getPress();
84  $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
85  $publicationFormatFactory = $publicationFormatDao->getBySubmissionId($monograph->getId());
86  $publicationFormats = $publicationFormatFactory->toAssociativeArray();
87  $notificationMgr = new NotificationManager();
88 
89  if ($this->getData('confirm')) {
90  // Update the monograph status.
91  $monograph->setStatus(STATUS_PUBLISHED);
92  $monographDao->updateObject($monograph);
93 
94  if (!$isExistingEntry) {
95  unset($publishedMonograph);
96  $publishedMonograph = $publishedMonographDao->newDataObject();
97  $publishedMonograph->setId($monograph->getId());
98  $publishedMonographDao->insertObject($publishedMonograph);
99  }
100  $publishedMonograph->setDatePublished(Core::getCurrentDate());
101  $publishedMonographDao->updateObject($publishedMonograph);
102 
103  $notificationMgr->updateNotification(
104  $request,
105  array(NOTIFICATION_TYPE_APPROVE_SUBMISSION),
106  null,
107  ASSOC_TYPE_MONOGRAPH,
108  $publishedMonograph->getId()
109  );
110 
111  // Remove publication format tombstones.
112  $publicationFormatTombstoneMgr->deleteTombstonesByPublicationFormats($publicationFormats);
113 
114  // Update the search index for this published monograph.
115  import('classes.search.MonographSearchIndex');
117 
118  // Log the publication event.
119  import('lib.pkp.classes.log.SubmissionLog');
120  SubmissionLog::logEvent($request, $monograph, SUBMISSION_LOG_METADATA_PUBLISH, 'submission.event.metadataPublished');
121  } else {
122  if ($isExistingEntry) {
123  // Update the monograph status.
124  $monograph->setStatus(STATUS_QUEUED);
125 
126  // Unpublish monograph.
127  $publishedMonograph->setDatePublished(null);
128  $publishedMonographDao->updateObject($publishedMonograph);
129 
130  $notificationMgr->updateNotification(
131  $request,
132  array(NOTIFICATION_TYPE_APPROVE_SUBMISSION),
133  null,
134  ASSOC_TYPE_MONOGRAPH,
135  $publishedMonograph->getId()
136  );
137 
138  // Create tombstones for each publication format.
139  $publicationFormatTombstoneMgr->insertTombstonesByPublicationFormats($publicationFormats, $press);
140 
141  // Log the unpublication event.
142  import('lib.pkp.classes.log.SubmissionLog');
143  SubmissionLog::logEvent($request, $monograph, SUBMISSION_LOG_METADATA_UNPUBLISH, 'submission.event.metadataUnpublished');
144  }
145 
146  // regular submission without publish in catalog.
147  $monographDao->updateObject($monograph);
148  }
149  }
150 }
151 
152 ?>
static & getDAO($name, $dbconn=null)
addCheck($formValidator)
Definition: Form.inc.php:396
CatalogEntrySubmissionReviewForm($monographId, $stageId=null, $formParams=null)
Displays a submission&#39;s metadata view.
static requireComponents()
readUserVars($vars)
Definition: Form.inc.php:364
getData($key)
Definition: Form.inc.php:210
Class defining basic operations for publication format tombstones.
Form validation check using a regular expression.
static logEvent($request, $submission, $eventType, $messageKey, $params=array())
Class to represent a form validation check.
Displays a submission&#39;s metadata view.
static getCurrentDate($ts=null)
Definition: Core.inc.php:95