mirror of
https://github.com/itflow-org/itflow
synced 2026-12-04 01:59:00 +00:00
53 lines
2.3 KiB
PHP
53 lines
2.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* API - Knowledge Base articles - Create
|
|
* POST /api/v1/kb_articles/create.php
|
|
*
|
|
* Write an article, as New Article does - a draft for agents only unless it says otherwise.
|
|
*
|
|
* Parameters (POST, JSON body):
|
|
* api_key required - Your API key
|
|
* kb_article_title required - Up to 200 characters
|
|
* kb_article_content optional - What it says, as HTML. Pictures in it as data: URLs are saved as files
|
|
* kb_article_markdown optional - What it says in Markdown, instead - it is written in Markdown,
|
|
* and kb_article_content is made from it
|
|
* kb_article_summary optional - One line on what it helps with, up to 255 characters
|
|
* kb_article_category_id optional - A Knowledge Base category (categories/read.php?kind=kb)
|
|
* kb_article_review_months optional - How often it is reviewed: 0 (never), 3, 6, 12 (the default) or 24
|
|
* kb_article_published optional - 1 to publish it; a draft otherwise
|
|
* kb_article_visibility optional - agents (the default), clients or public
|
|
* kb_article_all_clients optional - 1: every client, for clients
|
|
* kb_article_client_tag_ids optional - For clients: the clients with these client tags
|
|
* kb_article_client_ids optional - For clients: these clients
|
|
* tags optional - Its tags - ids or names, as an array or comma-separated
|
|
*
|
|
* Shared with clients, it needs kb_article_all_clients, kb_article_client_tag_ids or
|
|
* kb_article_client_ids. Returns the new article's id.
|
|
*/
|
|
|
|
require_once '../validate_api_key.php';
|
|
|
|
require_once '../require_post_method.php';
|
|
|
|
require_once 'kb_article_model.php';
|
|
|
|
$insert_id = false;
|
|
|
|
[$fields, $error] = kbApiFields($_POST);
|
|
if ($error !== '') {
|
|
kbApiFail($error);
|
|
}
|
|
|
|
$insert_id = kbArticleSave($fields);
|
|
if (isset($_POST['tags'])) {
|
|
tagSetForRecord('kb_article', $insert_id, kbApiList($_POST['tags']));
|
|
}
|
|
|
|
$title = escapeSql($fields['title']);
|
|
logAudit("Knowledge Base", "Create", "$session_name wrote " . ($fields['published'] ? '' : 'a draft of ') . "article $title via API ($api_key_name)", 0, $insert_id);
|
|
logAudit("API", "Success", "Created Knowledge Base article $title via API ($api_key_name)", 0);
|
|
|
|
// Output
|
|
require_once '../create_output.php';
|