Copy a Knowledge Base article's link from its menu on its page and in the list: Copy Public Link, Copy Portal Link or Copy Link to its agent page by who can read it, with one that won't open yet greyed out and saying why, and the menu shown with just these to agents who can read articles but not edit them; 26.12.6 changelog

This commit is contained in:
johnnyq
2026-12-05 01:32:57 -05:00
parent 332b444c7b
commit de83a2d480
5 changed files with 72 additions and 6 deletions

View File

@@ -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)` - `![alt](target)`, `<img src>`, `[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/<id>/` 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]

View File

@@ -327,11 +327,17 @@ $csrf = $_SESSION['csrf_token'];
</td>
<?php } ?>
<td class="text-end">
<?php if ($can_edit) { ?>
<?php $copy_links = kbCopyLinks($row); ?>
<?php if ($can_edit || $copy_links) { ?>
<div class="dropdown dropstart">
<button class="btn btn-sm btn-light" title="More actions" type="button" data-bs-toggle="dropdown"><i class="fas fa-fw fa-ellipsis-v"></i></button>
<div class="dropdown-menu">
<?php if (!$row['kb_article_archived_at']) { ?>
<?php // Its links, for whoever reads it - to send, or to link to it from another article ?>
<?= kbCopyLinksMenuHtml($copy_links, 'text-secondary') ?>
<?php if ($copy_links && $can_edit) { ?>
<div class="dropdown-divider"></div>
<?php } ?>
<?php if ($can_edit && !$row['kb_article_archived_at']) { ?>
<a class="dropdown-item ajax-modal" href="#" data-modal-size="xl" data-modal-url="modals/kb/kb_article_edit.php?id=<?= $kb_article_id ?>">
<i class="fas fa-fw fa-edit text-secondary me-2"></i>Edit
</a>
@@ -354,7 +360,7 @@ $csrf = $_SESSION['csrf_token'];
<a class="dropdown-item text-danger" href="post.php?archive_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } else { ?>
<?php } elseif ($can_edit) { ?>
<a class="dropdown-item" href="post.php?restore_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>">
<i class="fas fa-fw fa-redo text-secondary me-2"></i>Restore
</a>

View File

@@ -42,6 +42,7 @@ $review = kbReviewState($row);
$audience = kbAudiencesFor([$kb_article_id])[$kb_article_id];
$visibility = isset(KB_VISIBILITY[$row['kb_article_visibility']]) ? $row['kb_article_visibility'] : 'agents';
$public_url = kbPublicUrl($kb_article_id, $row['kb_article_title']);
$copy_links = kbCopyLinks($row);
$versions = [];
$sql_versions = mysqli_query($mysqli, "SELECT kb_article_version_id, kb_article_version_title, kb_article_version_created_at, user_name
@@ -128,11 +129,16 @@ $page_title = $row['kb_article_title'];
<button type="button" class="dropdown-item" onclick="window.print();"><i class="fas fa-fw fa-print me-2"></i>Print</button>
</div>
</div>
<?php if ($can_edit) { ?>
<?php if ($can_edit || $copy_links) { ?>
<div class="dropdown">
<button type="button" class="btn btn-outline-secondary" data-bs-toggle="dropdown" title="More actions"><i class="fas fa-ellipsis-v"></i></button>
<div class="dropdown-menu dropdown-menu-end">
<?php if (!$archived) { ?>
<?php // Its links, for whoever reads it - one that won't open yet says why ?>
<?= kbCopyLinksMenuHtml($copy_links) ?>
<?php if ($copy_links && $can_edit) { ?>
<div class="dropdown-divider"></div>
<?php } ?>
<?php if ($can_edit && !$archived) { ?>
<?php if ($published) { ?>
<a class="dropdown-item" href="post.php?draft_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>" title="Back to a draft - not finished"><i class="fas fa-fw fa-pencil-alt me-2"></i>Make Draft</a>
<?php } ?>
@@ -142,7 +148,7 @@ $page_title = $row['kb_article_title'];
<a class="dropdown-item" href="post.php?copy_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>" title="A new draft starting from this one"><i class="far fa-fw fa-copy me-2"></i>Copy</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger" href="post.php?archive_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>"><i class="fas fa-fw fa-archive me-2"></i>Archive</a>
<?php } else { ?>
<?php } elseif ($can_edit) { ?>
<a class="dropdown-item" href="post.php?restore_kb_article=<?= $kb_article_id ?>&csrf_token=<?= $csrf ?>"><i class="fas fa-fw fa-redo me-2"></i>Restore</a>
<?php } ?>
<?php if ($can_delete) { ?>

View File

@@ -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;

View File

@@ -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 = '<i class="fas fa-fw ' . $icon . ($icon_class !== '' ? " $icon_class" : '') . ' me-2"></i>';
$html .= $why === ''
? '<a class="dropdown-item clipboardjs" href="#" data-clipboard-text="' . escapeHtml($url) . '" title="' . escapeHtml($what) . '">' . $icon_html . $label . '</a>'
: '<span class="dropdown-item disabled" aria-disabled="true">' . $icon_html . $label . ' <span class="itflow-dropdown-why">' . escapeHtml($why) . '</span></span>';
}
return $html;
}
/** Has a client's portal anything under Help - an article it may read? */
function kbClientHas($client_id) {
global $mysqli;