16 import(
'lib.pkp.classes.plugins.PKPPubIdPlugin');
26 $context = $router->getContext(
$request);
29 switch (
$request->getUserVar(
'verb')) {
33 $suffixGenerationStrategy = $this->
getSetting($context->getId(), $suffixFieldName);
34 if ($suffixGenerationStrategy !=
'customId') {
40 $issues = $issueDao->getPublishedIssues($context->getId());
41 while ($issue = $issues->next()) {
42 $issuePubId = $issue->getStoredPubId($this->
getPubIdType());
43 if (empty($issuePubId)) {
44 $issuePubId = $this->
getPubId($issue);
45 $issueDao->changePubId($issue->getId(), $this->getPubIdType(), $issuePubId);
49 if ($submissionEnabled || $representationEnabled) {
53 'contextId' => $context->getId(),
54 'status' => STATUS_PUBLISHED,
57 foreach ($submissions as $submission) {
58 $publications = $submission->getData(
'publications');
59 if ($submissionEnabled) {
60 foreach ($publications as $publication) {
61 $publicationPubId = $publication->getStoredPubId($this->
getPubIdType());
62 if (empty($publicationPubId)) {
63 $publicationPubId = $this->
getPubId($publication);
64 $publicationDao->changePubId($publication->getId(), $this->getPubIdType(), $publicationPubId);
68 if ($representationEnabled) {
69 foreach ($publications as $publication) {
70 $representations = $representationDao->getByPublicationId($publication->getId(), $context->getId());
71 while ($representation = $representations->next()) {
72 $representationPubId = $representation->getStoredPubId($this->
getPubIdType());
73 if (empty($representationPubId)) {
74 $representationPubId = $this->
getPubId($representation);
75 $representationDao->changePubId($representation->getId(), $this->getPubIdType(), $representationPubId);
85 return parent::manage($args,
$request);
96 $pubObjectTypes = parent::getPubObjectTypes();
97 array_push($pubObjectTypes,
'Issue');
98 return $pubObjectTypes;
107 if ($type ===
'Issue') {
108 $excludeTypeId = $type === $pubObjectType ? $excludeId :
null;
109 if ($issueDao->pubIdExists($type, $pubId, $excludeTypeId, $contextId)) {
115 return parent::checkDuplicate($pubId, $pubObjectType, $excludeId, $contextId);
126 $storedPubId = $pubObject->getStoredPubId($pubIdType);
127 if ($storedPubId)
return $storedPubId;
133 $issue = ($pubObjectType ==
'Issue' ? $pubObject :
null);
134 $submission = ($pubObjectType ==
'Submission' ? $pubObject :
null);
135 $representation = ($pubObjectType ==
'Representation' ? $pubObject :
null);
136 $submissionFile = ($pubObjectType ==
'SubmissionFile' ? $pubObject :
null);
139 if ($pubObjectType ===
'Issue') {
140 $contextId = $pubObject->getJournalId();
141 } elseif ($pubObjectType ===
'Representation') {
142 $publication =
Services::get(
'publication')->get($pubObject->getData(
'publicationId'));
143 $submission =
Services::get(
'submission')->get($publication->getData(
'submissionId'));
144 $contextId = $submission->getData(
'contextId');
145 } elseif (in_array($pubObjectType, [
'Publication',
'SubmissionFile'])) {
146 $submission =
Services::get(
'submission')->get($pubObject->getData(
'submissionId'));
147 $contextId = $submission->getData(
'contextId');
152 if (!$context)
return null;
153 $contextId = $context->getId();
157 if (!$objectTypeEnabled)
return null;
160 if (!is_a($pubObject,
'Issue')) {
161 assert(!is_null($submission));
163 $issue = $issueDao->getBySubmissionId($submission->getId(), $contextId);
165 if ($issue && $contextId != $issue->getJournalId())
return null;
169 if (empty($pubIdPrefix))
return null;
173 $suffixGenerationStrategy = $this->
getSetting($contextId, $suffixFieldName);
174 switch ($suffixGenerationStrategy) {
176 $pubIdSuffix = $pubObject->getData($suffixFieldName);
181 $pubIdSuffix = $this->
getSetting($contextId, $suffixPatternsFieldNames[$pubObjectType]);
187 if ($pubObject->getStoredPubId(
'publisher-id')) {
204 if ($submission->getPages()) {
209 if ($representation) {
214 if ($submissionFile) {
225 $pubIdSuffix .=
'.v' . $issue->getVolume() .
'i' . $issue->getNumber();
227 $pubIdSuffix .=
'.v%vi%i';
231 $pubIdSuffix .=
'.' . $submission->getId();
234 if ($representation) {
235 $pubIdSuffix .=
'.g' . $representation->getId();
238 if ($submissionFile) {
239 $pubIdSuffix .=
'.f' . $submissionFile->getFileId();
242 if (empty($pubIdSuffix))
return null;
245 $pubId = $this->
constructPubId($pubIdPrefix, $pubIdSuffix, $contextId);
258 $submissionPubIdEnabled = $this->
isObjectTypeEnabled(
'Submission', $issue->getJournalId());
259 $representationPubIdEnabled = $this->
isObjectTypeEnabled(
'Representation', $issue->getJournalId());
261 if (!$submissionPubIdEnabled && !$representationPubIdEnabled && !$filePubIdEnabled)
return false;
264 import(
'lib.pkp.classes.submission.SubmissionFile');
267 'contextId' => $issue->getJournalId(),
268 'issueIds' => $issue->getId(),
272 foreach ($submissionIds as $submissionId) {
273 $submission =
Services::get(
'submission')->get($submissionId);
274 if ($submissionPubIdEnabled) {
275 foreach ((array) $submission->getData(
'publications') as $publication) {
276 $publicationDao->deletePubId($publication->getId(), $pubIdType);
279 if ($representationPubIdEnabled || $filePubIdEnabled) {
280 foreach ((array) $submission->getData(
'publications') as $publication) {
282 while ($representation = $representations->next()) {
283 if ($representationPubIdEnabled) {
286 if ($filePubIdEnabled) {
287 $articleProofFiles = $submissionFileDao->getAllRevisionsByAssocId(ASSOC_TYPE_REPRESENTATION, $representation->getId(), SUBMISSION_FILE_PROOF);
288 foreach ($articleProofFiles as $articleProofFile) {
289 $submissionFileDao->deletePubId($articleProofFile->getFileId(), $pubIdType);
293 unset($representations);