Open eramos13 opened 1 year ago
Hi, same here, I'm facing the same issue, the groups from requester and technician haven´t been added.
+1 / no group added when choosing a requester or a technician
I corrected this problem with the following code in the ticket file /marketplace/behaviors/inc/ticket.class.php
// line 359
//Start code
if ($config->getField('use_requester_user_group') > 0 || isset($ticket->input['_actors'])) {
if (isset($ticket->input['_actors'])) {
$actors = $ticket->input['_actors'];
// save sender if available
}
// add group
if ($config->getField('use_requester_user_group') == 1) {
// First group
$grp = PluginBehaviorsUser::getRequesterGroup($ticket->input['entities_id'], $ticket->input['_users_id_requester'], true);
if ($grp > 0) {
$actors['requester'][] = [
'itemtype' => 'Group',
'items_id' => $grp,
'use_notification' => "1",
'alternative_email' => ""
];
}
} else {
// All groups
$grps = PluginBehaviorsUser::getRequesterGroup($ticket->input['entities_id'], $ticket->input['_users_id_requester'], false);
foreach ($grps as $grp) {
$actors['requester'][] = [
'itemtype' => 'Group',
'items_id' => $grp,
'use_notification' => "1",
'alternative_email' => ""
];
}
}
$ticket->input['_actors'] = $actors;
}
//end code
Thanks for the fix Why not pushing it as a pull request ?
I corrected this problem with the following code in the ticket file /marketplace/behaviors/inc/ticket.class.php
// line 359 //Start code if ($config->getField('use_requester_user_group') > 0 || isset($ticket->input['_actors'])) { if (isset($ticket->input['_actors'])) { $actors = $ticket->input['_actors']; // save sender if available } // add group if ($config->getField('use_requester_user_group') == 1) { // First group $grp = PluginBehaviorsUser::getRequesterGroup($ticket->input['entities_id'], $ticket->input['_users_id_requester'], true); if ($grp > 0) { $actors['requester'][] = [ 'itemtype' => 'Group', 'items_id' => $grp, 'use_notification' => "1", 'alternative_email' => "" ]; } } else { // All groups $grps = PluginBehaviorsUser::getRequesterGroup($ticket->input['entities_id'], $ticket->input['_users_id_requester'], false); foreach ($grps as $grp) { $actors['requester'][] = [ 'itemtype' => 'Group', 'items_id' => $grp, 'use_notification' => "1", 'alternative_email' => "" ]; } } $ticket->input['_actors'] = $actors; } //end code
For me it didn't work, when selecting the technitian in "Assigned to" including after saving, the group wasn't add it.
I corrected this problem with the following code in the ticket file /marketplace/behaviors/inc/ticket.class.php
// line 359 //Start code if ($config->getField('use_requester_user_group') > 0 || isset($ticket->input['_actors'])) { if (isset($ticket->input['_actors'])) { $actors = $ticket->input['_actors']; // save sender if available } // add group if ($config->getField('use_requester_user_group') == 1) { // First group $grp = PluginBehaviorsUser::getRequesterGroup($ticket->input['entities_id'], $ticket->input['_users_id_requester'], true); if ($grp > 0) { $actors['requester'][] = [ 'itemtype' => 'Group', 'items_id' => $grp, 'use_notification' => "1", 'alternative_email' => "" ]; } } else { // All groups $grps = PluginBehaviorsUser::getRequesterGroup($ticket->input['entities_id'], $ticket->input['_users_id_requester'], false); foreach ($grps as $grp) { $actors['requester'][] = [ 'itemtype' => 'Group', 'items_id' => $grp, 'use_notification' => "1", 'alternative_email' => "" ]; } } $ticket->input['_actors'] = $actors; } //end code
For me it didn't work, when selecting the technitian in "Assigned to" including after saving, the group wasn't add it.
This solution is to add to the requester's group when the ticket is created using the mail receiver.
The update the technician group I have not checked where in the code to be able to test.
For me, it should be available on demand for each actor's field, requester being of course the most important one
From the line 639 of file inc/ticket.class.php, include this:
// Line 639
// Begin
if ($config->getField('use_assign_user_group_update') && isset($ticket->input['_actors'])) {
$assigners = $ticket->input['_actors']['assign'];
if (count($assigners)) {
$grupos = [];
foreach ($assigners as $id => $assign) {
if ($assign['itemtype'] == 'User') {
if ($config->getField('use_assign_user_group_update') == 1) {
// First group
$grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],true);
$grupos = array_merge ($grupos, $grupo);
} else {
$grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],false);
$grupos = array_merge ($grupos, $grupo);
}
}
}
$ticket->input['_additional_groups_assigns'] = $grupos;
}
}
// End
please test in a homologation environment and let me know if there are any errors
From the line 639 of file inc/ticket.class.php, include this:
// Line 639 // Begin if ($config->getField('use_assign_user_group_update') && isset($ticket->input['_actors'])) { $assigners = $ticket->input['_actors']['assign']; if (count($assigners)) { $grupos = []; foreach ($assigners as $id => $assign) { if ($assign['itemtype'] == 'User') { if ($config->getField('use_assign_user_group_update') == 1) { // First group $grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],true); $grupos = array_merge ($grupos, $grupo); } else { $grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],false); $grupos = array_merge ($grupos, $grupo); } } } $ticket->input['_additional_groups_assigns'] = $grupos; } } // End
please test in a homologation environment and let me know if there are any errors
Which version did you patch this on ? (we're using 10.0.9 btw ;-) )
From the line 639 of file inc/ticket.class.php, include this:
// Line 639 // Begin if ($config->getField('use_assign_user_group_update') && isset($ticket->input['_actors'])) { $assigners = $ticket->input['_actors']['assign']; if (count($assigners)) { $grupos = []; foreach ($assigners as $id => $assign) { if ($assign['itemtype'] == 'User') { if ($config->getField('use_assign_user_group_update') == 1) { // First group $grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],true); $grupos = array_merge ($grupos, $grupo); } else { $grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],false); $grupos = array_merge ($grupos, $grupo); } } } $ticket->input['_additional_groups_assigns'] = $grupos; } } // End
please test in a homologation environment and let me know if there are any errors
Which version did you patch this on ? (we're using 10.0.9 btw ;-) )
Glpi 10.0.9 and Behaviors 2.7.2
From the line 639 of file inc/ticket.class.php, include this:
// Line 639 // Begin if ($config->getField('use_assign_user_group_update') && isset($ticket->input['_actors'])) { $assigners = $ticket->input['_actors']['assign']; if (count($assigners)) { $grupos = []; foreach ($assigners as $id => $assign) { if ($assign['itemtype'] == 'User') { if ($config->getField('use_assign_user_group_update') == 1) { // First group $grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],true); $grupos = array_merge ($grupos, $grupo); } else { $grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],false); $grupos = array_merge ($grupos, $grupo); } } } $ticket->input['_additional_groups_assigns'] = $grupos; } } // End
please test in a homologation environment and let me know if there are any errors
I have made some adjustments to your code, so that it adds the first group or all depending on the configuration of the plugin.
//Start code
if ($config->getField('use_assign_user_group_update') && isset($ticket->input['_actors'])) {
$assigners = $ticket->input['_actors']['assign'];
if (count($assigners)) {
$grupos = [];
foreach ($assigners as $id => $assign) {
if ($assign['itemtype'] == 'User') {
if ($config->getField('use_assign_user_group_update') == 1) {
// First group
$grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],true);
$grupos[] = $grupo;
} else if ($config->getField('use_assign_user_group_update') == 2) {
// All groups
$grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],false);
$grupos = array_merge ($grupos, $grupo);
}
}
}
$ticket->input['_additional_groups_assigns'] = $grupos;
}
}
//end code
Hi @nelsonyoneyama @eramos13, is it not better to do a pull request?
Actually, after several tests, neither of those two codes work here ... :-(
Actually, after several tests, neither of those two codes work here ... :-(
Clear your glpi cache, because both codes I tested in my development environment, then to production and it works without problems.
Actually, after several tests, neither of those two codes work here ... :-(
Could you provide a more detailed explanation of the issue you're encountering along with the specific error message you're receiving?
From the line 639 of file inc/ticket.class.php, include this:
// Line 639 // Begin if ($config->getField('use_assign_user_group_update') && isset($ticket->input['_actors'])) { $assigners = $ticket->input['_actors']['assign']; if (count($assigners)) { $grupos = []; foreach ($assigners as $id => $assign) { if ($assign['itemtype'] == 'User') { if ($config->getField('use_assign_user_group_update') == 1) { // First group $grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],true); $grupos = array_merge ($grupos, $grupo); } else { $grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],false); $grupos = array_merge ($grupos, $grupo); } } } $ticket->input['_additional_groups_assigns'] = $grupos; } } // End
please test in a homologation environment and let me know if there are any errors
I have made some adjustments to your code, so that it adds the first group or all depending on the configuration of the plugin.
//Start code if ($config->getField('use_assign_user_group_update') && isset($ticket->input['_actors'])) { $assigners = $ticket->input['_actors']['assign']; if (count($assigners)) { $grupos = []; foreach ($assigners as $id => $assign) { if ($assign['itemtype'] == 'User') { if ($config->getField('use_assign_user_group_update') == 1) { // First group $grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],true); $grupos[] = $grupo; } else if ($config->getField('use_assign_user_group_update') == 2) { // All groups $grupo = PluginBehaviorsUser::getTechnicianGroup($ticket->fields['entities_id'],$assign['items_id'],false); $grupos = array_merge ($grupos, $grupo); } } } $ticket->input['_additional_groups_assigns'] = $grupos; } } //end code
If you include this same code within the static function "beforeAdd," approximately around line 432, the code will assign the technician's groups during ticket creation.
Actually, after several tests, neither of those two codes work here ... :-(
Could you provide a more detailed explanation of the issue you're encountering along with the specific error message you're receiving?
I'm not ghaving any error message up front. It simply doesn't add any group.
I have to dig deeper in logs. I'll let you know if I find something
Actually, after several tests, neither of those two codes work here ... :-(
Could you provide a more detailed explanation of the issue you're encountering along with the specific error message you're receiving?
I'm not ghaving any error message up front. It simply doesn't add any group.
I have to dig deeper in logs. I'll let you know if I find something
Do you use any other plugin in your GLPI? Can you send me your ticket.class.php file to have a look?
In the behavior settings in the update request section the option "Add technician group - First" is enabled, but if I update the technician it does not update the group. This happens both when creating the ticket from the portal, as well as when creating the ticket from the mail receiver. I have already tried solution #71.
To replicate the scenario, create a ticket via the mail receiver, then update the request to assign a technician, you will see that it does not add the technician group.