/**
  * Add the comment.
  */
 function execute()
 {
     // Personalized execute() method since now there are possibly two comments contained within each form submission.
     $commentDao =& DAORegistry::getDAO('ArticleCommentDAO');
     $this->insertedComments = array();
     // Assign all common information
     $comment = new ArticleComment();
     $comment->setCommentType($this->commentType);
     $comment->setRoleId($this->roleId);
     $comment->setArticleId($this->article->getId());
     $comment->setAssocId($this->assocId);
     $comment->setAuthorId($this->user->getId());
     $comment->setCommentTitle($this->getData('commentTitle'));
     $comment->setDatePosted(Core::getCurrentDate());
     // If comments "For authors and editor" submitted
     if ($this->getData('authorComments') != null) {
         $comment->setComments($this->getData('authorComments'));
         $comment->setViewable(1);
         array_push($this->insertedComments, $commentDao->insertArticleComment($comment));
     }
     // If comments "For editor" submitted
     if ($this->getData('comments') != null) {
         $comment->setComments($this->getData('comments'));
         $comment->setViewable(null);
         array_push($this->insertedComments, $commentDao->insertArticleComment($comment));
     }
 }
 /**
  * Email editor decision comment.
  * @param $sectionEditorSubmission object
  * @param $send boolean
  * @param $request object
  */
 function emailEditorDecisionComment($sectionEditorSubmission, $send, $request)
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $articleCommentDao =& DAORegistry::getDAO('ArticleCommentDAO');
     $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
     $journal =& $request->getJournal();
     $user =& $request->getUser();
     import('classes.mail.ArticleMailTemplate');
     $decisionTemplateMap = array(SUBMISSION_EDITOR_DECISION_ACCEPT => 'EDITOR_DECISION_ACCEPT', SUBMISSION_EDITOR_DECISION_PENDING_REVISIONS => 'EDITOR_DECISION_REVISIONS', SUBMISSION_EDITOR_DECISION_RESUBMIT => 'EDITOR_DECISION_RESUBMIT', SUBMISSION_EDITOR_DECISION_DECLINE => 'EDITOR_DECISION_DECLINE');
     $decisions = $sectionEditorSubmission->getDecisions();
     $decisions = array_pop($decisions);
     // Rounds
     $decision = array_pop($decisions);
     $decisionConst = $decision ? $decision['decision'] : null;
     $email = new ArticleMailTemplate($sectionEditorSubmission, isset($decisionTemplateMap[$decisionConst]) ? $decisionTemplateMap[$decisionConst] : null);
     $copyeditor = $sectionEditorSubmission->getUserBySignoffType('SIGNOFF_COPYEDITING_INITIAL');
     if ($send && !$email->hasErrors()) {
         HookRegistry::call('SectionEditorAction::emailEditorDecisionComment', array(&$sectionEditorSubmission, &$send, &$request));
         $email->send($request);
         if ($decisionConst == SUBMISSION_EDITOR_DECISION_DECLINE) {
             // If the most recent decision was a decline,
             // sending this email archives the submission.
             $sectionEditorSubmission->setStatus(STATUS_ARCHIVED);
             $sectionEditorSubmission->stampStatusModified();
             $sectionEditorSubmissionDao->updateSectionEditorSubmission($sectionEditorSubmission);
         }
         $articleComment = new ArticleComment();
         $articleComment->setCommentType(COMMENT_TYPE_EDITOR_DECISION);
         $articleComment->setRoleId(Validation::isEditor() ? ROLE_ID_EDITOR : ROLE_ID_SECTION_EDITOR);
         $articleComment->setArticleId($sectionEditorSubmission->getId());
         $articleComment->setAuthorId($sectionEditorSubmission->getUserId());
         $articleComment->setCommentTitle($email->getSubject());
         $articleComment->setComments($email->getBody());
         $articleComment->setDatePosted(Core::getCurrentDate());
         $articleComment->setViewable(true);
         $articleComment->setAssocId($sectionEditorSubmission->getId());
         $articleCommentDao->insertArticleComment($articleComment);
         return true;
     } else {
         if (!$request->getUserVar('continued')) {
             $authorUser =& $userDao->getUser($sectionEditorSubmission->getUserId());
             $authorEmail = $authorUser->getEmail();
             $email->assignParams(array('editorialContactSignature' => $user->getContactSignature(), 'authorName' => $authorUser->getFullName(), 'journalTitle' => $journal->getLocalizedTitle()));
             $email->addRecipient($authorEmail, $authorUser->getFullName());
             if ($journal->getSetting('notifyAllAuthorsOnDecision')) {
                 foreach ($sectionEditorSubmission->getAuthors() as $author) {
                     if ($author->getEmail() != $authorEmail) {
                         $email->addCc($author->getEmail(), $author->getFullName());
                     }
                 }
             }
         } elseif ($request->getUserVar('importPeerReviews')) {
             $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
             $reviewAssignments =& $reviewAssignmentDao->getBySubmissionId($sectionEditorSubmission->getId(), $sectionEditorSubmission->getCurrentRound());
             $reviewIndexes =& $reviewAssignmentDao->getReviewIndexesForRound($sectionEditorSubmission->getId(), $sectionEditorSubmission->getCurrentRound());
             $body = '';
             foreach ($reviewAssignments as $reviewAssignment) {
                 // If the reviewer has completed the assignment, then import the review.
                 if ($reviewAssignment->getDateCompleted() != null && !$reviewAssignment->getCancelled()) {
                     // Get the comments associated with this review assignment
                     $articleComments =& $articleCommentDao->getArticleComments($sectionEditorSubmission->getId(), COMMENT_TYPE_PEER_REVIEW, $reviewAssignment->getId());
                     if ($articleComments) {
                         $body .= "------------------------------------------------------\n";
                         $body .= __('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => String::enumerateAlphabetically($reviewIndexes[$reviewAssignment->getReviewId()]))) . "\n";
                         if (is_array($articleComments)) {
                             foreach ($articleComments as $comment) {
                                 // If the comment is viewable by the author, then add the comment.
                                 if ($comment->getViewable()) {
                                     $body .= String::html2text($comment->getComments()) . "\n\n";
                                 }
                             }
                         }
                         $body .= "------------------------------------------------------\n\n";
                     }
                     if ($reviewFormId = $reviewAssignment->getReviewFormId()) {
                         $reviewId = $reviewAssignment->getId();
                         $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
                         $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
                         $reviewFormElements =& $reviewFormElementDao->getReviewFormElements($reviewFormId);
                         if (!$articleComments) {
                             $body .= "------------------------------------------------------\n";
                             $body .= __('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => String::enumerateAlphabetically($reviewIndexes[$reviewAssignment->getReviewId()]))) . "\n\n";
                         }
                         foreach ($reviewFormElements as $reviewFormElement) {
                             if ($reviewFormElement->getIncluded()) {
                                 $body .= String::html2text($reviewFormElement->getLocalizedQuestion()) . ": \n";
                                 $reviewFormResponse = $reviewFormResponseDao->getReviewFormResponse($reviewId, $reviewFormElement->getId());
                                 if ($reviewFormResponse) {
                                     $possibleResponses = $reviewFormElement->getLocalizedPossibleResponses();
                                     if (in_array($reviewFormElement->getElementType(), $reviewFormElement->getMultipleResponsesElementTypes())) {
                                         if ($reviewFormElement->getElementType() == REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES) {
                                             foreach ($reviewFormResponse->getValue() as $value) {
                                                 $body .= "\t" . String::html2text($possibleResponses[$value - 1]['content']) . "\n";
                                             }
                                         } else {
                                             $body .= "\t" . String::html2text($possibleResponses[$reviewFormResponse->getValue() - 1]['content']) . "\n";
                                         }
                                         $body .= "\n";
                                     } else {
                                         $body .= "\t" . $reviewFormResponse->getValue() . "\n\n";
                                     }
                                 }
                             }
                         }
                         $body .= "------------------------------------------------------\n\n";
                     }
                 }
             }
             $oldBody = $email->getBody();
             if (!empty($oldBody)) {
                 $oldBody .= "\n";
             }
             $email->setBody($oldBody . $body);
         }
         $email->displayEditForm($request->url(null, null, 'emailEditorDecisionComment', 'send'), array('articleId' => $sectionEditorSubmission->getId()), 'submission/comment/editorDecisionEmail.tpl', array('isAnEditor' => true));
         return false;
     }
 }
Exemple #3
0
 /**
  * Add the comment.
  */
 function execute()
 {
     $commentDao =& DAORegistry::getDAO('ArticleCommentDAO');
     $article = $this->article;
     // Insert new comment
     $comment = new ArticleComment();
     $comment->setCommentType($this->commentType);
     $comment->setRoleId($this->roleId);
     $comment->setArticleId($article->getId());
     $comment->setAssocId($this->assocId);
     $comment->setAuthorId($this->user->getId());
     $comment->setCommentTitle($this->getData('commentTitle'));
     $comment->setComments($this->getData('comments'));
     $comment->setDatePosted(Core::getCurrentDate());
     $comment->setViewable($this->getData('viewable'));
     $this->commentId = $commentDao->insertArticleComment($comment);
 }
 /**
  * Email editor decision comment.
  * @param $authorSubmission object
  * @param $send boolean
  * @param $request object
  */
 function emailEditorDecisionComment($authorSubmission, $send, $request)
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $journal =& $request->getJournal();
     $user =& $request->getUser();
     import('classes.mail.ArticleMailTemplate');
     $email = new ArticleMailTemplate($authorSubmission);
     $editAssignments = $authorSubmission->getEditAssignments();
     $editors = array();
     foreach ($editAssignments as $editAssignment) {
         array_push($editors, $userDao->getUser($editAssignment->getEditorId()));
     }
     if ($send && !$email->hasErrors()) {
         HookRegistry::call('AuthorAction::emailEditorDecisionComment', array(&$authorSubmission, &$email));
         $email->send($request);
         $articleCommentDao =& DAORegistry::getDAO('ArticleCommentDAO');
         $articleComment = new ArticleComment();
         $articleComment->setCommentType(COMMENT_TYPE_EDITOR_DECISION);
         $articleComment->setRoleId(ROLE_ID_AUTHOR);
         $articleComment->setArticleId($authorSubmission->getId());
         $articleComment->setAuthorId($authorSubmission->getUserId());
         $articleComment->setCommentTitle($email->getSubject());
         $articleComment->setComments($email->getBody());
         $articleComment->setDatePosted(Core::getCurrentDate());
         $articleComment->setViewable(true);
         $articleComment->setAssocId($authorSubmission->getId());
         $articleCommentDao->insertArticleComment($articleComment);
         return true;
     } else {
         if (!$request->getUserVar('continued')) {
             $email->setSubject($authorSubmission->getLocalizedTitle());
             if (!empty($editors)) {
                 foreach ($editors as $editor) {
                     $email->addRecipient($editor->getEmail(), $editor->getFullName());
                 }
             } else {
                 $email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName'));
             }
         }
         $email->displayEditForm(Request::url(null, null, 'emailEditorDecisionComment', 'send'), array('articleId' => $authorSubmission->getId()), 'submission/comment/editorDecisionEmail.tpl');
         return false;
     }
 }
    function importArticles()
    {
        assert($this->xml->name == 'articles');
        $articleDAO =& DAORegistry::getDAO('ArticleDAO');
        $articles = $articleDAO->getArticlesByJournalId($this->journal->getId());
        $journalFileManager = new JournalFileManager($this->journal);
        $publicFileManager =& new PublicFileManager();
        $this->nextElement();
        while ($this->xml->name == 'article') {
            $articleXML = $this->getCurrentElementAsDom();
            $article = new Article();
            $article->setJournalId($this->journal->getId());
            $article->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $articleXML->userId));
            $article->setSectionId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_SECTION, (int) $articleXML->sectionId));
            $article->setLocale((string) $articleXML->locale);
            $article->setLanguage((string) $articleXML->language);
            $article->setCommentsToEditor((string) $articleXML->commentsToEditor);
            $article->setCitations((string) $articleXML->citations);
            $article->setDateSubmitted((string) $articleXML->dateSubmitted);
            $article->setDateStatusModified((string) $articleXML->dateStatusModified);
            $article->setLastModified((string) $articleXML->lastModified);
            $article->setStatus((int) $articleXML->status);
            $article->setSubmissionProgress((int) $articleXML->submissionProgress);
            $article->setCurrentRound((int) $articleXML->currentRound);
            $article->setPages((string) $articleXML->pages);
            $article->setFastTracked((int) $articleXML->fastTracked);
            $article->setHideAuthor((int) $articleXML->hideAuthor);
            $article->setCommentsStatus((int) $articleXML->commentsStatus);
            $articleDAO->insertArticle($article);
            $oldArticleId = (int) $articleXML->oldId;
            $this->restoreDataObjectSettings($articleDAO, $articleXML->settings, 'article_settings', 'article_id', $article->getId());
            $article =& $articleDAO->getArticle($article->getId());
            // Reload article with restored settings
            $covers = $article->getFileName(null);
            if ($covers) {
                foreach ($covers as $locale => $oldCoverFileName) {
                    $sourceFile = $this->publicFolderPath . '/' . $oldCoverFileName;
                    $extension = $publicFileManager->getExtension($oldCoverFileName);
                    $destFile = 'cover_issue_' . $article->getId() . "_{$locale}.{$extension}";
                    $publicFileManager->copyJournalFile($this->journal->getId(), $sourceFile, $destFile);
                    unlink($sourceFile);
                    $article->setFileName($destFile, $locale);
                    $articleDAO->updateArticle($article);
                }
            }
            $articleFileManager = new ArticleFileManager($article->getId());
            $authorDAO =& DAORegistry::getDAO('AuthorDAO');
            foreach ($articleXML->author as $authorXML) {
                $author = new Author();
                $author->setArticleId($article->getId());
                $author->setFirstName((string) $authorXML->firstName);
                $author->setMiddleName((string) $authorXML->middleName);
                $author->setLastName((string) $authorXML->lastName);
                $author->setSuffix((string) $authorXML->suffix);
                $author->setCountry((string) $authorXML->country);
                $author->setEmail((string) $authorXML->email);
                $author->setUrl((string) $authorXML->url);
                $author->setUserGroupId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_GROUP, (int) $authorXML->userGroupId));
                $author->setPrimaryContact((int) $authorXML->primaryContact);
                $author->setSequence((int) $authorXML->sequence);
                $authorDAO->insertAuthor($author);
                $this->restoreDataObjectSettings($authorDAO, $authorXML->settings, 'author_settings', 'author_id', $author->getId());
                unset($author);
            }
            $articleEmailLogDAO =& DAORegistry::getDAO('ArticleEmailLogDAO');
            $emailLogsXML = array();
            foreach ($articleXML->emailLogs->emailLog as $emailLogXML) {
                array_unshift($emailLogsXML, $emailLogXML);
            }
            foreach ($emailLogsXML as $emailLogXML) {
                $emailLog = new ArticleEmailLogEntry();
                $emailLog->setAssocType(ASSOC_TYPE_ARTICLE);
                $emailLog->setAssocId($article->getId());
                $emailLog->setSenderId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $emailLogXML->senderId));
                $emailLog->setDateSent((string) $emailLogXML->dateSent);
                $emailLog->setIPAddress((string) $emailLogXML->IPAddress);
                $emailLog->setEventType((int) $emailLogXML->eventType);
                $emailLog->setFrom((string) $emailLogXML->from);
                $emailLog->setRecipients((string) $emailLogXML->recipients);
                $emailLog->setCcs((string) $emailLogXML->ccs);
                $emailLog->setBccs((string) $emailLogXML->bccs);
                $emailLog->setSubject((string) $emailLogXML->subject);
                $emailLog->setBody((string) $emailLogXML->body);
                $articleEmailLogDAO->insertObject($emailLog);
                $this->idTranslationTable->register(INTERNAL_TRANSFER_OBJECT_ARTICLE_EMAIL_LOG, (int) $emailLogXML->oldId, $emailLog->getId());
            }
            $articleFileDAO =& DAORegistry::getDAO('ArticleFileDAO');
            foreach ($articleXML->articleFile as $articleFileXML) {
                try {
                    $articleFile = new ArticleFile();
                    $articleFile->setArticleId($article->getId());
                    $articleFile->setSourceFileId((int) $articleFileXML->sourceFileId);
                    $articleFile->setSourceRevision((int) $articleFileXML->sourceRevision);
                    $articleFile->setRevision((int) $articleFileXML->revision);
                    $articleFile->setFileName((string) $articleFileXML->fileName);
                    $articleFile->setFileType((string) $articleFileXML->fileType);
                    $articleFile->setFileSize((string) $articleFileXML->fileSize);
                    $articleFile->setOriginalFileName((string) $articleFileXML->originalFileName);
                    $articleFile->setFileStage((int) $articleFileXML->fileStage);
                    $articleFile->setAssocId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_EMAIL_LOG, (int) $articleFileXML->assocId));
                    $articleFile->setDateUploaded((string) $articleFileXML->dateUploaded);
                    $articleFile->setDateModified((string) $articleFileXML->dateModified);
                    $articleFile->setRound((int) $articleFileXML->round);
                    $articleFile->setViewable((int) $articleFileXML->viewable);
                    $articleFileDAO->insertArticleFile($articleFile);
                    $oldArticleFileId = (int) $articleFileXML->oldId;
                    $oldFileName = $articleFile->getFileName();
                    $stagePath = $articleFileManager->fileStageToPath($articleFile->getFileStage());
                    $fileInTransferPackage = $this->journalFolderPath . "/articles/{$oldArticleId}/{$stagePath}/{$oldFileName}";
                    $newFileName = $articleFileManager->generateFilename($articleFile, $articleFile->getFileStage(), $articleFile->getOriginalFileName());
                    $newFilePath = "/articles/" . $article->getId() . "/{$stagePath}/{$newFileName}";
                    $journalFileManager->copyFile($fileInTransferPackage, $journalFileManager->filesDir . $newFilePath);
                    unlink($fileInTransferPackage);
                    $articleFileDAO->updateArticleFile($articleFile);
                    $this->idTranslationTable->register(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, $oldArticleFileId, $articleFile->getFileId());
                } catch (Exception $e) {
                }
            }
            $articleFiles = $articleFileDAO->getArticleFilesByArticle($article->getId());
            foreach ($articleFiles as $articleFile) {
                try {
                    $articleFile->setSourceFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, $articleFile->getSourceFileId()));
                    $articleFileDAO->updateArticleFile($articleFile);
                } catch (Exception $e) {
                }
            }
            $suppFileDAO =& DAORegistry::getDAO('SuppFileDAO');
            foreach ($articleXML->suppFile as $suppFileXML) {
                $suppFile =& new SuppFile();
                $suppFile->setArticleId($article->getId());
                $suppFile->setRemoteURL((string) $suppFileXML->remoteURL);
                $suppFile->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $suppFileXML->fileId));
                $suppFile->setType((string) $suppFileXML->type);
                $suppFile->setDateCreated((string) $suppFileXML->dateCreated);
                $suppFile->setLanguage((string) $suppFileXML->language);
                $suppFile->setShowReviewers((int) $suppFileXML->showReviewers);
                $suppFile->setDateSubmitted((string) $suppFileXML->dateSubmitted);
                $suppFile->setSequence((int) $suppFileXML->sequence);
                $suppFileDAO->insertSuppFile($suppFile);
                $this->restoreDataObjectSettings($suppFileDAO, $suppFileXML->settings, 'article_supp_file_settings', 'supp_id', $suppFile->getId());
            }
            $articleCommentDAO =& DAORegistry::getDAO('ArticleCommentDAO');
            foreach ($articleXML->articleComment as $articleCommentXML) {
                $articleComment = new ArticleComment();
                $articleComment->setArticleId($article->getId());
                $articleComment->setAssocId($article->getId());
                $articleComment->setCommentType((int) $articleCommentXML->commentType);
                $articleComment->setRoleId((int) $articleCommentXML->roleId);
                $articleComment->setAuthorId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $articleCommentXML->authorId));
                $articleComment->setCommentTitle((string) $articleCommentXML->commentTitle);
                $articleComment->setComments((string) $articleCommentXML->comments);
                $articleComment->setDatePosted((string) $articleCommentXML->datePosted);
                $articleComment->setDateModified((string) $articleCommentXML->dateModified);
                $articleComment->setViewable((int) $articleCommentXML->viewable);
                $articleCommentDAO->insertArticleComment($articleComment);
            }
            $articleGalleyDAO =& DAORegistry::getDAO('ArticleGalleyDAO');
            foreach ($articleXML->articleGalley as $articleGalleyXML) {
                $articleGalley = null;
                if ($articleGalleyXML->htmlGalley == "1") {
                    $articleGalley = new ArticleHTMLGalley();
                } else {
                    $articleGalley = new ArticleGalley();
                }
                $articleGalley->setArticleId($article->getId());
                $articleGalley->setLocale((string) $articleGalleyXML->locale);
                $articleGalley->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleGalleyXML->fileId));
                $articleGalley->setLabel((string) $articleGalleyXML->label);
                $articleGalley->setSequence((int) $articleGalleyXML->sequence);
                $articleGalley->setRemoteURL((string) $articleGalleyXML->remoteURL);
                if ($articleGalley instanceof ArticleHTMLGalley) {
                    $articleGalley->setStyleFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleGalleyXML->styleFileId));
                }
                $articleGalleyDAO->insertGalley($articleGalley);
                if ($articleGalley instanceof ArticleHTMLGalley) {
                    foreach ($articleGalleyXML->htmlGalleyImage as $articleGalleyImageXML) {
                        $imageId = $this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleGalleyImageXML);
                        $articleGalleyDAO->insertGalleyImage($articleGalley->getId(), $imageId);
                    }
                }
                $this->restoreDataObjectSettings($articleGalleyDAO, $articleGalleyXML->settings, 'article_galley_settings', 'galley_id', $articleGalley->getId());
            }
            $noteDAO =& DAORegistry::getDAO('NoteDAO');
            foreach ($articleXML->articleNote as $articleNoteXML) {
                $articleNote = new Note();
                $articleNote->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $articleNoteXML->userId));
                $articleNote->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleNoteXML->fileId));
                $articleNote->setAssocType(ASSOC_TYPE_ARTICLE);
                $articleNote->setAssocId($article->getId());
                $articleNote->setDateCreated((string) $articleNoteXML->dateCreated);
                $articleNote->setDateModified((string) $articleNoteXML->dateModified);
                $articleNote->setContents((string) $articleNoteXML->contents);
                $articleNote->setTitle((string) $articleNoteXML->title);
                $noteDAO->insertObject($articleNote);
            }
            $editAssignmentDAO =& DAORegistry::getDAO('EditAssignmentDAO');
            foreach ($articleXML->editAssignment as $editAssignmentXML) {
                $editAssignment = new EditAssignment();
                $editAssignment->setArticleId($article->getId());
                $editAssignment->setEditorId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $editAssignmentXML->editorId));
                $editAssignment->setCanReview((int) $editAssignmentXML->canReview);
                $editAssignment->setCanEdit((int) $editAssignmentXML->canEdit);
                $editAssignment->setDateUnderway((string) $editAssignmentXML->dateUnderway);
                $editAssignment->setDateNotified((string) $editAssignmentXML->dateNotified);
                $editAssignmentDAO->insertEditAssignment($editAssignment);
            }
            $reviewAssignmentDAO =& DAORegistry::getDAO('ReviewAssignmentDAO');
            $reviewFormResponseDAO =& DAORegistry::getDAO('ReviewFormResponseDAO');
            foreach ($articleXML->reviewAssignment as $reviewAssignmentXML) {
                $reviewAssignment = new ReviewAssignment();
                $reviewAssignment->setSubmissionId($article->getId());
                $reviewAssignment->setReviewerId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $reviewAssignmentXML->reviewerId));
                try {
                    $reviewAssignment->setReviewerFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $reviewAssignmentXML->reviewerFileId));
                } catch (Exception $e) {
                    $this->logger->log("Arquivo do artigo {$oldArticleId} não encontrado. ID: " . (int) $reviewAssignmentXML->reviewerFileId . "\n");
                }
                $reviewAssignment->setReviewFormId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_REVIEW_FORM, (int) $reviewAssignmentXML->reviewFormId));
                $reviewAssignment->setReviewRoundId((int) $reviewAssignmentXML->reviewRoundId);
                $reviewAssignment->setStageId((int) $reviewAssignmentXML->stageId);
                $reviewAssignment->setReviewerFullName((string) $reviewAssignmentXML->reviewerFullName);
                $reviewAssignment->setCompetingInterests((string) $reviewAssignmentXML->competingInterests);
                $reviewAssignment->setRegretMessage((string) $reviewAssignmentXML->regretMessage);
                $reviewAssignment->setRecommendation((string) $reviewAssignmentXML->recommendation);
                $reviewAssignment->setDateAssigned((string) $reviewAssignmentXML->dateAssigned);
                $reviewAssignment->setDateNotified((string) $reviewAssignmentXML->dateNotified);
                $reviewAssignment->setDateConfirmed((string) $reviewAssignmentXML->dateConfirmed);
                $reviewAssignment->setDateCompleted((string) $reviewAssignmentXML->dateCompleted);
                $reviewAssignment->setDateAcknowledged((string) $reviewAssignmentXML->dateAcknowledged);
                $reviewAssignment->setDateDue((string) $reviewAssignmentXML->dateDue);
                $reviewAssignment->setDateResponseDue((string) $reviewAssignmentXML->dateResponseDue);
                $reviewAssignment->setLastModified((string) $reviewAssignmentXML->lastModified);
                $reviewAssignment->setDeclined((int) $reviewAssignmentXML->declined);
                $reviewAssignment->setReplaced((int) $reviewAssignmentXML->replaced);
                $reviewAssignment->setCancelled((int) $reviewAssignmentXML->cancelled);
                $reviewAssignment->setQuality((int) $reviewAssignmentXML->quality);
                $reviewAssignment->setDateRated((string) $reviewAssignmentXML->dateRated);
                $reviewAssignment->setDateReminded((string) $reviewAssignmentXML->dateReminded);
                $reviewAssignment->setReminderWasAutomatic((int) $reviewAssignmentXML->reminderWasAutomatic);
                $reviewAssignment->setRound((int) $reviewAssignmentXML->round);
                $reviewAssignment->setReviewRevision((int) $reviewAssignmentXML->reviewRevision);
                $reviewAssignment->setReviewMethod((int) $reviewAssignmentXML->reviewMethod);
                $reviewAssignment->setUnconsidered((int) $reviewAssignmentXML->unconsidered);
                $reviewAssignmentDAO->insertObject($reviewAssignment);
                foreach ($reviewAssignmentXML->formResponses->formResponse as $formResponseXML) {
                    $reviewFormResponseDAO->update('INSERT INTO review_form_responses
							(review_form_element_id, review_id, response_type, response_value)
							VALUES
							(?, ?, ?, ?)', array($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_REVIEW_FORM_ELEMENT, (int) $formResponseXML->reviewFormElementId), $reviewAssignment->getId(), (string) $formResponseXML->responseType, (string) $formResponseXML->responseValue));
                }
            }
            $signoffDAO =& DAORegistry::getDAO('SignoffDAO');
            foreach ($articleXML->signoff as $signoffXML) {
                $signoff = new Signoff();
                $signoff->setAssocType(ASSOC_TYPE_ARTICLE);
                $signoff->setAssocId($article->getId());
                $signoff->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $signoffXML->userId));
                $signoff->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $signoffXML->fileId));
                $signoff->setUserGroupId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_GROUP, (int) $signoffXML->userGroupId));
                $signoff->setSymbolic((string) $signoffXML->symbolic);
                $signoff->setFileRevision((int) $signoffXML->fileRevision);
                $signoff->setDateUnderway((string) $signoffXML->dateUnderway);
                $signoff->setDateNotified((string) $signoffXML->dateNotified);
                $signoff->setDateCompleted((string) $signoffXML->dateCompleted);
                $signoff->setDateAcknowledged((string) $signoffXML->dateAcknowledged);
                $signoffDAO->insertObject($signoff);
            }
            $editorSubmissionDAO =& DAORegistry::getDAO('EditorSubmissionDAO');
            foreach ($articleXML->editDecisions as $editDecisionXML) {
                $editDecisions =& $editorSubmissionDAO->update('INSERT INTO edit_decisions (article_id, round, editor_id, decision, date_decided) values (?, ?, ?, ?, ?)', array($article->getId(), (string) $editDecisionXML->round, $this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $editDecisionXML->editorId), (string) $editDecisionXML->decision, (string) $editDecisionXML->dateDecided));
            }
            $publishedArticleDAO =& DAORegistry::getDAO('PublishedArticleDAO');
            if (isset($articleXML->publishedArticle)) {
                $publishedArticleXML = $articleXML->publishedArticle;
                $publishedArticle = new PublishedArticle();
                $publishedArticle->setId($article->getId());
                $publishedArticle->setIssueId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ISSUE, (int) $publishedArticleXML->issueId));
                $publishedArticle->setDatePublished((string) $publishedArticleXML->datePublished);
                $publishedArticle->setSeq((int) $publishedArticleXML->seq);
                $publishedArticle->setAccessStatus((int) $publishedArticleXML->accessStatus);
                $publishedArticleDAO->insertPublishedArticle($publishedArticle);
            }
            $articleEventLogDAO =& DAORegistry::getDAO('ArticleEventLogDAO');
            $eventLogsXML =& iterator_to_array($articleXML->eventLogs->eventLog);
            $eventLogsXML = array();
            foreach ($articleXML->eventLogs->eventLog as $eventLogXML) {
                array_unshift($eventLogsXML, $eventLogXML);
            }
            foreach ($eventLogsXML as $eventLogXML) {
                $eventLog = new ArticleEventLogEntry();
                $eventLog->setAssocType(ASSOC_TYPE_ARTICLE);
                $eventLog->setAssocId($article->getId());
                $eventLog->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $eventLogXML->userId));
                $eventLog->setDateLogged((string) $eventLogXML->dateLogged);
                $eventLog->setIPAddress((string) $eventLogXML->IPAddress);
                $eventLog->setEventType((int) $eventLogXML->eventType);
                $eventLog->setMessage((string) $eventLogXML->message);
                $eventLog->setIsTranslated((int) $eventLogXML->isTranslated);
                $articleEventLogDAO->insertObject($eventLog);
                $this->restoreDataObjectSettings($articleEventLogDAO, $eventLogXML->settings, 'event_log_settings', 'log_id', $eventLog->getId());
            }
            try {
                $article->setSubmissionFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->submissionFileId));
            } catch (Exception $e) {
            }
            try {
                $article->setRevisedFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->revisedFileId));
            } catch (Exception $e) {
            }
            try {
                $article->setReviewFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->reviewFileId));
            } catch (Exception $e) {
            }
            try {
                $article->setEditorFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->editorFileId));
            } catch (Exception $e) {
            }
            $articleDAO->updateArticle($article);
            $this->nextElement();
        }
    }
 /**
  * Creates and returns an article comment object from a row
  * @param $row array
  * @return ArticleComment object
  */
 function &_returnArticleCommentFromRow($row)
 {
     $articleComment = new ArticleComment();
     $articleComment->setId($row['comment_id']);
     $articleComment->setCommentType($row['comment_type']);
     $articleComment->setRoleId($row['role_id']);
     $articleComment->setArticleId($row['article_id']);
     $articleComment->setAssocId($row['assoc_id']);
     $articleComment->setAuthorId($row['author_id']);
     $articleComment->setCommentTitle($row['comment_title']);
     $articleComment->setComments($row['comments']);
     $articleComment->setDatePosted($this->datetimeFromDB($row['date_posted']));
     $articleComment->setDateModified($this->datetimeFromDB($row['date_modified']));
     $articleComment->setViewable($row['viewable']);
     HookRegistry::call('ArticleCommentDAO::_returnArticleCommentFromRow', array(&$articleComment, &$row));
     return $articleComment;
 }
 /**
  * Email editor decision comment
  * @param $sectionEditorSubmission object
  * @param $send boolean
  */
 function emailEditorDecisionComment($sectionEditorSubmission, $send)
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $articleCommentDao =& DAORegistry::getDAO('ArticleCommentDAO');
     $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     import('classes.mail.ArticleMailTemplate');
     $decisionTemplateMap = array(SUBMISSION_SECTION_DECISION_APPROVED => 'SECTION_DECISION_APPROVED', SUBMISSION_SECTION_DECISION_RESUBMIT => 'SECTION_DECISION_RESUBMIT', SUBMISSION_SECTION_DECISION_INCOMPLETE => 'SECTION_DECISION_INCOMPLETE', SUBMISSION_SECTION_DECISION_DECLINED => 'SECTION_DECISION_DECLINE', SUBMISSION_SECTION_DECISION_EXEMPTED => 'SECTION_DECISION_EXEMPT');
     $decision = $sectionEditorSubmission->getLastSectionDecision();
     if ($decision->getDecision() == SUBMISSION_SECTION_DECISION_APPROVED && $decision->getReviewType() == REVIEW_TYPE_FR) {
         $email = new ArticleMailTemplate($sectionEditorSubmission, null, 'SECTION_DECISION_FR_APPROVED');
     } elseif ($decision->getDecision() == SUBMISSION_SECTION_DECISION_EXEMPTED && $decision->getComments() == null) {
         return true;
     } else {
         $email = new ArticleMailTemplate($sectionEditorSubmission, null, isset($decisionTemplateMap[$decision->getDecision()]) ? $decisionTemplateMap[$decision->getDecision()] : null);
     }
     $copyeditor = $sectionEditorSubmission->getUserBySignoffType('SIGNOFF_COPYEDITING_INITIAL');
     if ($send && !$email->hasErrors()) {
         HookRegistry::call('SectionEditorAction::emailEditorDecisionComment', array(&$sectionEditorSubmission, &$send));
         $email->send();
         $articleComment = new ArticleComment();
         $articleComment->setCommentType(COMMENT_TYPE_SECTION_DECISION);
         $articleComment->setRoleId(Validation::isEditor() ? ROLE_ID_EDITOR : ROLE_ID_SECTION_EDITOR);
         $articleComment->setArticleId($sectionEditorSubmission->getArticleId());
         $articleComment->setAuthorId($user->getUserId());
         $articleComment->setCommentTitle($email->getSubject());
         $articleComment->setComments($email->getBody());
         $articleComment->setDatePosted(Core::getCurrentDate());
         $articleComment->setViewable(true);
         $articleComment->setAssocId($sectionEditorSubmission->getArticleId());
         $articleCommentDao->insertArticleComment($articleComment);
         return true;
     } else {
         if (!Request::getUserVar('continued')) {
             $authorUser =& $userDao->getUser($sectionEditorSubmission->getUserId());
             $authorEmail = $authorUser->getEmail();
             $email->assignParams(array('editorialContactSignature' => $user->getContactSignature(), 'authorName' => $authorUser->getFullName(), 'urlOngoing' => Request::url(null, 'author', 'index', 'ongoingResearches'), 'urlDrafts' => Request::url(null, 'author', 'index', 'proposalsToSubmit'), 'url' => Request::url(null, 'author', 'submissionReview', $sectionEditorSubmission->getArticleId()), 'reviewType' => Locale::translate($decision->getReviewTypeKey()), 'journalTitle' => $journal->getLocalizedTitle()));
             $email->addRecipient($authorEmail, $authorUser->getFullName());
             if ($journal->getSetting('notifyAllAuthorsOnDecision')) {
                 foreach ($sectionEditorSubmission->getAuthors() as $author) {
                     if ($author->getEmail() != $authorEmail) {
                         $email->addCc($author->getEmail(), $author->getFullName());
                     }
                 }
             }
             import('classes.file.TemporaryFileManager');
             $temporaryFileManager = new TemporaryFileManager();
             $decisionFiles =& $decision->getDecisionFiles();
             foreach ($decisionFiles as $file) {
                 if ($file) {
                     $temporaryFile = $temporaryFileManager->articleToTemporaryFile($file, $user->getId());
                     $email->addPersistAttachment($temporaryFile);
                 }
             }
         } elseif (Request::getUserVar('importPeerReviews')) {
             $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
             $reviewAssignments =& $reviewAssignmentDao->getByDecisionId($sectionEditorSubmission->getLastSectionDecisionId());
             $reviewIndexes =& $reviewAssignmentDao->getReviewIndexesForDecision($sectionEditorSubmission->getLastSectionDecisionId());
             $body = '';
             foreach ($reviewAssignments as $reviewAssignment) {
                 // If the reviewer has completed the assignment, then import the review.
                 if ($reviewAssignment->getDateCompleted() != null && !$reviewAssignment->getCancelled()) {
                     // Get the comments associated with this review assignment
                     $articleComments =& $articleCommentDao->getArticleComments($sectionEditorSubmission->getArticleId(), COMMENT_TYPE_PEER_REVIEW, $reviewAssignment->getId());
                     if ($articleComments) {
                         $body .= "------------------------------------------------------\n";
                         $body .= Locale::translate('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => chr(ord('A') + $reviewIndexes[$reviewAssignment->getId()]))) . "\n";
                         if (is_array($articleComments)) {
                             foreach ($articleComments as $comment) {
                                 // If the comment is viewable by the author, then add the comment.
                                 if ($comment->getViewable()) {
                                     $body .= String::html2text($comment->getComments()) . "\n\n";
                                 }
                             }
                         }
                         $body .= "------------------------------------------------------\n\n";
                     }
                     if ($reviewFormId = $reviewAssignment->getReviewFormId()) {
                         $reviewId = $reviewAssignment->getId();
                         $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
                         $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
                         $reviewFormElements =& $reviewFormElementDao->getReviewFormElements($reviewFormId);
                         if (!$articleComments) {
                             $body .= "------------------------------------------------------\n";
                             $body .= Locale::translate('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => chr(ord('A') + $reviewIndexes[$reviewAssignment->getId()]))) . "\n\n";
                         }
                         foreach ($reviewFormElements as $reviewFormElement) {
                             if ($reviewFormElement->getIncluded()) {
                                 $body .= String::html2text($reviewFormElement->getLocalizedQuestion()) . ": \n";
                                 $reviewFormResponse = $reviewFormResponseDao->getReviewFormResponse($reviewId, $reviewFormElement->getId());
                                 if ($reviewFormResponse) {
                                     $possibleResponses = $reviewFormElement->getLocalizedPossibleResponses();
                                     if (in_array($reviewFormElement->getElementType(), $reviewFormElement->getMultipleResponsesElementTypes())) {
                                         if ($reviewFormElement->getElementType() == REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES) {
                                             foreach ($reviewFormResponse->getValue() as $value) {
                                                 $body .= "\t" . String::html2text($possibleResponses[$value - 1]['content']) . "\n";
                                             }
                                         } else {
                                             $body .= "\t" . String::html2text($possibleResponses[$reviewFormResponse->getValue() - 1]['content']) . "\n";
                                         }
                                         $body .= "\n";
                                     } else {
                                         $body .= "\t" . String::html2text($reviewFormResponse->getValue()) . "\n\n";
                                     }
                                 }
                             }
                         }
                         $body .= "------------------------------------------------------\n\n";
                     }
                 }
             }
             $oldBody = $email->getBody();
             if (!empty($oldBody)) {
                 $oldBody .= "\n";
             }
             $email->setBody($oldBody . $body);
         }
         $email->displayEditForm(Request::url(null, null, 'emailEditorDecisionComment', 'send'), array('articleId' => $sectionEditorSubmission->getArticleId()), 'submission/comment/editorDecisionEmail.tpl', array('isAnEditor' => true));
         return false;
     }
 }