-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
close ticket when rattached to problem closed #21358
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
close ticket when rattached to problem closed #21358
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current solution works, but the template calls item.maySolve()
on item
, which is a Ticket object but empty.
At this point, we do not have access to the actual Ticket (we are inside a mass action).
Another approach — to be validated with @cedric-anne — could be to pass an argument like from_ma
to handle this specific context and bypass status check.
diff --git a/src/Change_Ticket.php b/src/Change_Ticket.php
index a7d46d6209..7119ba48b3 100644
--- a/src/Change_Ticket.php
+++ b/src/Change_Ticket.php
@@ -128,7 +128,7 @@ class Change_Ticket extends CommonDBRelation
$change = new Change();
$input = $ma->getInput();
if (isset($input['changes_id']) && $change->getFromDB($input['changes_id'])) {
- $change->showMassiveSolutionForm($change);
+ $change->showMassiveSolutionForm($change, true);
echo "<br>";
echo Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']);
return true;
diff --git a/src/CommonITILObject.php b/src/CommonITILObject.php
index a9c445303b..af9bc7dade 100644
--- a/src/CommonITILObject.php
+++ b/src/CommonITILObject.php
@@ -5194,7 +5194,7 @@ abstract class CommonITILObject extends CommonDBTM
*
* @param $entities_id
**/
- public static function showMassiveSolutionForm(CommonITILObject $item)
+ public static function showMassiveSolutionForm(CommonITILObject $item, bool $from_ma = false)
{
$solution = new ITILSolution();
$solution->showForm(
@@ -5204,6 +5204,7 @@ abstract class CommonITILObject extends CommonDBTM
'entity' => $item->getEntityID(),
'noform' => true,
'nokb' => true,
+ 'from_ma' => $from_ma,
]
);
}
diff --git a/src/Problem_Ticket.php b/src/Problem_Ticket.php
index b5b98f1a1d..8687241451 100644
--- a/src/Problem_Ticket.php
+++ b/src/Problem_Ticket.php
@@ -169,7 +169,7 @@ class Problem_Ticket extends CommonDBRelation
$problem = new Problem();
$input = $ma->getInput();
if (isset($input['problems_id']) && $problem->getFromDB($input['problems_id'])) {
- $problem->showMassiveSolutionForm($problem);
+ $problem->showMassiveSolutionForm($problem, true);
echo "<br>";
echo Html::submit(_x('button', 'Post'), [
'name' => 'massiveaction',
diff --git a/templates/components/itilobject/timeline/form_solution.html.twig b/templates/components/itilobject/timeline/form_solution.html.twig
index 2a20697eb0..2dcc56797a 100644
--- a/templates/components/itilobject/timeline/form_solution.html.twig
+++ b/templates/components/itilobject/timeline/form_solution.html.twig
@@ -35,7 +35,7 @@
{% set params = {'item': item}|merge(params|default({})) %}
-{% set candedit = item.maySolve() %}
+{% set candedit = item.maySolve() or params['from_ma'] %}
{% set can_read_kb = has_profile_right('knowbase', constant('READ')) or has_profile_right('knowbase', constant('KnowbaseItem::READFAQ')) %}
{% set can_update_kb = has_profile_right('knowbase', constant('UPDATE')) %}
{% set nokb = params['nokb'] is defined or params['nokb'] == true %}
What do you think @cedric-anne
IMHO, changing the |
can you retry / check behavior with only this : diff --git a/templates/components/itilobject/timeline/form_task.html.twig b/templates/components/itilobject/timeline/form_task.html.twig
index c3743ca441..ea0dcf187b 100644
--- a/templates/components/itilobject/timeline/form_task.html.twig
+++ b/templates/components/itilobject/timeline/form_task.html.twig
@@ -34,7 +34,7 @@
{% set params = {'parent': item}|merge(params|default({})) %}
-{% set candedit = item.maySolve() %}
+{% set candedit = item.isNewItem() or item.maySolve() %}
{% set can_read_kb = has_profile_right('knowbase', constant('READ')) or has_profile_right('knowbase', constant('KnowbaseItem::READFAQ')) %}
{% set can_update_kb = has_profile_right('knowbase', constant('UPDATE')) %}
{% set nokb = params['nokb'] is defined or (params['nokb'] ?? false) == true %} |
@stonebuzz, the solution proposed by @cedric-anne works |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not be here :)
8534cd9
to
b296dad
Compare
b296dad
to
7c36fcc
Compare
217ac92
to
40e9ca1
Compare
Checklist before requesting a review
Please delete options that are not relevant.
Description
Users cannot add solutions to linked Tickets via mass actions when the parent Problem is Closed.
Let’s consider the following scenario:
A user has the permission to resolve or close a Problem, but their profile restrictions prevent them from changing the Problem’s status from “Closed” back to “Solved.”
Starting from a Closed Problem,
if the user tries to resolve one or more linked Tickets through mass actions,
the form used to add a solution to the Tickets appears disabled (grayed out).
This happens because the template form_solution.html.twig — which displays the solution form — checks whether the current object can be resolved using the maybeSolve() method.
The maybeSolve() function verifies whether the user’s profile lifecycle allows transitioning the current object’s status from its current state (in this case, the Problem, which is Closed) to Solved.
Since this check is performed on the Problem object instead of the Ticket,
GLPI returns false, marking the fields as non-editable, even though the user might be allowed to resolve the Ticket itself.
Screenshots (if appropriate):