Skip to content

Commit

Permalink
Fixes discussions import/export
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagolepidus committed Apr 24, 2024
1 parent 87a54ac commit 577d7ce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions filter/export/ExtendedArticleNativeXmlFilter.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,19 @@ public function addQueries($doc, $parentNode, $submission, $stageId)
$queryDAO = DAORegistry::getDAO('QueryDAO');

$queries = $queryDAO->getByAssoc(ASSOC_TYPE_SUBMISSION, $submission->getId(), $stageId);

$queriesNode = $doc->createElementNS($deployment->getNamespace(), 'queries');
while ($query = $queries->next()) {
$participantIds = $queryDAO->getParticipantIds($query->getId());

if (empty($participantIds)) {
continue;
}

$queryNode = $doc->createElementNS($deployment->getNamespace(), 'query');
$queryNode->setAttribute('seq', $query->getData('sequence'));
$queryNode->setAttribute('closed', (int) $query->getData('closed'));

$queryNode->appendChild($this->createQueryParticipantsNode($doc, $deployment, $query));
$queryNode->appendChild($this->createQueryParticipantsNode($doc, $deployment, $participantIds));
$queryNode->appendChild($this->createQueryRepliesNode($doc, $deployment, $submission, $query));

$queriesNode->appendChild($queryNode);
Expand All @@ -135,12 +140,10 @@ public function addQueries($doc, $parentNode, $submission, $stageId)
}
}

private function createQueryParticipantsNode($doc, $deployment, $query)
private function createQueryParticipantsNode($doc, $deployment, $participantIds)
{
$queryDAO = DAORegistry::getDAO('QueryDAO');
$userDAO = DAORegistry::getDAO('UserDAO');
$participantsNode = $doc->createElementNS($deployment->getNamespace(), 'participants');
$participantIds = $queryDAO->getParticipantIds($query->getId());

foreach ($participantIds as $participantId) {
$participant = $userDAO->getById($participantId);
Expand All @@ -162,6 +165,9 @@ private function createQueryRepliesNode($doc, $deployment, $submission, $query)

while ($note = $replies->next()) {
$user = $note->getUser();
if (!$user) {
continue;
}
$noteNode = $doc->createElementNS($deployment->getNamespace(), 'note');
$noteNode->setAttribute('user_email', htmlspecialchars($user->getEmail(), ENT_COMPAT, 'UTF-8'));
$noteNode->setAttribute('date_modified', $note->getDateModified());
Expand Down
4 changes: 2 additions & 2 deletions filter/import/NativeXmlExtendedArticleFilter.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ public function parseQuery($node, $submission, $stageId)

$deployment->setNote($note);
$noteFilesNodes = $noteNode->getElementsByTagNameNS($deployment->getNamespace(), 'workflow_file');
for ($i = 0; $i < $noteFilesNodes->count(); $i++) {
$noteNode = $noteFilesNodes->item($i);
for ($fileIndex = 0; $fileIndex < $noteFilesNodes->count(); $fileIndex++) {
$noteNode = $noteFilesNodes->item($fileIndex);
$this->parseArticleFile($noteNode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion fullJournal.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
<element name="replies">
<complexType>
<sequence>
<element ref="pkp:note" minOccurs="1" maxOccurs="unbounded" />
<element ref="pkp:note" minOccurs="0" maxOccurs="unbounded" />
</sequence>
</complexType>
</element>
Expand Down

0 comments on commit 577d7ce

Please sign in to comment.