Repository navigation
feat(kb): endpoints for FAQ articles and categories (2.8.0) - #17
Merged
Merged
Conversation
List, create and change FAQ categories; search, read, create and change FAQ articles including internal/public/featured. No delete. Changes go through FAQ::update() and Category::update(); partial updates keep notes, help topics and attachments. Slugs for /kb/<slug> are read from the root .htaccess, never written. New permissions can_read_kb and can_write_kb. Also fixes the api/.htaccess cleanup on update, which left the task rules behind since 2.6.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Knowledge base endpoints for FAQ categories and articles (2.8.0):
GET kb-categories-list.php,POST kb-categories-create.php,PATCH kb-categories-update.php/{id}.jsonGET kb-faq-search.php(text, category, visibility, slug, paging),GET kb-faq-get.php/{id}.jsonPOST kb-faq-create.php,PATCH kb-faq-update.php/{id}.json(title, answer, category, notes, visibility)No delete. Hiding an article means
visibility: internal. New content is internal unless set otherwise.How
lib/Services/KbService.php; writes go throughFAQ::update()/Category::update(), so HTML is sanitized like in the staff UI and duplicates are refused.FAQ::update()would otherwise clear notes and help topics.RewriteRule ^kb/<slug>$ kb/faq.php?id=<ID>in the root.htaccess(fixed path, size cap). Responses carryslug,publicUrl,visibleInPortal.can_read_kb,can_write_kb(default off), rendered and saved with the task permissions.Fix included
Since 2.6.0 every update left the task rewrite rules behind in
api/.htaccess(block removal stopped at the subticket unlink rule). The template now ends with an explicit end marker, and leftover plugin rules are stripped. Verified in the devlab: duplicate task rules gone, osTicket's own rules untouched.Tests
KbEndpointAccessTest,KbServiceTest,HtaccessLeftoverTest.<script>,onerror,javascript:) neutralized by osTicket, partial update keeps notes and help topics, duplicate title 400, invalid visibility/slug/id 400, unknown article 404, DELETE 405, cycle refused. Admin permission table renders the two checkboxes and saves them.