Skip to content

Commit a5dc10d

Browse files
committed
fix(targetticket): set default document category
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent c69a5d0 commit a5dc10d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

inc/targetbase.class.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,25 @@ protected function addGroupActor($role, $group) {
531531
* Attach documents of the answer to the target
532532
*/
533533
protected function attachDocument($formAnswerId, $itemtype, $targetID) {
534+
global $CFG_GLPI;
535+
534536
$docItem = new Document_Item();
535-
if (count($this->attachedDocuments) > 0) {
536-
foreach ($this->attachedDocuments as $documentID => $dummy) {
537-
$docItem->add([
538-
'documents_id' => $documentID,
539-
'itemtype' => $itemtype,
540-
'items_id' => $targetID
537+
if (count($this->attachedDocuments) <= 0) {
538+
return;
539+
}
540+
541+
foreach ($this->attachedDocuments as $documentID => $dummy) {
542+
$docItem->add([
543+
'documents_id' => $documentID,
544+
'itemtype' => $itemtype,
545+
'items_id' => $targetID,
546+
]);
547+
if ($itemtype === Ticket::class) {
548+
$document = new Document();
549+
$documentCategoryFk = DocumentCategory::getForeignKeyField();
550+
$document->update([
551+
'id' => $documentID,
552+
$documentCategoryFk => $CFG_GLPI["documentcategories_id_forticket"],
541553
]);
542554
}
543555
}

0 commit comments

Comments
 (0)