Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.5.0: group not added to requesters #629

Closed
satyan01 opened this issue Jun 14, 2017 · 49 comments · Fixed by #927
Closed

Version 2.5.0: group not added to requesters #629

satyan01 opened this issue Jun 14, 2017 · 49 comments · Fixed by #927
Assignees
Labels
Milestone

Comments

@satyan01
Copy link

satyan01 commented Jun 14, 2017

Hello

Thx for this great new version.

Is it possible to do the same thing for ticket title as category
image
replace title by content of title of incident fields of my form

My group is not created as well

  • It would be useful to have the possibility to sort form views for users, with glpi statistics we are able to know which request are the most used and put these forms firstly for users.
@btry
Copy link
Collaborator

btry commented Jun 14, 2017

Hi

1st question:
Add a question answer tag in the title of the target ticket our taget change. It should work.

2nd question:
I'm not sure about your question. Do you mean sorting the forms in t he adminisration area of the plugin (where the admin designs forms) ?

@satyan01
Copy link
Author

1 - how can I add a tag in title ?
image

2 - I mean change in administration the view for users view

example in administration mode I put first - incident / wifi access / folder right

users see : incident / wifi access / folder right

@btry
Copy link
Collaborator

btry commented Jun 14, 2017

1
At the bottom of the target ticket you have a list of tags for labels and answers. Simply use them in the title. See the screenshot below.

image

2 there is no feature for that now. Forms are displated to the user by popularity or alphabetically. The popularity of a form increases when a user answers it.

@satyan01
Copy link
Author

satyan01 commented Jun 14, 2017

1 - thx it works
2 - ok it answers to my request
3 - issue with requester group not filled
image

@btry btry changed the title Version 2.5.0 Version 2.5.0: group not added to requesters Jun 14, 2017
@btry
Copy link
Collaborator

btry commented Jun 14, 2017

Please show me the target ticket definition of this form, to see how groups shoudl be aded (from a question, a fixed group, ..)

@satyan01
Copy link
Author

image

@btry
Copy link
Collaborator

btry commented Jun 15, 2017

This screenshot shows the user filling the form is added to the target ticket. There is not any group to add as requester, then the plugin seems to behave as expected.

@satyan01
Copy link
Author

I have this setup for all my forms and the group is added automatically with the requester

@btry
Copy link
Collaborator

btry commented Jun 15, 2017

Then the group comes from a ticket template.

In my opinion, if the template assigns actors, they should be added to those defined in the target item.

I need to determine if this is a regression. did this worked with previous version of the plugin (2.4.x ) ?

@satyan01
Copy link
Author

nothing in my other templates and it was working with 2.4.0 but not for all forms, so I suppose it does not come from 2.5.0. How the requester is able to be added automatically with the associated requester ?

@btry
Copy link
Collaborator

btry commented Jun 15, 2017

OK I mark this as bug for version 2.5.2 or later. (2.5.1 is planned for PHP 5.4 comaptibility )

@satyan01
Copy link
Author

ok thx

@btry btry added the bug label Jun 15, 2017
@btry btry self-assigned this Jun 15, 2017
@btry btry added this to the 2.5.2 milestone Jun 15, 2017
@nbriche
Copy link

nbriche commented Jun 19, 2017

@satyan01 Maybe the group was added by the "Behaviors" plugin?

I'm also trying to get this to work (automatically adding the user's groups to requesters), but so far no luck. As long as I don't use a form, the groups add themselves correctly (using Behaviors), but if I use a form nothing happens.

@btry
Copy link
Collaborator

btry commented Jun 19, 2017

Hi

This might explain why the target ticket does not have any group. @satyan01 please confirm if you use the Behaviors plugin to add a group.

@nbriche
Copy link

nbriche commented Jun 19, 2017

To be more precise: I'm currently using GLPI 9.1.3, Behaviors 1.3, FormCreator 2.4.2. (Although I just tested 2.5.1, and no change)

@satyan01
Copy link
Author

Hello yes I confirm to use Behavior plugin

@yllen
Copy link

yllen commented Jun 21, 2017

In Behaviors plugin, adding of group requester is done in pre_item_add to after have mechanism of the core.
In Formcreator plugin, adding a ticket is done directly so after rules of Behaviors plugin

