Skip to content

Commit

Permalink
Merge pull request #6 from lepidus/stable-3_3_0
Browse files Browse the repository at this point in the history
Feature/Add plugin events to activity log (OMP 3.3.0)
  • Loading branch information
thiagolepidus authored Oct 21, 2024
2 parents 8da6af9 + f4801db commit 4c7ac48
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This is required to use the API credentials provided, that are stored encrypted

## Installation

1. Download the latest version of the installation package (`thoth.tar.gz`) from the [Release page](https://github.com/lepidus/thoth-omp-plugin/releases).
1. Download the latest version of the installation package (`thoth.tar.gz`) from the [Release page](https://github.com/thoth-pub/thoth-omp-plugin/releases).

2. Access the administration area of your OMP website through the Dashboard. Navigate to `Settings` > `Website` > `Plugins` > `Upload a new plugin`, and select the `thoth.tar.gz` file.

Expand Down
15 changes: 13 additions & 2 deletions classes/ThothNotification.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,26 @@ public function __construct($plugin)
$this->plugin = $plugin;
}

public static function notify($request, $notificationType, $message)
public static function notify($request, $submission, $notificationType, $messageKey, $error = null)
{
$currentUser = $request->getUser();
$notificationMgr = new NotificationManager();
$notificationMgr->createTrivialNotification(
$currentUser->getId(),
$notificationType,
['contents' => $message]
['contents' => __($messageKey)]
);

import('lib.pkp.classes.log.SubmissionLog');
import('classes.log.SubmissionEventLogEntry');
SubmissionLog::logEvent(
$request,
$submission,
SUBMISSION_LOG_TYPE_DEFAULT,
$messageKey . '.log',
['reason' => $error]
);

return new JSONMessage(false);
}

Expand Down
7 changes: 5 additions & 2 deletions classes/ThothRegister.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,18 @@ public function registerWork($submission, $imprint)

ThothNotification::notify(
$request,
$submission,
NOTIFICATION_TYPE_SUCCESS,
__('plugins.generic.thoth.register.success')
'plugins.generic.thoth.register.success'
);
} catch (ThothException $e) {
error_log($e->getMessage());
ThothNotification::notify(
$request,
$submission,
NOTIFICATION_TYPE_ERROR,
__('plugins.generic.thoth.register.error')
'plugins.generic.thoth.register.error',
$e->getError()
);
}
}
Expand Down
7 changes: 5 additions & 2 deletions classes/ThothUpdater.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,18 @@ public function updateWork($hookName, $args)

ThothNotification::notify(
$request,
$submission,
NOTIFICATION_TYPE_SUCCESS,
__('plugins.generic.thoth.update.success')
'plugins.generic.thoth.update.success'
);
} catch (ThothException $e) {
error_log($e->getMessage());
ThothNotification::notify(
$request,
$submission,
NOTIFICATION_TYPE_ERROR,
__('plugins.generic.thoth.update.error')
'plugins.generic.thoth.update.error',
$e->getError()
);
}

Expand Down
12 changes: 3 additions & 9 deletions classes/services/ThothWorkService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ public function updateBook($thothClient, $thothWorkId, $submission, $publication
$thothClient,
$thothWorkData['relations'],
$publication,
$thothWorkId
$thothWorkId,
$thothWorkData['imprintId']
);
}

Expand Down Expand Up @@ -278,7 +279,7 @@ public function updateBook($thothClient, $thothWorkId, $submission, $publication
return $newThothWork;
}

