HandlerPageView: Set 'createdon' dynamic variable
This commit is contained in:
parent
0325cdf936
commit
86890660f4
@ -90,19 +90,20 @@ Response HandlerPageView::handleRequest(PageDao &pageDao, std::string pagename,
|
|||||||
|
|
||||||
std::optional<Revision> revision;
|
std::optional<Revision> revision;
|
||||||
std::string templatepartname;
|
std::string templatepartname;
|
||||||
|
auto revisionDao = this->database->createRevisionDao();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(revisionid > 0)
|
if(revisionid > 0)
|
||||||
{
|
{
|
||||||
if(!effectivePermissions(pagename).canSeePageHistory())
|
if(!effectivePermissions(pagename).canSeePageHistory())
|
||||||
{
|
{
|
||||||
auto current = this->database->createRevisionDao()->getCurrentForPage(pagename);
|
auto current = revisionDao->getCurrentForPage(pagename);
|
||||||
if(current && current->revision > revisionid)
|
if(current && current->revision > revisionid)
|
||||||
{
|
{
|
||||||
return errorResponse("Error", "You are not allowed to view older revisions of this page");
|
return errorResponse("Error", "You are not allowed to view older revisions of this page");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
revision = this->database->createRevisionDao()->getRevisionForPage(pagename, revisionid);
|
revision = revisionDao->getRevisionForPage(pagename, revisionid);
|
||||||
if(!revision)
|
if(!revision)
|
||||||
{
|
{
|
||||||
return errorResponse("Revision not found", "No such revision found");
|
return errorResponse("Revision not found", "No such revision found");
|
||||||
@ -122,7 +123,7 @@ Response HandlerPageView::handleRequest(PageDao &pageDao, std::string pagename,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
revision = this->database->createRevisionDao()->getCurrentForPage(pagename);
|
revision = revisionDao->getCurrentForPage(pagename);
|
||||||
templatepartname = "page_view";
|
templatepartname = "page_view";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,6 +176,15 @@ Response HandlerPageView::handleRequest(PageDao &pageDao, std::string pagename,
|
|||||||
}
|
}
|
||||||
return std::string{};
|
return std::string{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto firstRevision = revisionDao->getRevisionForPage(pagename, 1);
|
||||||
|
if(!firstRevision)
|
||||||
|
{
|
||||||
|
return errorResponse("Error", "Could not get first revision for page, which is odd. Solar flares?");
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamicVarsMap["createdon"] = utils::toISODate(firstRevision.value().timestamp);
|
||||||
|
|
||||||
std::string resolvedContent = parser.parseDynamics(revision->content, dynamicParseCallback);
|
std::string resolvedContent = parser.parseDynamics(revision->content, dynamicParseCallback);
|
||||||
if(revisionid > 0)
|
if(revisionid > 0)
|
||||||
{
|
{
|
||||||
|
Caricamento…
Fai riferimento in un nuovo problema
Block a user