@btry
Copy link
Collaborator

btry commented Jun 21, 2017

Thank you @yllen for this information.

I think shall do the same in FormCreator, this way, both plugin can work together.

@satyan01
Copy link
Author

if it is not a big modification could you give me it in order to fix it now.

@btry
Copy link
Collaborator

btry commented Jun 21, 2017

@satyan01 please try first to workaround by adding in your target the groups which should be added by Behaviors.

I think it will work. I think I have to redesign several parts of the plugin now to solve more complex issues, and plan to add tests on the UI of the plugin.

@satyan01
Copy link
Author

the group is different according to the requester, anyway, i will wait for your fix. Thank you

@satyan01
Copy link
Author

I confirm if I force group in the form it does not appear in the ticket

@btry
Copy link
Collaborator

btry commented Jun 27, 2017

Hi

I think the fix needs to be in Behaviors, not FormCreator.

To remove direct manipulation on tickets I contributed to GLPI 9.1.2 to let it handle arrays of users, groups and suppliers for all actor types (requester, observer, and assigned).

Behaviors does not handle arrays for requesters, then it fails with FormCreator. I tried a simple change in FormCreator but this is not sufficient to make Behaviors happy. If I go further, I will simply destroy the work I did a few months ago, and revert to the previous implementation. This old code was very hard to maintain, and is anyway incomaptible with Behaviors due to how it worked.

@btry btry removed the bug label Jun 27, 2017
@btry btry removed this from the 2.5.2 milestone Jun 27, 2017
@btry btry added this to the 2.6.1 milestone Dec 8, 2017
@btry
Copy link
Collaborator

btry commented Dec 8, 2017

The method PluginBehaviorsTicket::BeforeAdd()

is called in the process of Ticket::add(), and before the ticket is actually saved in the database. Check the method CommonDBTM::add() which implement the high level actions of adding any item in the database, including tickets of course.

@nbriche
Copy link

nbriche commented Dec 8, 2017

Behaviors is still on the old forge, which is not quite optimal for my workflow but yes, I'm going to request some dev time to my boss to work on this a little.

@nbriche
Copy link

nbriche commented Dec 8, 2017

Okay I think I've got it.

At behaviors/inc/ticket.class.php:344, PluginBehaviorsTicket::beforeAdd() tests the incoming ticket's requesters. It only applies the configured policy if:

  • $ticket->input['_users_id_requester'] exists, and
  • $ticket->input['_users_id_requester'] is not zero, and
  • $ticket->input['_groups_id_requester'] doesn't exist, or is <=0.

Core 9.2.1 creates its 'vanilla' tickets with a _groups_id_requester set to zero if no group is added. Behaviors knows how to handle that. But FormCreator sends an empty array, and as you said previously, that's not a case this test is ready for.

If I complete the test as such: && (!isset($ticket->input['_groups_id_requester']) || $ticket->input['_groups_id_requester']<=0 || empty($ticket->input['_groups_id_requester'])), Behaviors seems to understand what's going on and add the correct groups.

The thing is, I don't know if this is a problem with Behaviors for not checking _groups_id_requester as an empty array, or FormCreator for not declaring an empty _groups_id_requester the same way as Core.

EDIT: Now that I think about it, unless there's a reason for _groups_id_requester to be negative, that entire test can be replaced by just the empty($ticket->input['_groups_id_requester'])) and we'll have support for both forms.

@btry
Copy link
Collaborator

btry commented Dec 9, 2017

Hi

The thing is, I don't know if this is a problem with Behaviors for not checking _groups_id_requester as an empty array, or FormCreator for not declaring an empty _groups_id_requester the same way as Core.

I said I contributed to GLPI core to handle creation of ticket with several requesters. This contribution is intended to solve way too complex and unmaintainable code in Formcreator. Also, setting multiple observers or assignees was already possible. It makes sense to have same level of features for all actors. The user interface of GLPI still does not allows to set several requesters, this is the reason it does not sends an array of requesters.

Therefore, Behaviors is simply not up to date, and it needs a patch. Your investigation seems good, and you're close to a good patch to submit to the community.

Now that I think about it, unless there's a reason for _groups_id_requester to be negative, that entire test can be replaced by just the empty($ticket->input['_groups_id_requester'])) and we'll have support for both forms.

