@@ -820,9 +820,9 @@ if (!$can_support) {
-
+ = fileTypeTile($row['file_ext'], 'sm') ?>
= formatBytes($row['file_size']) ?> · = timeAgo($row['file_created_at']) ?>
diff --git a/agent/document.php b/agent/document.php
index a5652b599..7f091b76a 100644
--- a/agent/document.php
+++ b/agent/document.php
@@ -1,427 +1,236 @@
set('Cache.DefinitionImpl', null); // Disable cache by setting a non-existent directory or an invalid one
-$purifier_config->set('URI.AllowedSchemes', ['data' => true, 'src' => true, 'http' => true, 'https' => true]);
-$purifier = new HTMLPurifier($purifier_config);
-
-if (isset($_GET['document_id'])) {
- $document_id = intval($_GET['document_id']);
-}
-
-$folder_location = 0;
-
-$sql_document = mysqli_query($mysqli, "SELECT document_archived_at, document_client_visible, document_content, document_created_at,
- document_created_by, document_description, document_folder_id, document_name,
- document_updated_at, folder_name, user_name FROM documents
- LEFT JOIN folders ON document_folder_id = folder_id
- LEFT JOIN users ON document_created_by = user_id
+$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT document_archived_at, document_client_visible, document_content, document_created_at,
+ document_description, document_folder_id, document_name, document_updated_at,
+ creator.user_name AS created_by_name, updater.user_name AS updated_by_name
+ FROM documents
+ LEFT JOIN users creator ON document_created_by = creator.user_id
+ LEFT JOIN users updater ON document_updated_by = updater.user_id
WHERE document_client_id = $client_id AND document_id = $document_id
- LIMIT 1"
-);
+ LIMIT 1"));
-if (mysqli_num_rows($sql_document) == 0) {
- echo "
Nothing to see here
Go Back";
+if (!$row) {
+ echo "
Nothing to see here
Back to files";
require_once "../includes/footer.php";
exit();
}
-$row = mysqli_fetch_assoc($sql_document);
+$can_edit = lookupUserPermission('module_support') >= 2;
+$can_delete = lookupUserPermission('module_support') >= 3;
-$folder_name = escapeHtml($row['folder_name']);
$document_name = escapeHtml($row['document_name']);
$document_description = escapeHtml($row['document_description']);
-$document_content = $purifier->purify($row['document_content']);
-$document_created_by_id = intval($row['document_created_by']);
-$document_created_by_name = escapeHtml($row['user_name']);
-$document_created_at = escapeHtml($row['document_created_at']);
-$document_updated_at = escapeHtml($row['document_updated_at']);
-$document_archived_at = escapeHtml($row['document_archived_at']);
-$document_folder_id = intval($row['document_folder_id']);
-$document_client_visible = intval($row['document_client_visible']);
+$document_archived = !empty($row['document_archived_at']);
+$document_visible = intval($row['document_client_visible']);
+$document_updated_at = $row['document_updated_at'] ?: $row['document_created_at'];
+$document_updated_by = escapeHtml($row['updated_by_name'] ?: $row['created_by_name']);
-// Override Tab Title // No Sanitizing needed as this var will opnly be used in the tab title
+$folder_tree = folderTree($client_id);
+$document_folder_id = isset($folder_tree[intval($row['document_folder_id'])]) ? intval($row['document_folder_id']) : 0;
+$folder_path = folderPath($folder_tree, $document_folder_id);
+
+$versions = [];
+$sql_versions = mysqli_query($mysqli, "SELECT document_version_id, document_version_name, document_version_description, document_version_created_at, user_name
+ FROM document_versions LEFT JOIN users ON document_version_created_by = user_id
+ WHERE document_version_document_id = $document_id
+ ORDER BY document_version_created_at DESC, document_version_id DESC");
+while ($version = mysqli_fetch_assoc($sql_versions)) {
+ $versions[] = $version;
+}
+
+$csrf = $_SESSION['csrf_token'];
+
+// Tab title - used raw, the header escapes it
$page_title = $row['document_name'];
?>
- -
- = $client_name ?>
-
- -
- Files
-
- 0) {
- $sql_folder = mysqli_query($mysqli, "SELECT folder_name, parent_folder FROM folders WHERE folder_id = $folder_id");
- if ($row_folder = mysqli_fetch_assoc($sql_folder)) {
- $folder_name = escapeHtml($row_folder['folder_name']);
- $parent_folder = intval($row_folder['parent_folder']);
-
- // Prepend the folder to the beginning of the array
- array_unshift($folder_path, array('folder_id' => $folder_id, 'folder_name' => $folder_name));
-
- // Move up to the parent folder
- $folder_id = $parent_folder;
- } else {
- // If the folder is not found, break the loop
- break;
- }
- }
-
- // Output breadcrumb items for each folder in the path
- foreach ($folder_path as $folder) {
- $bread_crumb_folder_id = $folder['folder_id']; // Sanitized before put in array
- $bread_crumb_folder_name = $folder['folder_name']; // Sanitized before put in array
- ?>
- -
-
- = $bread_crumb_folder_name ?>
-
-
-
- -
- = $document_name ?>
- (ARCHIVED on $document_archived_at)";
- } ?>
-
+ - = $client_name ?>
+ - Files
+
+ - = escapeHtml($crumb['folder_name']) ?>
+
+ - = $document_name ?>
+
+
+
+ = documentTile('lg') ?>
+
+
+ = $document_name ?>
+ Archived
+ Portal
+
+
+
= $document_description ?>
+
+
+
Updated = timeAgo($document_updated_at) ?>= $document_updated_by ? " by $document_updated_by" : '' ?>
+ · Created = date('M j, Y', strtotime($row['document_created_at'])) ?>= $row['created_by_name'] ? ' by ' . escapeHtml($row['created_by_name']) : '' ?>
+ ·
= count($versions) ?> earlier version= count($versions) === 1 ? '' : 's' ?>
+
+
+
+
+
+
+
+
+
+
PDF
+
+
+
+
+
+
+
+
+
+
+