You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2024-04-24 17:03:40

scarletTornado
Member
Registered: 2024-04-12
Posts: 19

[SOLVED]Plugin development: associate plugin types to a ticket

I tried adding my plugin type to the 'ticket_types' array through the following code:

$CFG_GLPI["ticket_types"] += [
         PluginAssetlistAssetlist::class
]; 

Still, my class isn't showing in the item dropdown when creating a ticket.

Last edited by scarletTornado (2024-04-29 17:49:58)

Offline

#2 2024-04-24 19:40:53

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,430
Website

Re: [SOLVED]Plugin development: associate plugin types to a ticket

Did you add this type to the list of itemtypes allowed to be associated with tickets? There is a per-profile option for this on the Assistance tab of the profile form.


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

#3 2024-04-25 16:24:59

scarletTornado
Member
Registered: 2024-04-12
Posts: 19

Re: [SOLVED]Plugin development: associate plugin types to a ticket

I changed the code declaration to the following so the class could be detected. But still it is not appearing in the dropdown. I also declared it in the ticket types on the Assistant tab from the profile page.

$CFG_GLPI["ticket_types"][] = PluginAssetlistAssetlist::class;

Last edited by scarletTornado (2024-04-26 08:50:49)

Offline

#4 2024-04-29 13:42:34

scarletTornado
Member
Registered: 2024-04-12
Posts: 19

Re: [SOLVED]Plugin development: associate plugin types to a ticket

Still trying to find out the problem. I'll leave clear what's happening:
1. I defined all my classes in the "inc" folder. Each one has her name preceded by "PluginAssetlist".
2. The only class I want to associate to a ticket has been inserted in the "ticket_types" array through the following code.

$CFG_GLPI["ticket_types"][] = PluginAssetlistAssetlist::class;

3. After that I moved to the "Assistance" tab of one available user profile and added my class to it. It appeared with the name "Assetlists" (getTypeName() method invoked). I saved the changes and moved to the "/front/ticket.form.php" file. In the dropdown of items which can be associated to the ticket doesn't appear my class though.

Note: I just discovered that I can associate the object to the ticket if I create the ticket directly from the "Ticket" tab of my plugin object.

Last edited by scarletTornado (2024-04-29 13:48:19)

Offline

#5 2024-04-29 17:49:44

scarletTornado
Member
Registered: 2024-04-12
Posts: 19

Re: [SOLVED]Plugin development: associate plugin types to a ticket

Nevermind, I found out there's a hook called "assign_to_ticket". Basically, in your setup php you have to declare your plugin in the "assign_to_ticket" array with your plugin name as the key.

$PLUGIN_HOOKS['assign_to_ticket']['assetlist'] = "";    // Value isn't used

Later in your hook.php you declare a function like the following which returns an array with the different classes as keys and their representation in the dropdown as the values so they can be shown.

function plugin_assetlist_AssignToTicket() {
   return [
      PluginAssetlistAssetlist::class => PluginAssetlistAssetlist::getTypeName()
   ];
}

Offline

Board footer

Powered by FluxBB