I believe I never saw a case when a group ID may be < 0. This needs investigation to determine if this code is still useful or is dead. I suggest you leave it as is to submit a patch which only solve your issue, and investigate (if you want) separately about this case.

@btry btry removed this from the 2.6.1 milestone Jan 2, 2018
@btry
Copy link
Collaborator

btry commented Jan 29, 2018

Hi

@nbriche did you find time to build a patch for Behaviours plugin ? Or is the bug fixed by someone else ?

@nbriche
Copy link

nbriche commented Jan 29, 2018

Hi,

Sorry; I've asked for the preferred patch submission method (since I have no access to the forge except as read-only, and there's no GitHub repo for Behaviors) but I've had no answer yet. I've used my test modification (manually edited) for about three weeks in production, I've had no issue.

@btry
Copy link
Collaborator

btry commented Jan 29, 2018

If I remember correctly, I have access to submit patches or issues. You may send the diff here. I"ll review it, and submit it to the official maintainer.

@nbriche
Copy link

nbriche commented Feb 7, 2018

Hi,

At long last I managed to find enough time to build a patch: issue629_behaviors-v2.0.0.patch.txt

It's built (as the name suggests) against 2.0.0. There's been a new release since, but the patch doesn't conflict.

@btry
Copy link
Collaborator

btry commented Feb 7, 2018

Hi

Thnak you. I submitted the patch here

https://forge.glpi-project.org/issues/5548

@yllen
Copy link

yllen commented Feb 7, 2018

_groups_id_requester is always set.
If empty it set to 0 in the core.
Test for <=0 is for ticket creation from webservices (a mistake can be set in value passed)

If Formcreator doesn't define value as request in the core it's not a Behaviors error.
But if it can solve users issue, i added this control.

@btry
Copy link
Collaborator

btry commented Feb 7, 2018

Hi

OK, I'll update the plugin to always set _groups_id_requester.

@btry btry added this to the 2.6.2 milestone Feb 7, 2018
@nqb
Copy link

nqb commented Feb 26, 2018

Hello,

With :

  • GLPI 9.2.2
  • Behaviors 2.0.2 (option "Use the requester's group" = "First")
  • FormCreator 2.6.2

First requester group is assign on ticket created through formcreator.

@btry btry modified the milestones: 2.6.2, 2.6.3 Mar 5, 2018
btry added a commit to btry/formcreator that referenced this issue Mar 5, 2018
This fix solves issues with Behaiours plugin < 2.0.2 and creates tickets like GLPI does internally

fix pluginsGLPI#629
btry added a commit to btry/formcreator that referenced this issue Mar 5, 2018
This fix solves issues with Behaiours plugin < 2.0.2 and creates tickets like GLPI does internally

fix pluginsGLPI#629
btry added a commit to btry/formcreator that referenced this issue Mar 21, 2018
This fix solves issues with Behaiours plugin < 2.0.2 and creates tickets like GLPI does internally

fix pluginsGLPI#629
btry added a commit to btry/formcreator that referenced this issue Apr 3, 2018
This fix solves issues with Behaiours plugin < 2.0.2 and creates tickets like GLPI does internally

fix pluginsGLPI#629
btry added a commit to btry/formcreator that referenced this issue Apr 3, 2018
This fix solves issues with Behaiours plugin < 2.0.2 and creates tickets like GLPI does internally

fix pluginsGLPI#629
btry added a commit to btry/formcreator that referenced this issue Apr 3, 2018
This fix solves issues with Behaiours plugin < 2.0.2 and creates tickets like GLPI does internally

fix pluginsGLPI#629
@btry
Copy link
Collaborator

btry commented Apr 5, 2018

Hi

@yllen please have a look on the following PR. I think the problem you identified will be properly solved with it.

#927

btry added a commit to btry/formcreator that referenced this issue Apr 9, 2018
This fix solves issues with Behaiours plugin < 2.0.2 and creates tickets like GLPI does internally

fix pluginsGLPI#629
btry added a commit to btry/formcreator that referenced this issue Apr 16, 2018
This fix solves issues with Behaiours plugin < 2.0.2 and creates tickets like GLPI does internally

fix pluginsGLPI#629
@btry btry closed this as completed in fa3f816 Apr 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants