diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48a2231bb..6606d671f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,7 @@ Update from Maintenance > Update as usual. This release has two database changes
- Admin > Warranty Lookup, under Integrations, sets up each maker. Dell needs a TechDirect Warranty API key and HP an HP Warranty API key, which each approve by hand - HP doesn't give its to every IT company. Lenovo needs none: ITFlow asks Lenovo's support site as its own pages do, which can stop working when Lenovo changes the site. **Save and test** beside each one tries a serial number with what you've entered. HP works through each lookup as a job, so its answers can take a few minutes. It's part of IT documentation, and goes with it when that module is off.
- Upload a `.md` file and it becomes a document written in Markdown, that you can edit, in the folder it goes into - with **Upload** or by dropping it on the list, no import step. Upload the pictures it uses with it - pick them together, or upload the folder they're in - and they go into the document, found where its links say or by their name; a picture no file uses uploads as a file. A zip of Markdown pages, such as an export from Notion, Obsidian or Confluence, is opened in the Upload window and brought in as the folder it holds: each page a document in its folder with its pictures, its other files uploaded beside them, and Notion's IDs taken off the names. Afterwards ITFlow says which pictures a file uses that weren't uploaded with it, to add in the editor. The Upload window says what will become a document, and **Keep them as files** uploads the `.md` files as they are and a zip as a zip.
- A `.md` already in Files shows as it reads in its preview and quick look, with its pictures that are in the client's files, and **Make it a document**, in its menu and quick look, makes it a document: the pictures it uses are copied in, and the document takes the file's place and its links.
+- Copy a Knowledge Base article's link from its **⋮** menu, on its page or beside it in the list - to send it to someone, or to link to it from another article. It offers the links that suit who can read it: **Copy Public Link** for an article for anyone, **Copy Portal Link** for one in the client portal, and **Copy Link** to its page here for one for agents only. A link that won't open yet is greyed out with the reason under it, such as **Publish it first** or **The public help center is off**. Agents who can read articles but not edit them get the menu with these links too.
### Bug Fixes
@@ -49,6 +50,7 @@ Update from Maintenance > Update as usual. This release has two database changes
- Markdown uploads: `functions/markdown_upload.php`. `upload_files` (`agent/post/file.php`) collects an upload's .md files and pictures (`markdownUploadExtensions()`, `markdownPictureExtensions()`) and hands them to `markdownUploadConvert($client_id, $file_ids, $folders_made)` at its end; a folder sent in parts keeps them in `$_SESSION['upload_batches'][upload_batch]` until `upload_folder_done`, which now answers `go` - the document's address when one document is all it made. `markdown_keep` turns it off. `markdownFileToDocument()` makes each document with `markdownImportSplit()`, `markdownSaveImages()` and `markdownRewritePictures($markdown, $find)` - ``, ``, `[id]: target` for a picture and Obsidian's `![[name]]`, code blocks left alone - finding each with `markdownFindPicture()`: through the folder tree from the .md's folder (`markdownPathFolder()`, `..` included, folder names with or without Notion's ID), then by a name only one picture has. `markdownCopyPicture()` checks it with `getimagesizefromstring()` and stores it under `uploads/documents//` by its real type. The file's links move to the document through `linkAdd()`; the .md and the pictures used go (`markdownUploadRemoveFile()`), and so do folders the upload made that are left empty (`markdownUploadRemoveEmptyFolders()`). `folderForUploadPath()` takes `&$made_ids` and drops Notion's 32-character ID from a folder's name (`markdownNotionName()`).
- `js/zip_reader.js` - `window.itflowZip.list(file)` reads a zip's central directory, `.unpack(file, entry)` takes a file out, inflating with `DecompressionStream('deflate-raw')`; no zip64 or encrypted entries. The upload window sends a zip with Markdown pages as the folder it holds, through the folder upload, so PHP's zip extension isn't needed. Make it a document: `agent/modals/file/file_make_document.php`, `make_file_document`, `markdownFileMakeDocument()`. `get_file_markdown` (`agent/ajax.php`) and `fileMarkdownPreviewHtml()` render an uploaded .md - its pictures in Files as `file.php` links - for the grid previewer (`kind: 'markdown'`) and the file quick look. `agent/modals/document/document_import_markdown.php` and `import_markdown_documents` are removed. `fileUploadExtensions()` takes `.markdown`, and `fileTypeInfo()` calls `.md` Markdown.
- `purifierUriSchemes()` (`functions/sanitize.php`) is the one list of address schemes HTMLPurifier lets through - `http`, `https`, `mailto`, `tel` and `data` - for `documentHtmlPurify()` and the ticket views (`agent/ticket.php`, `agent/modals/ticket/ticket.php`, `client/ticket.php`, `guest/guest_view_ticket.php`, `guest/guest_approve_ticket_task.php`), each of which set `http`/`https`/`data` only. HTMLPurifier still checks each: a `mailto:` must be an address, a `tel:` is cut down to its digits, and `javascript:`, `vbscript:`, `file:` and the rest go. Database 4.4.5 makes `document_content` and `kb_article_content` (with their `_raw` search text) again from the Markdown of those with `mailto:` or `tel:` in it, keeping `_updated_at`; it stops, to be run again, if the process still has the functions from before it.
+- `kbCopyLinks($row)` (`functions/kb.php`) gives an article's links for its readers - `[label, icon, url, why not, what it is]`, from `kbPublicUrl()`, `kbPortalArticleUrl()` and the new `kbAgentArticleUrl()` - with why one won't open yet (a draft, `kbPublicOn()` or `moduleOn('portal')` off); `kbCopyLinksMenuHtml()` makes them `.clipboardjs` dropdown items, or disabled ones with the reason in `.itflow-dropdown-why`. `agent/kb_article.php` and the rows of `agent/kb.php` show their ⋮ menu for `kbCan(1)` as well as `kbCan(2)` - with only these items for those who can't edit.
## [26.12.5]
diff --git a/agent/kb.php b/agent/kb.php
index 2b2bb73a1..7db1e628d 100644
--- a/agent/kb.php
+++ b/agent/kb.php
@@ -327,11 +327,17 @@ $csrf = $_SESSION['csrf_token'];
-
+
+ = kbCopyLinksMenuHtml($copy_links) ?>
+
+
+
+
Make Draft
@@ -142,7 +148,7 @@ $page_title = $row['kb_article_title'];
CopyArchive
-
+
Restore
diff --git a/css/itflow_custom.css b/css/itflow_custom.css
index 0119006fe..1c854d9d1 100644
--- a/css/itflow_custom.css
+++ b/css/itflow_custom.css
@@ -5339,6 +5339,14 @@ tr:hover .itflow-files-rename,
padding: .2rem .25rem;
border-bottom: 1px solid var(--bs-border-color-translucent);
}
+/* A menu item that can't be used yet, and why - under its label, lined up with it */
+.dropdown-item .itflow-dropdown-why {
+ display: block;
+ padding-left: calc(1.25em + .5rem);
+ font-size: .8125rem;
+ white-space: normal;
+}
+
/* What becomes a document - .md files, and zips of Markdown pages */
.itflow-upload-markdown {
padding: .65rem .8rem;
diff --git a/functions/kb.php b/functions/kb.php
index 531b5a572..d78841314 100644
--- a/functions/kb.php
+++ b/functions/kb.php
@@ -122,6 +122,50 @@ function kbPortalArticleUrl($kb_article_id) {
return "https://$config_base_url/client/kb_article.php?id=" . intval($kb_article_id);
}
+/** An article's page for agents - for your team, and to link to it from an article only agents read. */
+function kbAgentArticleUrl($kb_article_id) {
+ global $config_base_url;
+ return "https://$config_base_url/agent/kb_article.php?kb_article_id=" . intval($kb_article_id);
+}
+
+/**
+ * An article's links to copy, for whoever reads it - [[label, icon, url, why not, what it is]]:
+ * the public help center's and the portal's for one for anyone, the portal's for clients, its
+ * agent page for agents only. One that won't open for its readers yet has why (a draft, the public
+ * help center or the client portal switched off); an archived article has none.
+ */
+function kbCopyLinks(array $row) {
+ if (!empty($row['kb_article_archived_at'])) {
+ return [];
+ }
+ $id = intval($row['kb_article_id']);
+ $visibility = $row['kb_article_visibility'] ?? 'agents';
+ $draft = empty($row['kb_article_published_at']) ? 'Publish it first' : '';
+ $links = [];
+ if ($visibility === 'public') {
+ $links[] = ['Copy Public Link', 'fa-globe', kbPublicUrl($id, $row['kb_article_title']), $draft ?: (kbPublicOn() ? '' : 'The public help center is off'), 'Anyone can open it, signed in or not'];
+ }
+ if ($visibility === 'public' || $visibility === 'clients') {
+ $links[] = ['Copy Portal Link', 'fa-users', kbPortalArticleUrl($id), moduleOn('portal') ? $draft : 'The client portal is off', 'In the client portal - a contact signs in to read it'];
+ }
+ if ($visibility === 'agents') {
+ $links[] = ['Copy Link', 'fa-link', kbAgentArticleUrl($id), '', 'This page, for your team'];
+ }
+ return $links;
+}
+
+/** kbCopyLinks() as items for an article's menu - a link copies when clicked, one that won't open yet shows why. $icon_class tints the icons as the rest of the menu's are. */
+function kbCopyLinksMenuHtml(array $links, $icon_class = '') {
+ $html = '';
+ foreach ($links as [$label, $icon, $url, $why, $what]) {
+ $icon_html = '';
+ $html .= $why === ''
+ ? '' . $icon_html . $label . ''
+ : '' . $icon_html . $label . ' ' . escapeHtml($why) . '';
+ }
+ return $html;
+}
+
/** Has a client's portal anything under Help - an article it may read? */
function kbClientHas($client_id) {
global $mysqli;