diff --git a/inc/functions.php b/inc/functions.php index f071534f9e..6ad56067d6 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -571,21 +571,65 @@ function make_pdf($id, $type, $out = 'browser') $comment[] = $uploads['comment']; } // do we have files attached ? - $filenb = count($real_name); - if ($filenb > 0) { + if (count($real_name) > 0) { $content .= "
"; - if ($filenb === 1) { + if (count($real_name) === 1) { $content .= "

Attached file :

"; } else { $content .= "

Attached files :

"; } $content .= "
"; } + // SQL to get linked items + $sql = "SELECT experiments_links.*, + experiments_links.link_id AS item_id, + items.title AS title, + items_types.name AS type + FROM experiments_links + LEFT JOIN items ON (experiments_links.link_id = items.id) + LEFT JOIN items_types ON (items.type = items_types.id) + WHERE item_id = ".$id; + $req = $pdo->prepare($sql); + $req->execute(); + $links_id_arr = array(); + $links_title_arr = array(); + $links_type_arr = array(); + // we put what we need in arrays + while ($links = $req->fetch()) { + $links_id_arr[] = $links['item_id']; + $links_title_arr[] = $links['title']; + $links_type_arr[] = $links['type']; + } + // only display this section if there is something to display + if ($req->rowCount() > 0) { + $content .= '
'; + if ($req->rowCount() === 1) { + $content .= "

Linked item :

"; + } else { + $content .= "

Linked items :

"; + } + $content .= "
"; + } + + + // ELABID and URL $content .= "

elabid : ".$elabid."

"; $content .= "

URL : ".$full_url."

"; } else { // ITEM diff --git a/make_zip.php b/make_zip.php index 7615e8d829..4b37877c51 100644 --- a/make_zip.php +++ b/make_zip.php @@ -107,9 +107,17 @@ $tags .= stripslashes($data['tag']).' '; } - // SQL to get filesattached - $sql = "SELECT * FROM uploads WHERE item_id = ".$id; + // SQL to get filesattached (of the right type) + $sql = "SELECT * FROM uploads WHERE item_id = :id AND type = :type"; $req = $pdo->prepare($sql); + // we could use $table instead of $type, but 'items' will be of type 'database', so we need this "if" + if ($table === 'items') { + $type = 'database'; + } else { + $type = $table; // experiments + } + $req->bindParam(':id', $id); + $req->bindParam(':type', $type); $req->execute(); $real_name = array(); $long_name = array();