Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions src/NotificationTargetCommonITILObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,33 @@ public function getDataForObject(CommonITILObject $item, array $options, $simple
$data['##ticket.numberoflinkedchanges##'] = count($data['linkedchanges']);
$data['##ticket.numberoflinkedproblems##'] = count($data['linkedproblems']);

$data['linkedprojects'] = [];
$itil_project = new Itil_Project();
$linked_projects = $itil_project->find([
'itemtype' => $item->getType(),
'items_id' => $item->getField('id'),
]);
foreach ($linked_projects as $linked_project) {
$project = new Project();
if ($project->getFromDB($linked_project['projects_id'])) {
$data['linkedprojects'][] = [
'##linkedproject.id##' => $linked_project['projects_id'],
'##linkedproject.url##' => $this->formatURL(
$options['additionnaloption']['usertype'],
'project_' . $linked_project['projects_id']
),
'##linkedproject.name##' => $project->getField('name'),
'##linkedproject.content##' => $project->getField('content'),
'##linkedproject.code##' => $project->getField('code'),
'##linkedproject.planstartdate##' => $project->getField('plan_start_date'),
'##linkedproject.planenddate##' => $project->getField('plan_end_date'),
'##linkedproject.realstartdate##' => $project->getField('real_start_date'),
'##linkedproject.realenddate##' => $project->getField('real_end_date'),
];
}
}
$data['##' . strtolower($item->getType()) . '.numberoflinkedprojects##'] = count($data['linkedprojects']);

$show_private = $options['additionnaloption']['show_private'] ?? false;
$followup_restrict = [];
$followup_restrict['items_id'] = $item->getField('id');
Expand Down Expand Up @@ -2227,6 +2254,7 @@ public function getTags()
$objettype . '.numberoflinkedtickets' => _x('quantity', 'Number of linked tickets'),
$objettype . '.numberoflinkedchanges' => _x('quantity', 'Number of linked changes'),
$objettype . '.numberoflinkedproblems' => _x('quantity', 'Number of linked problems'),
$objettype . '.numberoflinkedprojects' => _x('quantity', 'Number of linked projects'),
$objettype . '.reminder.bumpcounter' => __('Number of sent reminders since status is pending'),
$objettype . '.reminder.bumpremaining' => __('Number of remaining reminders before automatic resolution'),
$objettype . '.reminder.bumptotal' => __('Total number of reminders before automatic resolution'),
Expand Down Expand Up @@ -2255,6 +2283,7 @@ public function getTags()
'linkedtickets' => _n('Linked ticket', 'Linked tickets', Session::getPluralNumber()),
'linkedchanges' => _n('Linked change', 'Linked changes', Session::getPluralNumber()),
'linkedproblems' => _n('Linked problem', 'Linked problems', Session::getPluralNumber()),
'linkedprojects' => _n('Linked project', 'Linked projects', Session::getPluralNumber()),
];

foreach ($tags as $tag => $label) {
Expand All @@ -2278,6 +2307,7 @@ public function getTags()
$objettype . '.linkedtickets' => _n('Linked ticket', 'Linked tickets', Session::getPluralNumber()),
$objettype . '.linkedchanges' => _n('Linked change', 'Linked changes', Session::getPluralNumber()),
$objettype . '.linkedproblems' => _n('Linked problem', 'Linked problems', Session::getPluralNumber()),
$objettype . '.linkedprojects' => _n('Linked project', 'Linked projects', Session::getPluralNumber()),
];

foreach ($tags as $tag => $label) {
Expand Down Expand Up @@ -2440,6 +2470,51 @@ public function getTags()
_n('Linked problem', 'Linked problems', 1),
__('Description')
),
'linkedproject.id' => sprintf(
__('%1$s: %2$s'),
_n('Linked project', 'Linked projects', 1),
__('ID')
),
'linkedproject.url' => sprintf(
__('%1$s: %2$s'),
_n('Linked project', 'Linked projects', 1),
__('URL')
),
'linkedproject.name' => sprintf(
__('%1$s: %2$s'),
_n('Linked project', 'Linked projects', 1),
__('Name')
),
'linkedproject.content' => sprintf(
__('%1$s: %2$s'),
_n('Linked project', 'Linked projects', 1),
__('Description')
),
'linkedproject.code' => sprintf(
__('%1$s: %2$s'),
_n('Linked project', 'Linked projects', 1),
__('Code')
),
'linkedproject.planstartdate' => sprintf(
__('%1$s: %2$s'),
_n('Linked project', 'Linked projects', 1),
__('Plan start date')
),
'linkedproject.planenddate' => sprintf(
__('%1$s: %2$s'),
_n('Linked project', 'Linked projects', 1),
__('Plan end date')
),
'linkedproject.realstartdate' => sprintf(
__('%1$s: %2$s'),
_n('Linked project', 'Linked projects', 1),
__('Plan start date')
),
'linkedproject.realenddate' => sprintf(
__('%1$s: %2$s'),
_n('Linked project', 'Linked projects', 1),
__('Plan start date')
),
];

foreach ($tags as $tag => $label) {
Expand Down
67 changes: 67 additions & 0 deletions src/NotificationTargetTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,30 @@ public function getDataForObject(CommonDBTM $item, array $options, $simple = fal

$data['validations'][] = $tmp;
}

// linked project tasks
$data['linkedprojecttasks'] = [];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code has been added to src/NotificationTargetTicket.php.
It will likely also need to be implemented in NotificationTargetChange and NotificationTargetProblem for consistency across notification targets.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't have to add it in NotificationTargetChange and NotificationTargetProblem because we can't link project tasks to changes and problems but only to tickets.

$project_task_ticket = new ProjectTask_Ticket();
$linked_project_tasks = $project_task_ticket->find(['tickets_id' => $item->getField('id')]);
foreach ($linked_project_tasks as $linked_project_task) {
$project_task = new ProjectTask();
if ($project_task->getFromDB($linked_project_task['projecttasks_id'])) {
$data['linkedprojecttasks'][] = [
'##linkedprojecttask.id##' => $linked_project_task['projecttasks_id'],
'##linkedprojecttask.url##' => $this->formatURL(
$options['additionnaloption']['usertype'],
'projecttask_' . $linked_project_task['projecttasks_id']
),
'##linkedprojecttask.name##' => $project_task->getField('name'),
'##linkedprojecttask.content##' => $project_task->getField('content'),
'##linkedprojecttask.planstartdate##' => $project_task->getField('plan_start_date'),
'##linkedprojecttask.planenddate##' => $project_task->getField('plan_end_date'),
'##linkedprojecttask.realstartdate##' => $project_task->getField('real_start_date'),
'##linkedprojecttask.realenddate##' => $project_task->getField('real_end_date'),
];
}
}
$data['##ticket.numberoflinkedprojecttasks##'] = count($data['linkedprojecttasks']);
}

$data['##ticket.externalid##'] = $item->fields['externalid'];
Expand Down Expand Up @@ -652,6 +676,7 @@ public function getTags()
'ticket.numberofproblems' => _x('quantity', 'Number of problems'),
'ticket.numberofchanges' => _x('quantity', 'Number of changes'),
'ticket.numberofitems' => _x('quantity', 'Number of items'),
'ticket.numberoflinkedprojecttasks' => _x('quantity', 'Number of linked project tasks'),
'ticket.autoclose' => __('Automatic closing of solved tickets after'),
'ticket.location' => Location::getTypeName(1),
'ticket.location.comment' => __('Location comments'),
Expand Down Expand Up @@ -736,6 +761,7 @@ public function getTags()
'changes' => Change::getTypeName(Session::getPluralNumber()),
'items' => _n('Associated item', 'Associated items', Session::getPluralNumber()),
'documents' => Document::getTypeName(Session::getPluralNumber()),
'linkedprojecttasks' => _n('Linked project task', 'Linked project tasks', Session::getPluralNumber()),
];

foreach ($tags as $tag => $label) {
Expand All @@ -759,6 +785,7 @@ public function getTags()
),
'?'
),
'ticket.linkedprojecttasks' => _n('Linked project task', 'Linked project tasks', Session::getPluralNumber()),
];

foreach ($tags as $tag => $label) {
Expand Down Expand Up @@ -809,6 +836,46 @@ public function getTags()
Change::getTypeName(1),
__('Description')
),
'linkedprojecttask.id' => sprintf(
__('%1$s: %2$s'),
_n('Linked project task', 'Linked project tasks', 1),
__('ID')
),
'linkedprojecttask.url' => sprintf(
__('%1$s: %2$s'),
_n('Linked project task', 'Linked project tasks', 1),
__('URL')
),
'linkedprojecttask.name' => sprintf(
__('%1$s: %2$s'),
_n('Linked project task', 'Linked project tasks', 1),
__('Name')
),
'linkedprojecttask.content' => sprintf(
__('%1$s: %2$s'),
_n('Linked project task', 'Linked project tasks', 1),
__('Description')
),
'linkedprojecttask.planstartdate' => sprintf(
__('%1$s: %2$s'),
_n('Linked project task', 'Linked project tasks', 1),
__('Plan start date')
),
'linkedprojecttask.planenddate' => sprintf(
__('%1$s: %2$s'),
_n('Linked project task', 'Linked project tasks', 1),
__('Plan end date')
),
'linkedprojecttask.realstartdate' => sprintf(
__('%1$s: %2$s'),
_n('Linked project task', 'Linked project tasks', 1),
__('Plan start date')
),
'linkedprojecttask.realenddate' => sprintf(
__('%1$s: %2$s'),
_n('Linked project task', 'Linked project tasks', 1),
__('Plan start date')
),
];

foreach ($tags as $tag => $label) {
Expand Down