diff --git a/CHANGELOG.md b/CHANGELOG.md index 291611932..a6136a1ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,8 @@ Update from Maintenance > Update as usual. This release has two database changes - Cron leaves alone the jobs that have nothing to do on your ITFlow - what they work with is switched off or isn't set up: AI Triage, Text Messages, RMM Sync and RMM Alerts, the Ticket Email Parser with email to ticket off or no mailbox, the Mail Queue with no mail server, Payment Provider Fees without Stripe, the Update Check on an install that isn't a git checkout, and Manager Check-in and Managed Instances when there's nothing connected. Before, each one started every minute only to stop itself. Maintenance > Cron shows them as **Not in use**, with why under each; they start by themselves once that changes, and **Run Now** still runs them. Cron Watch doesn't email about them falling behind. - An API / service account no longer takes a seat on the agent user limit - the one your hosting provider sets, or one set for your installation. Nobody signs in as it: it's the login an integration's API keys act as. You can add one, enable one or restore one when every seat is taken, and Admin > Users shows the seats without them. Turning one back into an agent who signs in takes a seat, so there has to be one free. A hosted instance's manager sees it the same way: its seats taken leave API accounts out, and its list of agents marks them. - Unlock your credentials with a passkey. When a passkey sign-in leaves them locked although your passkey opens them - signing in by scanning a QR code with your phone, or some password managers' autofill - the Unlock window offers **Unlock with a Passkey** before your password, with any passkey of yours that opens them. It's there while passkeys are on in Admin > Settings > Security. -- Knowledge Base articles can be written in Markdown, as documents can. New and Edit Article have the same **Rich text** / **Markdown** switch and Markdown toolbar with Write and Preview, and switching either way converts what's written. A new article starts the way you wrote last. Saved versions keep their Markdown, so putting one back brings back what was written then. **Import Markdown Files**, in the New Article menu, makes each .md file an article - a draft for agents only, in the category you pick - and **Export** on an article now has **Markdown (.md)** beside PDF. A document written in Markdown copied into the Knowledge Base arrives in Markdown, and with Write up for the Knowledge Base in Markdown the AI's draft comes in as Markdown. The client portal, the public help center, search, ticket replies and PDFs show a Markdown article like any other. +- Knowledge Base articles can be written in Markdown, as documents can. New and Edit Article have the same **Rich text** / **Markdown** switch and Markdown toolbar with Write and Preview, and switching either way converts what's written. A new article starts the way you wrote last. Saved versions keep their Markdown, so putting one back brings back what was written then. **Import Markdown Files**, in the New Article menu, makes each .md file an article - a draft for agents only, in the category you pick - and **Export** on an article now has **Markdown (.md)** beside PDF. A document written in Markdown copied into the Knowledge Base arrives in Markdown, and with Write up for the Knowledge Base in Markdown the AI's draft comes in as Markdown. The client portal, the public help center, search, ticket replies and PDFs show a Markdown article like any other - its tables keep their lines in an emailed reply too. +- The Knowledge Base is in the API. An integration can find articles - by words, category, who can read them, drafts, or what a client's portal shows - and write, change, archive and delete them, in rich text or Markdown, with who can read them, their category, review and tags. A change keeps the version before, as in ITFlow. It takes Support in the key's role, and Full to delete. See the API reference under Tickets. - Password managers fill your password in the Unlock window. Bitwarden and the like offer the ITFlow password they keep for signing in, as they do on the sign-in page - handy where your passkey can't open your credentials itself, as with passkeys kept in Bitwarden. ### Bug Fixes @@ -33,6 +34,7 @@ Update from Maintenance > Update as usual. This release has two database changes - Cron and runs outside it (database 4.4.2, `cron_jobs.cron_job_outside_at`): `cron/includes/cron_lock.php` gains `cronLockFile()`, `cronLockHolder()`, `cronLockFileProblem()`, `cronLockDispatchBeat()`, `cronLockOutsideFile()`, `cronLockAttended()` and `cronLockRunAsOwner()`, run first: started as root on an install whose `cron/cron.php` is another user's, it calls `posix_initgroups()`, `posix_setgid()` and `posix_setuid()` to become that user, or exits saying how to run it. `cronLockAcquire($path, $stamp)` returns null for a lock file it can't open (it used to `die()`, ending the dispatch at that job), and writes `direct` or `terminal` into the file while a run on its own holds it. The dispatcher touches the heartbeat file each cycle; a run on its own without a terminal on STDIN (`stream_isatty()`) while it is under 180 seconds old exits 0, quietly, and touches its `.outside` file. The dispatcher records that file's time, or a lock found held by a `direct` run, as `cron_job_outside_at` (`cronJobNoteOutside()`, at most every ten minutes), and fails a job whose lock can't be opened with `cronLockFileProblem()` as its error (`cronJobLockFailed()`, logged to App Logs once). `functions/cron_health.php`: `cronStrayLines()` reads `/etc/crontab` and the `/etc/cron.d` files cron would read for lines that run this install's job scripts on their own (anything in `cron/` but `cron.php`, and the old `scripts/cron*.php` and `cron_*.php`), `cronStrayText()`, `cronStrayWhat()`, `cronOutsideJobs()` (the last `CRON_HEALTH_OUTSIDE_HOURS`, 26), `cronOutsideReady()` and `cronFilesOwner()`; `cronHealthProblems()` adds a `stray` problem and an `outside` one per job the lines don't cover, and doesn't call a job overdue while it is run outside. `health.php` leaves both kinds out, so an uptime monitor doesn't go red for them. Maintenance > Cron has a card for the lines (`data-cron-stray`, `data-cron-stray-line`) and a note on each job run outside (`data-cron-outside`); Debug's Background jobs adds Old cron lines. CONTRIBUTING.md has the rule. - Passkeys sealed to the vault after they were added (`functions/passkey.php`, no database change): `login_passkey.php` keeps a passkey's PRF result for the session when it has no `passkey_vault` that opens with it - `passkeySealKeep()`, AES-256-GCM in `$_SESSION['passkey_seal']` with its key in the httponly `passkey_seal_key` cookie, set as `user_encryption_session_key` is - and once the vault opens, `vaultUnlock()` or the new `vaultUnlockPasskey()` seals the vault key to it (`passkeySealKept()`, checked to open before `passkey_vault` is written; the kept secret is dropped either way, and logout clears the cookie). `vaultUnlockPasskey()` checks an assertion for the new `unlock` challenge purpose against the signed-in agent's own passkeys - `passkeyVerify($post, $purpose, $user_id)`, which `passkeyVerifySignIn()` now wraps - and opens the vault with its PRF result; a passkey whose copy doesn't open with it keeps that result for the password to seal. `passkeyUnlockOptions()`, `passkeyVaultCount()` and `passkeySealPending()` feed the Unlock window (`includes/footer.php`, `[data-vault-unlock-passkey]`), and `agent/ajax.php` adds `vault_unlock_passkey_options` and `vault_unlock_passkey` (POST, CSRF). `js/passkey.js` handles the button, runs once per page (`window.itflowPasskeys`) and fires `itflow:vault-unlocked` on `#vaultUnlockModal`, which `js/credentials.js` now listens for. A passkey that doesn't unlock is logged as Login / Unlock Failed. `vaultLockedReason()` for a passkey sign-in now reads "your passkey sign-in didn't open them". The Unlock window's form drops `autocomplete="off"` and carries the agent's email in a hidden `autocomplete="username"` field (as `join.php` does), so password managers match it to the sign-in they keep. - Knowledge Base articles in Markdown (database 4.4.3): `kb_articles.kb_article_markdown` and `kb_article_versions.kb_article_version_markdown` (NULL for rich text), with `kbMarkdownReady()`, `kbMarkdownSql()` and `kbMarkdownSet()` in `functions/kb.php`. `kbArticleFields()` reads `format` and `markdown`; `kbArticleSave()` takes `markdown` and stores `kb_article_content` as `markdownToHtml()` of it, so every reader of `kb_article_content` is unchanged; `kbKeepVersion()`, the version restore, `copy_kb_article` and `kbArticleFromDocument()` carry it (with picture paths moved to the new article's folder). `markdownSaveImages()` takes a third `$folder` ('kb' for `uploads/kb//`). `includes/document_editors.php` takes `$document_editor_rich_class` and `$document_editor_markdown_ready`, which `agent/modals/kb/kb_article_form.php` sets to keep `.tinymce` and `kbMarkdownReady()`. New: `export_kb_article_markdown` and `import_markdown_kb_articles` in `agent/post/kb.php` and `agent/modals/kb/kb_import_markdown.php`. The write-up from a ticket uses `itflowDocumentFormat.putHtml()` when its form is in Markdown. +- Knowledge Base API (`api/v1/kb_articles/`): `read.php` (`kb_article_id` with its versions, or a list by `q`, `category_id`, `visibility`, `published`, `client_id` - what that client's portal shows - and `archived`), `create.php`, `update.php`, `archive.php`, `unarchive.php` and `delete.php` over `functions/kb.php`, and `categories/read.php` takes `kind=kb` - `kbApiFields()` in `kb_article_model.php` maps the API's `kb_article_*` fields onto `kbArticleFields()` over the article as it stands, `kbArticleSave()` saves (versions and Markdown as on the pages), and `kbApiRow()` gives typed rows with the audience, review state, public address and, for one article, `kbApiVersions()`. The endpoints answer 403 while the Knowledge Base module is off, and 400 or 404 with what was wrong. `enforce_api_rbac.php` maps `kb_articles` to `module_support` and leaves it out of the write target-client check (`$resource_without_client`); a limited agent's update keeps the clients it can't reach, which its reads don't show. `kbArticleRow()`'s query is `kbArticleSelectSql()`, shared with the list. `kbArticleReplyHtml()` gives a `table-bordered` table `border="1"`, `cellpadding` and `border-collapse` for email. ## [26.12.4] diff --git a/api/v1/categories/read.php b/api/v1/categories/read.php index 6088c7423..734376f32 100644 --- a/api/v1/categories/read.php +++ b/api/v1/categories/read.php @@ -11,7 +11,7 @@ * api_key required - Your API key * kind optional - Expense, Income, Referral, Ticket, network_interface, * asset_status, software_type, rack_type, - * contact_note_type or asset_note_type (or what + * contact_note_type, kb or asset_note_type (or what * Admin > Categories calls it - "Asset Status"), * in any case * category_id optional - One category, archived or not @@ -31,7 +31,7 @@ * * Only the kinds whose records the key's user can read - expense categories * need Financial, income categories Sales or Financial, referrals and contact - * note types Clients, the rest Support. + * note types Clients, the rest - Knowledge Base categories (kb) among them - Support. */ require_once '../validate_api_key.php'; diff --git a/api/v1/enforce_api_rbac.php b/api/v1/enforce_api_rbac.php index 46b6ab438..36e5abab6 100644 --- a/api/v1/enforce_api_rbac.php +++ b/api/v1/enforce_api_rbac.php @@ -163,6 +163,8 @@ $resource_module = [ 'tasks' => 'module_support', 'task_approvals' => 'module_support', 'recurring_tickets' => 'module_support', + // Knowledge Base articles - api/v1/kb_articles/ also wants the Knowledge Base switched on (kbOn()) + 'kb_articles' => 'module_support', 'clients' => 'module_client', 'contacts' => 'module_client', 'contact_notes' => 'module_client', @@ -272,7 +274,10 @@ $client_id_supplied = isset($_POST['client_id']) || isset($_GET['client_id']); // client's record just as update does, so they name a client the user can reach too. // Listing the reads, not the writes, keeps a new kind of write from slipping past. $is_write = !in_array($operation_file, ['read.php', 'time.php', 'download.php'], true); -if ($is_write && !apiUserCanAccessClient($client_id)) { +// Records that are no client's - Knowledge Base articles - take no target client, as on their pages: +// an agent limited to some clients writes them there too +$resource_without_client = ['kb_articles']; +if ($is_write && !in_array($resource, $resource_without_client, true) && !apiUserCanAccessClient($client_id)) { // Writes act on a single client the caller names (client_id 0 = a global record). // The user must be able to access it - this also blocks a restricted user from // writing global (client_id 0) records, which their access does not include. diff --git a/api/v1/kb_articles/archive.php b/api/v1/kb_articles/archive.php new file mode 100644 index 000000000..dd9bf428b --- /dev/null +++ b/api/v1/kb_articles/archive.php @@ -0,0 +1,37 @@ + Settings > Modules. + */ + +isset($mysqli) || die("Direct file access is not allowed"); + +require_once __DIR__ . '/../../../includes/load_global_settings.php'; + +// The Knowledge Base switched off +if (!kbOn()) { + http_response_code(403); + echo json_encode(['success' => 'False', 'message' => moduleOffText('kb')]); + exit(); +} + +/* A call that can't be done - its status and why, and stop. */ +function kbApiFail($message, $status = 400) { + http_response_code($status); + echo json_encode(['success' => 'False', 'message' => $message]); + exit(); +} + +/* A list sent as an array or comma-separated - its trimmed, non-empty values. */ +function kbApiList($value) { + $values = is_array($value) ? $value : explode(',', (string) $value); + return array_values(array_filter(array_map(function ($v) { + return trim((string) $v); + }, $values), 'strlen')); +} + +/* 1, true, "yes" - on; anything else off. */ +function kbApiOn($value) { + return in_array(strtolower(trim(var_export($value, true), "'")), ['1', 'true', 'yes', 'on'], true); +} + +/* + * One article as the API gives it - $row from kbArticleRow() or kbArticleSelectSql(), $audience + * from kbAudiencesFor(). Clients it is shared with by name are the ones the key's user can reach. + * $versions, for one article asked for: its earlier versions, newest first. + */ +function kbApiRow(array $row, array $audience, $versions = null) { + $review = kbReviewState($row); + $published = !empty($row['kb_article_published_at']); + $public = $published && empty($row['kb_article_archived_at']) && $row['kb_article_visibility'] === 'public' && kbPublicOn(); + $out = [ + 'kb_article_id' => intval($row['kb_article_id']), + 'kb_article_title' => $row['kb_article_title'], + 'kb_article_summary' => (string) $row['kb_article_summary'] !== '' ? $row['kb_article_summary'] : null, + 'kb_article_content' => (string) $row['kb_article_content'], + 'kb_article_markdown' => $row['kb_article_markdown'] ?? null, + 'kb_article_format' => ($row['kb_article_markdown'] ?? null) !== null ? 'markdown' : 'html', + 'kb_article_category_id' => intval($row['kb_article_category_id']), + 'kb_article_category_name' => intval($row['kb_article_category_id']) > 0 ? ($row['category_name'] ?? null) : null, + 'kb_article_published_at' => $row['kb_article_published_at'] ?? null, + 'kb_article_visibility' => $row['kb_article_visibility'], + 'kb_article_all_clients' => intval($row['kb_article_all_clients']) === 1, + 'kb_article_client_tag_ids' => array_map('intval', array_column($audience['tags'] ?? [], 'tag_id')), + 'kb_article_client_ids' => array_values(array_filter(array_map('intval', array_keys($audience['clients'] ?? [])), 'hasClientAccess')), + 'kb_article_review_months' => intval($row['kb_article_review_months']), + 'kb_article_reviewed_at' => $row['kb_article_reviewed_at'] ?? null, + 'kb_article_next_review' => $review ? $review['next'] : null, + 'kb_article_review_due' => $review ? (bool) $review['due'] : false, + 'kb_article_views' => intval($row['kb_article_views'] ?? 0), + 'kb_article_created_at' => $row['kb_article_created_at'], + 'kb_article_created_by' => intval($row['kb_article_created_by']), + 'kb_article_created_by_name' => $row['created_by_name'] ?? null, + 'kb_article_updated_at' => $row['kb_article_updated_at'] ?? null, + 'kb_article_updated_by' => intval($row['kb_article_updated_by']), + 'kb_article_updated_by_name' => $row['updated_by_name'] ?? null, + 'kb_article_archived_at' => $row['kb_article_archived_at'] ?? null, + 'kb_article_public_url' => $public ? kbPublicUrl($row['kb_article_id'], $row['kb_article_title']) : null, + ]; + if ($versions !== null) { + $out['kb_article_versions'] = $versions; + } + return $out; +} + +/* An article's earlier versions, newest first - when each was saved, by whom, its title and whether it was in Markdown. */ +function kbApiVersions($kb_article_id) { + global $mysqli; + $versions = []; + $sql = mysqli_query($mysqli, "SELECT kb_article_version_id, kb_article_version_title, kb_article_version_created_at, kb_article_version_created_by, + " . kbMarkdownSql('kb_article_version_markdown') . ", user_name + FROM kb_article_versions LEFT JOIN users ON user_id = kb_article_version_created_by AND kb_article_version_created_by > 0 + WHERE kb_article_version_kb_article_id = " . intval($kb_article_id) . " + ORDER BY kb_article_version_created_at DESC, kb_article_version_id DESC"); + while ($sql && $row = mysqli_fetch_assoc($sql)) { + $versions[] = [ + 'kb_article_version_id' => intval($row['kb_article_version_id']), + 'kb_article_version_title' => $row['kb_article_version_title'], + 'kb_article_version_created_at' => $row['kb_article_version_created_at'], + 'kb_article_version_created_by' => intval($row['kb_article_version_created_by']), + 'kb_article_version_created_by_name' => $row['user_name'] ?? null, + 'kb_article_version_format' => $row['kb_article_version_markdown'] !== null ? 'markdown' : 'html', + ]; + } + return $versions; +} + +/* + * What kbArticleFields() reads, from what the API was sent, over the article as it stands ($row, + * kbArticleRow()) - or a new article's starting values: a draft for agents only, reviewed every + * year. Anything left out stays as it is. [fields, error]. + */ +function kbApiFields(array $post, $row = null) { + if ($row) { + $in = [ + 'title' => $row['kb_article_title'], + 'summary' => (string) $row['kb_article_summary'], + 'category_id' => intval($row['kb_article_category_id']), + 'review_months' => intval($row['kb_article_review_months']), + 'published' => !empty($row['kb_article_published_at']), + ] + kbAudienceFields($row); + // Clients already on it stay, even ones the key's user can't reach - as on the pages + $in['keep_client_ids'] = $in['client_ids']; + } else { + $in = ['title' => '', 'summary' => '', 'category_id' => 0, 'review_months' => 12, 'published' => false, + 'visibility' => 'agents', 'all_clients' => false, 'client_tag_ids' => [], 'client_ids' => [], 'keep_client_ids' => []]; + } + + if (array_key_exists('kb_article_title', $post)) { + $in['title'] = (string) $post['kb_article_title']; + } + if (array_key_exists('kb_article_summary', $post)) { + $in['summary'] = (string) $post['kb_article_summary']; + } + if (array_key_exists('kb_article_category_id', $post)) { + $category_id = intval($post['kb_article_category_id']); + if ($category_id > 0 && kbCategoryId($category_id) === 0) { + return [[], "kb_article_category_id $category_id isn't a Knowledge Base category - categories/read.php?kind=kb lists them, and 0 is none."]; + } + $in['category_id'] = max(0, $category_id); + } + if (array_key_exists('kb_article_review_months', $post)) { + $in['review_months'] = intval($post['kb_article_review_months']); + if (!isset(KB_REVIEW_MONTHS[$in['review_months']])) { + return [[], 'kb_article_review_months is how often it is reviewed: 0 (never), 3, 6, 12 or 24.']; + } + } + if (array_key_exists('kb_article_published', $post)) { + $in['published'] = kbApiOn($post['kb_article_published']); + } + + // Who can read it + if (array_key_exists('kb_article_visibility', $post)) { + $in['visibility'] = strtolower(trim((string) $post['kb_article_visibility'])); + if (!isset(KB_VISIBILITY[$in['visibility']])) { + return [[], 'kb_article_visibility is agents, clients or public.']; + } + } + if (array_key_exists('kb_article_all_clients', $post)) { + $in['all_clients'] = kbApiOn($post['kb_article_all_clients']); + } + if (array_key_exists('kb_article_client_tag_ids', $post)) { + $asked = array_map('intval', kbApiList($post['kb_article_client_tag_ids'])); + $missing = array_diff($asked, kbClientTagIds($asked)); + if ($missing) { + return [[], 'kb_article_client_tag_ids: ' . implode(', ', $missing) . " isn't a client tag - tags/read.php?kind=client lists them."]; + } + $in['client_tag_ids'] = $asked; + } + if (array_key_exists('kb_article_client_ids', $post)) { + $asked = array_map('intval', kbApiList($post['kb_article_client_ids'])); + $missing = array_diff($asked, kbClientIds($asked, $in['keep_client_ids'])); + if ($missing) { + return [[], 'kb_article_client_ids: ' . implode(', ', $missing) . " isn't a client the user linked to this API key can reach."]; + } + // The clients it is shared with that the key's user can't reach aren't in what they read (kbApiRow()), so they stay + $unseen = array_values(array_filter($in['keep_client_ids'], function ($id) { + return !hasClientAccess($id); + })); + $in['client_ids'] = array_values(array_unique(array_merge($asked, $unseen))); + } + + // What it says - in Markdown, as HTML, or as it is + if (array_key_exists('kb_article_markdown', $post)) { + if (!kbMarkdownReady()) { + return [[], 'Articles in Markdown come with database 4.4.3 - run the database update from Maintenance > Update first.']; + } + $in['format'] = 'markdown'; + $in['markdown'] = (string) $post['kb_article_markdown']; + } elseif (array_key_exists('kb_article_content', $post)) { + $in['content'] = (string) $post['kb_article_content']; + } elseif ($row && ($row['kb_article_markdown'] ?? null) !== null) { + $in['format'] = 'markdown'; + $in['markdown'] = $row['kb_article_markdown']; + } elseif ($row) { + $in['content'] = (string) $row['kb_article_content']; + } + + return kbArticleFields($in); +} + +/* The article named by kb_article_id - or a 404. */ +function kbApiArticle($kb_article_id) { + $row = kbArticleRow($kb_article_id); + if (!$row) { + kbApiFail('No Knowledge Base article has that kb_article_id.', 404); + } + return $row; +} diff --git a/api/v1/kb_articles/read.php b/api/v1/kb_articles/read.php new file mode 100644 index 000000000..56473c8dd --- /dev/null +++ b/api/v1/kb_articles/read.php @@ -0,0 +1,90 @@ + 0) { + $found = []; + while ($row = mysqli_fetch_assoc($sql)) { + $found[intval($row['kb_article_id'])] = $row; + } + $audiences = kbAudiencesFor(array_keys($found)); + $one = isset($_GET['kb_article_id']); + $rows = []; + foreach ($found as $kb_article_id => $row) { + $rows[] = kbApiRow($row, $audiences[$kb_article_id] ?? [], $one ? kbApiVersions($kb_article_id) : null); + } + $rows = tagApiAttach($rows, 'kb_article'); + echo json_encode(['success' => 'True', 'count' => count($rows), 'data' => $rows]); + exit(); +} + +// Output - nothing found +require_once '../read_output.php'; diff --git a/api/v1/kb_articles/unarchive.php b/api/v1/kb_articles/unarchive.php new file mode 100644 index 000000000..5b89fb9a9 --- /dev/null +++ b/api/v1/kb_articles/unarchive.php @@ -0,0 +1,36 @@ +]*\bclass="[^"]*\btable-bordered\b[^"]*"[^>]*)>#i', function ($m) { + if (preg_match('/\sborder\s*=/i', $m[1])) { + return $m[0]; + } + return ''; + }, $html); return preg_replace('#\b(src|href)="/?(uploads/kb/\d+/[^"]+)"#', '$1="https://' . $config_base_url . '/$2"', $html); } @@ -301,7 +309,12 @@ function kbClosedText($level = 1) { function kbArticleRow($kb_article_id) { global $mysqli; $kb_article_id = intval($kb_article_id); - return mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT kb_article_id, kb_article_title, kb_article_summary, kb_article_content, " . kbMarkdownSql() . ", kb_article_category_id, + return mysqli_fetch_assoc(mysqli_query($mysqli, kbArticleSelectSql() . " WHERE kb_article_id = $kb_article_id")) ?: null; +} + +/** How kbArticleRow() reads an article - for a WHERE of its own (the API's list, api/v1/kb_articles/read.php). */ +function kbArticleSelectSql() { + return "SELECT kb_article_id, kb_article_title, kb_article_summary, kb_article_content, " . kbMarkdownSql() . ", kb_article_category_id, kb_article_published_at, kb_article_visibility, kb_article_all_clients, kb_article_review_months, kb_article_reviewed_at, kb_article_reviewed_by, " . (kbFeedbackReady() ? 'kb_article_views' : '0 AS kb_article_views') . ", kb_article_created_at, kb_article_created_by, kb_article_updated_at, kb_article_updated_by, kb_article_archived_at, @@ -311,8 +324,7 @@ function kbArticleRow($kb_article_id) { LEFT JOIN categories ON category_id = kb_article_category_id AND kb_article_category_id > 0 LEFT JOIN users creator ON creator.user_id = kb_article_created_by AND kb_article_created_by > 0 LEFT JOIN users updater ON updater.user_id = kb_article_updated_by AND kb_article_updated_by > 0 - LEFT JOIN users reviewer ON reviewer.user_id = kb_article_reviewed_by AND kb_article_reviewed_by > 0 - WHERE kb_article_id = $kb_article_id")) ?: null; + LEFT JOIN users reviewer ON reviewer.user_id = kb_article_reviewed_by AND kb_article_reviewed_by > 0"; } /*