HandlerPageEdit: Add 'frompage' GET parameter to use a page as a template
This commit is contained in:
bovenliggende
2ee760d9ca
commit
995a980d49
@ -42,7 +42,7 @@ Response HandlerPageEdit::handleRequest(PageDao &pageDao, std::string pagename,
|
|||||||
return errorResponse("No permission", "You don't have permission to create new pages");
|
return errorResponse("No permission", "You don't have permission to create new pages");
|
||||||
}
|
}
|
||||||
auto revisiondao = this->database->createRevisionDao();
|
auto revisiondao = this->database->createRevisionDao();
|
||||||
auto revision = this->database->createRevisionDao()->getCurrentForPage(pagename);
|
auto revision = revisiondao->getCurrentForPage(pagename);
|
||||||
std::string body;
|
std::string body;
|
||||||
|
|
||||||
unsigned int current_revision = 0;
|
unsigned int current_revision = 0;
|
||||||
@ -51,6 +51,15 @@ Response HandlerPageEdit::handleRequest(PageDao &pageDao, std::string pagename,
|
|||||||
body = revision->content;
|
body = revision->content;
|
||||||
current_revision = revision->revision;
|
current_revision = revision->revision;
|
||||||
}
|
}
|
||||||
|
std::string from = r.get("frompage");
|
||||||
|
if(!from.empty())
|
||||||
|
{
|
||||||
|
if(!effectivePermissions(from).canRead())
|
||||||
|
{
|
||||||
|
return this->errorResponse("Permission denied", "No access permissions, so you can't use this page as a template");
|
||||||
|
}
|
||||||
|
body = revisiondao->getCurrentForPage(from)->content;
|
||||||
|
}
|
||||||
if(r.getRequestMethod() == "POST")
|
if(r.getRequestMethod() == "POST")
|
||||||
{
|
{
|
||||||
if(r.post("do") == "submit")
|
if(r.post("do") == "submit")
|
||||||
|
Laden…
Verwijs in nieuw issue
Block a user