IssueEntryPublicationMetadataForm::execute PHP Method

execute() public method

Save the metadata and store the catalog data for this published monograph.
public execute ( $request )
    function execute($request)
    {
        parent::execute($request);
        $submission = $this->getSubmission();
        $context = $request->getContext();
        $waivePublicationFee = $request->getUserVar('waivePublicationFee') ? true : false;
        if ($waivePublicationFee) {
            $markAsPaid = $request->getUserVar('markAsPaid');
            import('classes.payment.ojs.OJSPaymentManager');
            $paymentManager = new OJSPaymentManager($request);
            $user = $request->getUser();
            // Get a list of author user IDs
            $authorUserIds = array();
            $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
            $submitterAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($submission->getId(), ROLE_ID_AUTHOR);
            $submitterAssignment = $submitterAssignments->next();
            assert(isset($submitterAssignment));
            // At least one author should be assigned
            $queuedPayment =& $paymentManager->createQueuedPayment($context->getId(), PAYMENT_TYPE_PUBLICATION, $markAsPaid ? $submitterAssignment->getUserId() : $user->getId(), $submission->getId(), $markAsPaid ? $context->getSetting('publicationFee') : 0, $markAsPaid ? $context->getSetting('currency') : '');
            $paymentManager->queuePayment($queuedPayment);
            // Since this is a waiver, fulfill the payment immediately
            $paymentManager->fulfillQueuedPayment($request, $queuedPayment, $markAsPaid ? 'ManualPayment' : 'Waiver');
        } else {
            // Get the issue for publication.
            $issueDao = DAORegistry::getDAO('IssueDAO');
            $issueId = $this->getData('issueId');
            $issue = $issueDao->getById($issueId, $context->getId());
            $sectionDao = DAORegistry::getDAO('SectionDAO');
            $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
            $publishedArticle = $publishedArticleDao->getPublishedArticleByArticleId($submission->getId(), null, false);
            /* @var $publishedArticle PublishedArticle */
            if ($publishedArticle) {
                if (!$issue || !$issue->getPublished()) {
                    $fromIssue = $issueDao->getById($publishedArticle->getIssueId(), $context->getId());
                    if ($fromIssue->getPublished()) {
                        // Insert article tombstone
                        import('classes.article.ArticleTombstoneManager');
                        $articleTombstoneManager = new ArticleTombstoneManager();
                        $articleTombstoneManager->insertArticleTombstone($submission, $context);
                    }
                }
            }
            import('classes.search.ArticleSearchIndex');
            $articleSearchIndex = new ArticleSearchIndex();
            // define the access status for the article if none is set.
            $accessStatus = $this->getData('accessStatus') != '' ? $this->getData('accessStatus') : ARTICLE_ACCESS_ISSUE_DEFAULT;
            $articleDao = DAORegistry::getDAO('ArticleDAO');
            if (!is_null($this->getData('pages'))) {
                $submission->setPages($this->getData('pages'));
            }
            if ($issue) {
                // Schedule against an issue.
                if ($publishedArticle) {
                    $publishedArticle->setIssueId($issueId);
                    $publishedArticle->setSequence(REALLY_BIG_NUMBER);
                    $publishedArticle->setDatePublished($this->getData('datePublished'));
                    $publishedArticle->setAccessStatus($accessStatus);
                    $publishedArticleDao->updatePublishedArticle($publishedArticle);
                    // Re-index the published article metadata.
                    $articleSearchIndex->articleMetadataChanged($publishedArticle);
                } else {
                    $publishedArticle = $publishedArticleDao->newDataObject();
                    $publishedArticle->setId($submission->getId());
                    $publishedArticle->setIssueId($issueId);
                    $publishedArticle->setDatePublished(Core::getCurrentDate());
                    $publishedArticle->setSequence(REALLY_BIG_NUMBER);
                    $publishedArticle->setAccessStatus($accessStatus);
                    $publishedArticleDao->insertObject($publishedArticle);
                    // If we're using custom section ordering, and if this is the first
                    // article published in a section, make sure we enter a custom ordering
                    // for it. (Default at the end of the list.)
                    if ($sectionDao->customSectionOrderingExists($issueId)) {
                        if ($sectionDao->getCustomSectionOrder($issueId, $submission->getSectionId()) === null) {
                            $sectionDao->insertCustomSectionOrder($issueId, $submission->getSectionId(), REALLY_BIG_NUMBER);
                            $sectionDao->resequenceCustomSectionOrders($issueId);
                        }
                    }
                    // Index the published article metadata and files for the first time.
                    $articleSearchIndex->articleMetadataChanged($publishedArticle);
                    $articleSearchIndex->submissionFilesChanged($publishedArticle);
                }
            } else {
                if ($publishedArticle) {
                    // This was published elsewhere; make sure we don't
                    // mess up sequencing information.
                    $issueId = $publishedArticle->getIssueId();
                    $publishedArticleDao->deletePublishedArticleByArticleId($submission->getId());
                    // Delete the article from the search index.
                    $articleSearchIndex->submissionFileDeleted($submission->getId());
                }
            }
            if ($this->getData('attachPermissions')) {
                $submission->setCopyrightYear($this->getData('copyrightYear'));
                $submission->setCopyrightHolder($this->getData('copyrightHolder'), null);
                // Localized
                $submission->setLicenseURL($this->getData('licenseURL'));
            } else {
                $submission->setCopyrightYear(null);
                $submission->setCopyrightHolder(null, null);
                $submission->setLicenseURL(null);
            }
            // Resequence the articles.
            $publishedArticleDao->resequencePublishedArticles($submission->getSectionId(), $issueId);
            $submission->stampStatusModified();
            if ($issue && $issue->getPublished()) {
                $submission->setStatus(STATUS_PUBLISHED);
                // delete article tombstone
                $tombstoneDao = DAORegistry::getDAO('DataObjectTombstoneDAO');
                $tombstoneDao->deleteByDataObjectId($submission->getId());
            } else {
                $submission->setStatus(STATUS_QUEUED);
            }
            $articleDao->updateObject($submission);
            $articleSearchIndex->articleChangesFinished();
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Expedites a submission through the submission process, if the submitter is a manager or editor.
  * @param $args array
  * @param $request PKPRequest
  */
 function expedite($args, $request)
 {
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     import('controllers.tab.issueEntry.form.IssueEntryPublicationMetadataForm');
     $user = $request->getUser();
     $form = new IssueEntryPublicationMetadataForm($submission->getId(), $user, null, array('expeditedSubmission' => true));
     if ($submission && (int) $request->getUserVar('issueId') > 0) {
         // Process our submitted form in order to create the published article entry.
         $form->readInputData();
         if ($form->validate()) {
             $form->execute($request);
             // Create trivial notification in place on the form, and log the event.
             $notificationManager = new NotificationManager();
             $user = $request->getUser();
             import('lib.pkp.classes.log.SubmissionLog');
             SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_ISSUE_METADATA_UPDATE, 'submission.event.issueMetadataUpdated');
             $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.savedIssueMetadata')));
             // Now, create a galley for this submission.  Assume PDF, and set to 'available'.
             $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
             $articleGalley = $articleGalleyDao->newDataObject();
             $articleGalley->setGalleyType('pdfarticlegalleyplugin');
             $articleGalley->setIsAvailable(true);
             $articleGalley->setSubmissionId($submission->getId());
             $articleGalley->setLocale($submission->getLocale());
             $articleGalley->setLabel('PDF');
             $articleGalley->setSeq($articleGalleyDao->getNextGalleySequence($submission->getId()));
             $articleGalleyId = $articleGalleyDao->insertObject($articleGalley);
             // Next, create a galley PROOF file out of the submission file uploaded.
             $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
             $submissionFiles = $submissionFileDao->getLatestRevisions($submission->getId(), SUBMISSION_FILE_SUBMISSION);
             // Assume a single file was uploaded, but check for something that's PDF anyway.
             foreach ($submissionFiles as $submissionFile) {
                 // test both mime type and file extension in case the mime type isn't correct after uploading.
                 if ($submissionFile->getFileType() == 'application/pdf' || preg_match('/\\.pdf$/', $submissionFile->getOriginalFileName())) {
                     // Get the path of the current file because we change the file stage in a bit.
                     $currentFilePath = $submissionFile->getFilePath();
                     // this will be a new file based on the old one.
                     $submissionFile->setFileId(null);
                     $submissionFile->setRevision(1);
                     $submissionFile->setFileStage(SUBMISSION_FILE_PROOF);
                     $submissionFile->setAssocType(ASSOC_TYPE_GALLEY);
                     $submissionFile->setAssocId($articleGalleyId);
                     $submissionFileDao->insertObject($submissionFile, $currentFilePath);
                     break;
                 }
             }
             // no errors, clear all notifications for this submission which may have been created during the submission process and close the modal.
             $context = $request->getContext();
             $notificationDao = DAORegistry::getDAO('NotificationDAO');
             $notificationFactory = $notificationDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submission->getId(), null, null, $context->getId());
             return new JSONMessage(true);
         } else {
             return new JSONMessage(true, $form->fetch($request));
         }
     }
     return new JSONMessage(true, $form->fetch($request));
 }
All Usage Examples Of IssueEntryPublicationMetadataForm::execute