Skip to content
Snippets Groups Projects
Commit e9a7582e authored by Cyril Vazquez's avatar Cyril Vazquez
Browse files

Fix: Add test on event table Vs coll_table/coll_view before adding attachment with record_id

parent aa276819
No related branches found
No related tags found
No related merge requests found
......@@ -133,18 +133,21 @@ while ($state <> 'END') {
if($tmpNotif['attach']) {
$logger->write('Adding attachments', 'INFO');
foreach($tmpNotif['events'] as $event) {
$query = "SELECT "
. "ds.path_template ,"
. "mlb.path, "
. "mlb.filename "
. "FROM ".$coll_view." mlb LEFT JOIN docservers ds ON mlb.docserver_id = ds.docserver_id "
. "WHERE mlb.res_id = " . $event->record_id;
Bt_doQuery($db, $query);
$path_parts = $db->fetch_object();
$path = $path_parts->path_template . str_replace('#', '/', $path_parts->path) . $path_parts->filename;
$path = str_replace('//', '/', $path);
$path = str_replace('\\', '/', $path);
$attachments[] = $path;
// Check if event is related to document in collection
if($event->table_name === $coll_table || $event->table_name === $coll_view) {
$query = "SELECT "
. "ds.path_template ,"
. "mlb.path, "
. "mlb.filename "
. "FROM ".$coll_view." mlb LEFT JOIN docservers ds ON mlb.docserver_id = ds.docserver_id "
. "WHERE mlb.res_id = " . $event->record_id;
Bt_doQuery($db, $query);
$path_parts = $db->fetch_object();
$path = $path_parts->path_template . str_replace('#', '/', $path_parts->path) . $path_parts->filename;
$path = str_replace('//', '/', $path);
$path = str_replace('\\', '/', $path);
$attachments[] = $path;
}
}
$logger->write(count($attachments) . ' attachment(s) added', 'INFO');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment