Skip to content

Commit bb31fc5

Browse files
authored
Add tasks visibility option (#449)
* Add tasks visibility option * Add in config template * Update changelog * Fix lint * FIx tests * FIx tests * FIx lints
1 parent 3d4eadf commit bb31fc5

6 files changed

Lines changed: 88 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313
- Fixed routing issue caused by incorrect trailing slash
1414
- Fix to rule execution based on group deletion
1515

16+
### Added
17+
18+
- Add task visibility option (`task_private`)
19+
1620
## [2.9.19] - 2026-27-01
1721

1822
### Fixed

hook.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@ function plugin_escalade_install()
8585
`use_filter_assign_group` INT NOT NULL,
8686
`ticket_last_status` INT NOT NULL,
8787
`remove_requester` INT NOT NULL,
88+
`task_private` INT NOT NULL,
8889
PRIMARY KEY (`id`)
8990
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
9091
$DB->doQuery($query);
9192

9293
$query = "INSERT INTO glpi_plugin_escalade_configs
93-
VALUES (NULL, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, '" . Ticket::WAITING . "',0)";
94+
VALUES (NULL, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, '" . Ticket::WAITING . "',0, 1)";
9495
$DB->doQuery($query);
9596
}
9697

@@ -390,6 +391,18 @@ function plugin_escalade_install()
390391
$migration->migrationOneTable('glpi_plugin_escalade_users');
391392
}
392393

394+
//Update to 2.10.2
395+
// add new fields
396+
if (!$DB->fieldExists('glpi_plugin_escalade_configs', 'task_private')) {
397+
$migration->addField(
398+
'glpi_plugin_escalade_configs',
399+
'task_private',
400+
'integer',
401+
['after' => 'remove_requester'],
402+
);
403+
$migration->migrationOneTable('glpi_plugin_escalade_configs');
404+
}
405+
393406
return true;
394407
}
395408

inc/ticket.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ function (array $actor) use ($groups_id, &$seen_new_group): bool {
563563
$task_content = '<p><i>' . sprintf(__s('Escalation to the group %s.', 'escalade'), $group->getName()) . '</i></p><hr />' . $comment;
564564
PluginEscaladeTaskmanager::setTicketTask([
565565
'tickets_id' => $tickets_id,
566-
'is_private' => true,
566+
'is_private' => $_SESSION['glpi_plugins']['escalade']['config']['task_private'],
567567
'state' => Planning::INFO,
568568
'content' => $task_content,
569569
]);

templates/config.html.twig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@
194194
field_options
195195
) }}
196196

197+
{{ fields.sliderField(
198+
'task_private',
199+
config["task_private"],
200+
__("Escalation task is private ?", "escalade"),
201+
field_options
202+
) }}
203+
197204
{{ fields.dropdownArrayField(
198205
'ticket_last_status',
199206
config["ticket_last_status"],

tests/EscaladeTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public function initConfig(array $conf = [])
113113
'cloneandlink_ticket' => 0,
114114
'close_linkedtickets' => 0,
115115
'reassign_group_from_cat' => 0,
116+
'task_private' => 1,
116117
];
117118

118119
// Update escalade config in database if provided

tests/Units/TaskMessageTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,65 @@ public function testTaskGroupEscalation(array $conf)
276276
}
277277
}
278278
}
279+
280+
public static function taskPrivateProvider(): iterable
281+
{
282+
yield [
283+
'task_private' => 0,
284+
'expected_is_private' => 0,
285+
];
286+
287+
yield [
288+
'task_private' => 1,
289+
'expected_is_private' => 1,
290+
];
291+
}
292+
293+
#[DataProvider('taskPrivateProvider')]
294+
public function testTaskPrivateFlagOnEscalationTask(int $task_private, int $expected_is_private): void
295+
{
296+
$this->initConfig([
297+
'task_history' => 1,
298+
'task_private' => $task_private,
299+
]);
300+
301+
$ticket = $this->createItem('Ticket', [
302+
'name' => 'Task private escalation test',
303+
'content' => '',
304+
'entities_id' => 0,
305+
]);
306+
307+
$this->createItem('Group', [
308+
'name' => 'Task private group',
309+
'entities_id' => 0,
310+
]);
311+
312+
$group2 = $this->createItem('Group', [
313+
'name' => 'Task private group 2',
314+
'entities_id' => 0,
315+
]);
316+
317+
$this->updateItem(
318+
Ticket::class,
319+
$ticket->getID(),
320+
[
321+
'_actors' => [
322+
'assign' => [
323+
[
324+
'items_id' => $group2->getID(),
325+
'itemtype' => 'Group',
326+
],
327+
],
328+
],
329+
],
330+
);
331+
332+
$ticket_task = new TicketTask();
333+
$ticket_tasks = $ticket_task->find(['tickets_id' => $ticket->getID()]);
334+
335+
$this->assertCount(1, $ticket_tasks);
336+
337+
$last_task = end($ticket_tasks);
338+
$this->assertSame($expected_is_private, (int) $last_task['is_private']);
339+
}
279340
}

0 commit comments

Comments
 (0)