Plugin de integração GLPI <-> Redmine: - Config nativa (Twig) com API key cifrada (GLPIKey) - Vínculo projeto GLPI <-> projeto Redmine (aba do projeto) + categoria por vínculo - 1 issue Redmine por chamado; defaults (tracker/priority/activity) e mapa de status - Tempo das TicketTasks -> time entries (gate em "Feito"), idempotente - Autores via impersonation (X-Redmine-Switch-User) + auto-membership por role - Mapeamento de usuários GLPI->Redmine (auto-match por e-mail + overrides) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
54 lines
2 KiB
PHP
54 lines
2 KiB
PHP
<?php
|
|
include ("../../../inc/includes.php");
|
|
|
|
Session::checkRight("config", UPDATE);
|
|
|
|
$config = new PluginRedmineConfig();
|
|
global $DB;
|
|
|
|
if (isset($_POST["update"]) || isset($_POST["sync"])) {
|
|
// Save whatever was typed (URL/key/defaults) before anything else.
|
|
$config->update($_POST);
|
|
|
|
if (isset($_POST["sync"])) {
|
|
$metadata = PluginRedmineRedmineapi::syncMetadata();
|
|
if ($metadata !== false) {
|
|
$DB->update('glpi_plugin_redmine_configs', [
|
|
'metadata_cache' => json_encode($metadata)
|
|
], ['id' => 1]);
|
|
PluginRedmineRedmineapi::syncUsers(); // refresh Redmine user cache
|
|
Session::addMessageAfterRedirect(__('Metadados sincronizados com sucesso!', 'redmine'));
|
|
} else {
|
|
Session::addMessageAfterRedirect(__('Erro ao sincronizar com o Redmine. Verifique URL e chave.', 'redmine'), false, ERROR);
|
|
}
|
|
}
|
|
|
|
Html::back();
|
|
}
|
|
|
|
// Add a manual user mapping override (GLPI user -> Redmine user).
|
|
if (isset($_POST["add_usermap"])) {
|
|
$uid = (int) ($_POST['override_users_id'] ?? 0);
|
|
$rid = (int) ($_POST['override_redmine_user_id'] ?? 0);
|
|
if ($uid > 0 && $rid > 0) {
|
|
$DB->delete('glpi_plugin_redmine_usermap', ['users_id' => $uid]); // replace existing
|
|
$DB->insert('glpi_plugin_redmine_usermap', ['users_id' => $uid, 'redmine_user_id' => $rid]);
|
|
Session::addMessageAfterRedirect(__('Mapeamento adicionado.', 'redmine'));
|
|
} else {
|
|
Session::addMessageAfterRedirect(__('Selecione um usuário GLPI e um usuário Redmine.', 'redmine'), false, ERROR);
|
|
}
|
|
Html::back();
|
|
}
|
|
|
|
// Remove a manual user mapping override.
|
|
if (isset($_POST["del_usermap"])) {
|
|
$DB->delete('glpi_plugin_redmine_usermap', ['id' => (int) $_POST['del_usermap']]);
|
|
Session::addMessageAfterRedirect(__('Mapeamento removido.', 'redmine'));
|
|
Html::back();
|
|
}
|
|
|
|
Html::header('Redmine Config', $_SERVER['PHP_SELF'], "config", "plugins");
|
|
|
|
$config->showForm(1);
|
|
|
|
Html::footer();
|