You are not logged in.
Pages: 1
I am creating a plugin to integrate GLPI's tickets with azure devops work items. Every time a ticket is created or updated with some predefined users assigned to it, I want to send a http POST request to the azure RESTful API.
This is what I managed to do so far:
<?php
define('TEST_VERSION', '1.2.10');
function plugin_init_test()
{
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS['csrf_compliant']['test'] = true;
$PLUGIN_HOOKS['item_add']['test'] = ['Ticket' => 'sendTicketInfo'];
$PLUGIN_HOOKS['item_update']['test'] = ['Ticket' => 'sendTicketInfo'];
}
function plugin_version_test()
{
return [
'name' => 'Plugin name that will be displayed',
'version' => TEST_VERSION,
'author' => 'John Doe and <a href="http://foobar.com">Foo Bar</a>',
'license' => 'GLPv3',
'homepage' => 'http://test.com',
'requirements' => [
'glpi' => [
'min' => '9.1'
]
]
];
}
function plugin_test_install()
{
return true;
}
function plugin_test_uninstall()
{
return true;
}
function sendTicketInfo($ticket)
{
$webhookUrl = 'http://localhost:8081';
$payload = $ticket->getDefaultValues();
$ch = curl_init($webhookUrl);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload, JSON_UNESCAPED_UNICODE));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
}
My problem is that the hook item_update doesn't fire when I change the ticket's assigned users. Is there any way I can solve this problem?
Offline
A better solution may be using the add and purge hooks for the individual actor link classes "Ticket_User", "Group_Ticket" and "Supplier_Ticket". That way, even if changing a ticket's requesters, watchers, or assigned technicians, you will still be able to know when they change.
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Pages: 1