From 7aae6e1fc54a1c256f29dcc3f46cd7547311d195 Mon Sep 17 00:00:00 2001 From: Thiago Brasil Date: Mon, 25 Nov 2024 15:29:23 -0400 Subject: [PATCH 1/2] Updates contribution biography in Thoth when updated in OMP Issue: documentacao-e-tarefas/desenvolvimento_e_infra#918 Signed-off-by: Thiago Brasil --- classes/components/forms/RegisterForm.inc.php | 1 + .../services/ThothContributionService.inc.php | 16 ++++++++++++---- lib/thothAPI/ThothClient.inc.php | 5 +++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/classes/components/forms/RegisterForm.inc.php b/classes/components/forms/RegisterForm.inc.php index 2bee78b..6a3aaa0 100644 --- a/classes/components/forms/RegisterForm.inc.php +++ b/classes/components/forms/RegisterForm.inc.php @@ -1,4 +1,5 @@ setId($params['contributionId'] ?? null); + $contribution->setWorkId($params['workId'] ?? null); + $contribution->setContributorId($params['contributorId'] ?? null); $contribution->setContributionType($params['contributionType']); $contribution->setMainContribution($params['mainContribution']); $contribution->setContributionOrdinal($params['contributionOrdinal']); @@ -48,7 +51,7 @@ public function getDataByAuthor($author) $data['firstName'] = $author->getLocalizedGivenName(); $data['lastName'] = $author->getLocalizedData('familyName'); $data['fullName'] = $author->getFullName(false); - $data['biography'] = $author->getLocalizedBiography(); + $data['biography'] = strip_tags($author->getLocalizedBiography()); return $data; } @@ -99,8 +102,13 @@ public function updateContributions($thothClient, $thothContributions, $publicat foreach ($authors as $author) { $publicationContribution = $this->getDataByAuthor($author); - if (!$this->contributionInList($publicationContribution, $thothContributions)) { + if (!$thothContribution = $this->contributionInList($publicationContribution, $thothContributions)) { $this->register($thothClient, $author, $thothWorkId); + continue; + } + if ($thothContribution['biography'] !== $publicationContribution['biography']) { + $thothContribution['biography'] = $publicationContribution['biography']; + $thothClient->updateContribution($this->new($thothContribution)); } } } @@ -112,10 +120,10 @@ private function contributionInList($targetContribution, $contributions) $contribution['firstName'] === $targetContribution['firstName'] && $contribution['lastName'] === $targetContribution['lastName'] ) { - return true; + return $contribution; } } - return false; + return null; } private function isMainContribution($author) diff --git a/lib/thothAPI/ThothClient.inc.php b/lib/thothAPI/ThothClient.inc.php index 4e17c53..8f64fc7 100644 --- a/lib/thothAPI/ThothClient.inc.php +++ b/lib/thothAPI/ThothClient.inc.php @@ -129,6 +129,11 @@ public function updatePublication($publication) return $this->mutation('updatePublication', $publication); } + public function updateContribution($contribution) + { + return $this->mutation('updateContribution', $contribution); + } + public function deleteWork($workId) { $data = ['workId' => $workId]; From 4c6bf288d9cc258eacb825b130eff262b6c4bb32 Mon Sep 17 00:00:00 2001 From: Thiago Brasil Date: Mon, 25 Nov 2024 15:30:05 -0400 Subject: [PATCH 2/2] Update version.xml Issue: documentacao-e-tarefas/desenvolvimento_e_infra#918 Signed-off-by: Thiago Brasil --- version.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.xml b/version.xml index 5877024..39ed39a 100644 --- a/version.xml +++ b/version.xml @@ -3,8 +3,8 @@ thoth plugins.generic - 0.1.3.2 - 2024-10-25 + 0.1.3.3 + 2024-11-25 1 ThothPlugin