From daed17848ce4b81db065b815c6f70fe129f6a3f0 Mon Sep 17 00:00:00 2001 From: "Albert S." Date: Thu, 23 Nov 2023 18:25:57 +0100 Subject: [PATCH] handlers: handlerpageedit: Handle [cmd:parentpage] --- handlers/handlerpageedit.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/handlers/handlerpageedit.cpp b/handlers/handlerpageedit.cpp index e2be89b..b0e3a5c 100644 --- a/handlers/handlerpageedit.cpp +++ b/handlers/handlerpageedit.cpp @@ -79,7 +79,15 @@ Response HandlerPageEdit::handleRequest(PageDao &pageDao, std::string pagename, std::string visiblecmd = parser.extractCommand("visible", newContent); std::string rename = parser.extractCommand("rename", newContent); std::string customtitle = parser.extractCommand("pagetitle", newContent); + std::string parentpage = parser.extractCommand("parentpage", newContent); std::vector perms = parser.extractCommands("permissions", newContent); + + if(parentpage != "" && !pageDao.find(parentpage)) + { + return this->errorResponse("Invalid parent", + "Specified parent page " + parentpage + " does not exist"); + } + Page page; std::optional currentPage = pageDao.find(pagename); if(currentPage) @@ -134,6 +142,7 @@ Response HandlerPageEdit::handleRequest(PageDao &pageDao, std::string pagename, page.listed = !(visiblecmd == "0"); page.name = pagename; page.title = customtitle; + page.parentpage = parentpage; if(page.title.empty()) { page.title = page.name;