public function updateRelations($thothClient, $thothRelations, $publication, $thothWorkId)
public function updateRelations($thothClient, $thothRelations, $publication, $thothWorkId, $thothImprintId)
{
$chapterDAO = DAORegistry::getDAO('ChapterDAO');
$chapters = $chapterDAO->getByPublicationId($publication->getId())->toArray();
Expand All @@ -301,13 +302,6 @@ public function updateRelations($thothClient, $thothRelations, $publication, $th
$submissionService = Services::get('submission');
$submission = $submissionService->get($publication->getData('submissionId'));

$pluginSettingsDAO = DAORegistry::getDAO('PluginSettingsDAO');
$thothImprintId = $pluginSettingsDAO->getSetting(
$submission->getData('contextId'),
'thothPlugin',
'imprintId'
);

foreach ($chapters as $chapter) {
$chapterTitle = $chapter->getLocalizedFullTitle();
if (!isset($thothRelationsData[$chapterTitle])) {
Expand Down
2 changes: 1 addition & 1 deletion docs/README-es.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Esto es necesario para utilizar las credenciales de la API proporcionadas, que s

## Instalación

1. Descarga la última versión del paquete de instalación (`thoth.tar.gz`) desde la [página de lanzamientos](https://github.com/lepidus/thoth-omp-plugin/releases).
1. Descarga la última versión del paquete de instalación (`thoth.tar.gz`) desde la [página de lanzamientos](https://github.com/thoth-pub/thoth-omp-plugin/releases).

2. Accede al área de administración de tu sitio OMP a través del Dashboard. Navega a `Configuración` > `Sitio web` > `Plugins` > `Subir un nuevo plugin` y selecciona el archivo `thoth.tar.gz`.

Expand Down
2 changes: 1 addition & 1 deletion docs/README-pt_BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Isso é necessário para usar as credenciais da API fornecidas, que são armazen

## Instalação

1. Baixe a versão mais recente do pacote de instalação (`thoth.tar.gz`) na [página de lançamentos](https://github.com/lepidus/thoth-omp-plugin/releases).
1. Baixe a versão mais recente do pacote de instalação (`thoth.tar.gz`) na [página de lançamentos](https://github.com/thoth-pub/thoth-omp-plugin/releases).

2. Acesse a área de administração do seu site OMP através do Dashboard. Navegue até `Configurações` > `Site` > `Plugins` > `Enviar um novo plugin` e selecione o arquivo `thoth.tar.gz`.

Expand Down
Binary file modified images/link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions lib/thothAPI/exceptions/ThothException.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@

class ThothException extends \RuntimeException
{
private $error;

public function __construct($error, $code)
{
$this->error = $error;
parent::__construct('Failed to send the request to Thoth: ' . $error, $code);
}

public function getError()
{
return $this->error;
}
}
12 changes: 12 additions & 0 deletions locale/en_US/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,33 @@ msgstr "Do you want to register in Thoth the metadata related to this submission
msgid "plugins.generic.thoth.register.success"
msgstr "Submission metadata successfully sent to Thoth."

msgid "plugins.generic.thoth.register.success.log"
msgstr "Submission metadata registered in Thoth."

msgid "plugins.generic.thoth.register.error"
msgstr ""
"There was a problem sending the submission metadata to Thoth. Please try again later, or "
"contact your system administrator."

msgid "plugins.generic.thoth.register.error.log"
msgstr "Error registering metadata in Thoth. Reason: {$reason}"

msgid "plugins.generic.thoth.update"
msgstr "Update Metadata"

msgid "plugins.generic.thoth.update.success"
msgstr "Metadata successfully updated in Thoth."

msgid "plugins.generic.thoth.update.success.log"
msgstr "Submission metadata updated in Thoth."

msgid "plugins.generic.thoth.update.error"
msgstr ""
"There was a problem updating metadata in Thoth. Please try again later, or "
"contact your system administrator."

msgid "plugins.generic.thoth.update.error.log"
msgstr "Error updating metadata in Thoth. Reason: {$reason}"

msgid "plugins.generic.thoth.api.403.alreadyRegistered"
msgstr "The submission is already registered in Thoth."
12 changes: 12 additions & 0 deletions locale/es_ES/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,33 @@ msgstr "¿Desea registrar en Thoth los metadatos relacionados con este envío?"
msgid "plugins.generic.thoth.register.success"
msgstr "Metadatos de envío enviados correctamente a Thoth."

msgid "plugins.generic.thoth.register.success.log"
msgstr "Metadatos de envío registrados en Thoth."

msgid "plugins.generic.thoth.register.error"
msgstr ""
"Se ha producido un problema al enviar los metadatos de envío a Thoth. "
"Vuelva a intentarlo más tarde o póngase en contacto con el administrador del sistema."

msgid "plugins.generic.thoth.register.error.log"
msgstr "Error al registrar metadatos en Thoth. Razón: {$reason}"

msgid "plugins.generic.thoth.update"
msgstr "Actualizar Metadatos"

msgid "plugins.generic.thoth.update.success"
msgstr "Metadatos actualizados correctamente en Thoth."

msgid "plugins.generic.thoth.update.success.log"
msgstr "Metadatos actualizados en Thoth."

msgid "plugins.generic.thoth.update.error"
msgstr ""
"Se ha producido un problema al actualizar los metadatos en Thoth "
"Vuelva a intentarlo más tarde o póngase en contacto con el administrador del sistema."

msgid "plugins.generic.thoth.update.error.log"
msgstr "Error al actualizar metadatos en Thoth. Razón: {$reason}"

msgid "plugins.generic.thoth.api.403.alreadyRegistered"
msgstr "El envío ya está registrado en Thoth."
12 changes: 12 additions & 0 deletions locale/pt_BR/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,33 @@ msgstr "Deseja realmente registrar na Thoth os metadados relacionados a essa sub
msgid "plugins.generic.thoth.register.success"
msgstr "Metadados da submissão enviados para Thoth com sucesso."

msgid "plugins.generic.thoth.register.success.log"
msgstr "Metadados da submissão registrados no Thoth."

msgid "plugins.generic.thoth.register.error"
msgstr ""
"Houve um problema ao enviar os metadados da submissão para Thoth. Por favor, tente mais "
"tarde, ou contate o administrador do sistema."

msgid "plugins.generic.thoth.register.error.log"
msgstr "Erro ao registrar metadados no Thoth. Motivo: {$reason}"

msgid "plugins.generic.thoth.update"
msgstr "Atualizar Metadados"

msgid "plugins.generic.thoth.update.success"
msgstr "Metadados atualizados com sucesso em Thoth."

msgid "plugins.generic.thoth.update.success.log"
msgstr "Metadados da submissão atualizados no Thoth."

msgid "plugins.generic.thoth.update.error"
msgstr ""
"Houve um problema ao atualizar os metadados em Thoth. Por favor, tente mais "
"tarde, ou contate o administrador do sistema."

msgid "plugins.generic.thoth.update.error.log"
msgstr "Erro ao atualizar metadados no Thoth. Motivo: {$reason}"

msgid "plugins.generic.thoth.api.403.alreadyRegistered"
msgstr "A submissão já foi registrada na Thoth."
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<version>
<application>thoth</application>
<type>plugins.generic</type>
<release>0.1.2.0</release>
<date>2024-10-18</date>
<release>0.1.3.0</release>
<date>2024-10-21</date>
<lazy-load>1</lazy-load>
<class>ThothPlugin</class>
</version>

0 comments on commit 4c7ac48

Please sign in to comment.