You are not logged in.
Pages: 1
Topic closed
I just installed version 9.2.1 on my test server and tested the document attachment option in the notification email. It now works, a technician can now attach a document in a follow up and it is going to be sent to the Requester in the notification email. The problem is, it doesn't just attach the document that was selected in the followup, it will attach ALL documents pertaining to that ticket. Example : if i do 3 followups with each of them having 1 file, the first followup will attach 1 file, the second will attach the first followup file and the current one, the third one will attach the first, second and current.
And it will even attach a document that was placed in a private followup. As you can probably guess this will just confuse the requesters plus it's inflating mailboxes with unnecessary documents. Is it possible to revise this to only place in the notification only the document attached to the followup in question?
GLPI 9.2.1 | Wampserver 3.1.0 | Apache 2.4.27 | PHP 7.1.9 | MySQL 5.7.19
Offline
I have same problem on same version.
Offline
Hi all
Have you already resolved this problem?
Can you share , please?
I have the same problem with the version 9.4.3
Tks
Offline
I have same problem on 9.5.3 and 9.5.5
Way of sending emails: PHP or SMTP + SSL
Any followup notification contains all attachments from ticket.
Last edited by alexey_zhuravlev (2021-06-28 21:42:10)
Offline
Hi,
anyone can get the resolve this issue?
Offline
Hello!
If still relevant))
I tried to do this to change the logic of working with attachments:
In class notificationeventmailing.class.php around line 268
replace
foreach ($inline_docs as $docID => $tag) {
$current->fields['body_html'] = preg_replace([
'/src=["\'][^"\']*document\.send\.php\?docid='.$docID.'(&[^"\']+)?["\']/',
'/href=["\'][^"\']*document\.send\.php\?docid='.$docID.'(&[^"\']+)?["\']/',
], [
'src="cid:' . $tag . '"',
'href="' . $CFG_GLPI['url_base'] . '/front/document.send.php?docid=' . $docID . '$1"',
],
$current->fields['body_html']);
}
$mmail->Body = GLPIMailer::normalizeBreaks($current->fields['body_html']);
$mmail->AltBody = GLPIMailer::normalizeBreaks($current->fields['body_text']);
}
self::attachDocuments($mmail, $documents_to_attach);
to
foreach ($inline_docs as $docID => $tag) {
$current->fields['body_html'] = preg_replace([
'/src=["\'][^"\']*document\.send\.php\?docid='.$docID.'(&[^"\']+)?["\']/',
'/href=["\'][^"\']*document\.send\.php\?docid='.$docID.'(&[^"\']+)?["\']/',
], [
'src="cid:' . $tag . '"',
'href="' . $CFG_GLPI['url_base'] . '/front/document.send.php?docid=' . $docID . '$1"',
],
$current->fields['body_html']);
}
$mmail->Body = GLPIMailer::normalizeBreaks($current->fields['body_html']);
$mmail->AltBody = GLPIMailer::normalizeBreaks($current->fields['body_text']);
}
<------> //patch - attach docs from documents fields of queuednotifications
if($current->fields["documents"]){
$documents_to_attach = [];
$documents_to_attach = importArrayFromDB($current->fields["documents"]);
<------> self::attachDocuments($mmail, $documents_to_attach);
}
In class notificationevent.class.php around line 182
replace
if (class_exists($eventclass)) {
$eventclass::raise(
$event,
$item,
$options,
$label,
$data,
$notificationtarget->setEvent($eventclass),
$template,
$notify_me,
$emitter
);
}
to
if (class_exists($eventclass)) {
<------><------>//attach docs added with followups or tasks
<------><------>if(array_key_exists('followup_id',$options)||array_key_exists('task_id',$options)){
$id_docs_array = [];
if(array_key_exists('followup_id',$options)){
$doc_crit[] = [
'timeline_position' => ['>', CommonITILObject::NO_TIMELINE],
'items_id'=>$options['followup_id']
];
}
if(array_key_exists('task_id',$options)){
$doc_crit[] = [
'timeline_position' => ['>', CommonITILObject::NO_TIMELINE],
'items_id'=>$options['task_id']
];
}
$query = [
'SELECT'=>'documents_id',
'FROM'=>'glpi_documents_items',
'WHERE'=> $doc_crit
];
$docs_ids = $DB->request($query);
foreach($docs_ids as $d_id){
$id_docs_array[] = $d_id['documents_id'];
}
$options['documents'] = $id_docs_array;
}
<------><------>//end of patch attach docs added with followups or tasks
$eventclass::raise(
$event,
$item,
$options,
$label,
$data,
$notificationtarget->setEvent($eventclass),
$template,
$notify_me,
$emitter
);
}
In class notificationeventabstract.class.php around line 140
//Send notification to the user
if ($label == '') {
$send_data = $template->getDataToSend(
$notificationtarget,
$tid,
$key,
$users_infos,
$options
);
$send_data['_notificationtemplates_id'] = $data['notificationtemplates_id'];
$send_data['_itemtype'] = $item->getType();
$send_data['_items_id'] = method_exists($item, "getID")
? $item->getID()
: 0;
$send_data['_entities_id'] = $entity;
$send_data['mode'] = $data['mode'];
//ADD
$send_data['documents'] = $options['documents'];
I only tested this for followup and tasks.
If you have a test environment, you can try testing.
Offline
Hi guys,
I know it's been a while, but this problem still exists, have you found any other solution?
Thanks a lot.
V.
Offline
Hi everyone,
have we got any news about this?
Is there a way to avoid that for every notification we have all ticket's documents attached?
Thanks!
Cris
Offline
same problem...
Offline
Please don't resurrect topics from ancient GLPI versions.
Please find or start a new topic for a supported version of GLPI (10.0.X).
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Pages: 1
Topic closed