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]; 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