summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/journal_commit.cc14
-rw-r--r--server/src/journal_commit.h3
-rw-r--r--server/src/server.cc12
3 files changed, 16 insertions, 13 deletions
diff --git a/server/src/journal_commit.cc b/server/src/journal_commit.cc
index e0db705..414fa20 100644
--- a/server/src/journal_commit.cc
+++ b/server/src/journal_commit.cc
@@ -207,12 +207,8 @@ JournalWriter::JournalWriter(std::string host, unsigned short int port)
}
void JournalWriter::addEntry(Transaction &transaction, Commit &commit,
- std::string resume, std::string templname)
+ std::string resume, Template *templ)
{
- TemplateParser tp(templname);
- tp.parse();
- Template *templ = tp.getTemplate();
-
size_t index = 0;
std::vector< Macro >::iterator i = templ->macros.begin();
while(i != templ->macros.end()) {
@@ -224,21 +220,21 @@ void JournalWriter::addEntry(Transaction &transaction, Commit &commit,
if(index >= templ->macros.size()) {
PRACRO_ERR(journal, "Could not find macro %s in template %s\n",
- commit.macro.c_str(), templname.c_str());
+ commit.macro.c_str(), templ->attributes["name"].c_str());
// return;
} else {
PRACRO_DEBUG(journal, "Found macro %s as index %u in template %s\n",
- commit.macro.c_str(), index, templname.c_str());
+ commit.macro.c_str(), index, templ->attributes["name"].c_str());
}
// First run - initialize username and cpr.
if(currentuser == "" && entrylist.size() == 0) currentuser = transaction.user;
if(currentcpr == "" && entrylist.size() == 0) currentcpr = transaction.cpr;
- PRACRO_DEBUG(journal, "addEntry: template(%s)\n", templname.c_str());
+ PRACRO_DEBUG(journal, "addEntry: template(%s)\n", templ->attributes["name"].c_str());
// Add the template resume as the header (ie. first entry) of the journal entry.
- if(entrylist.size() == 0 && templname != "") {
+ if(entrylist.size() == 0 && templ->attributes["name"] != "") {
std::string template_resume = templ->attributes["resume"];
PRACRO_DEBUG(journal, "TemplateResume: %s\n", template_resume.c_str());
diff --git a/server/src/journal_commit.h b/server/src/journal_commit.h
index 82919ed..4f7f211 100644
--- a/server/src/journal_commit.h
+++ b/server/src/journal_commit.h
@@ -31,13 +31,14 @@
#include <map>
#include "transaction.h"
+#include "template.h"
class JournalWriter {
public:
JournalWriter(std::string host, unsigned short int port);
void addEntry(Transaction &transaction, Commit &commit,
- std::string resume, std::string template_resume);
+ std::string resume, Template *templ);
void commit();
diff --git a/server/src/server.cc b/server/src/server.cc
index 0eeec43..d0e9524 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -82,7 +82,8 @@ public:
static std::string handleCommits(Transaction *transaction, Database &db,
- JournalWriter &journalwriter, MacroList &macrolist)
+ JournalWriter &journalwriter, MacroList &macrolist,
+ TemplateList &templatelist)
{
std::string answer;
@@ -99,7 +100,12 @@ static std::string handleCommits(Transaction *transaction, Database &db,
db.commitTransaction(transaction->user, transaction->cpr, *macro, commit.fields);
if(resume != "") {
- journalwriter.addEntry(*transaction, commit, resume, commit.templ);
+
+ TemplateParser tp(templatelist.getLatestVersion(commit.templ));
+ tp.parse();
+ Template *templ = tp.getTemplate();
+
+ journalwriter.addEntry(*transaction, commit, resume, templ);
}
i++;
@@ -264,7 +270,7 @@ static std::string handleTransaction(Transaction *transaction,
answer += "<pracro version=\"1.0\">\n";
try {
- answer += handleCommits(transaction, db, journalwriter, macrolist);
+ answer += handleCommits(transaction, db, journalwriter, macrolist, templatelist);
} catch( std::exception &e ) {
PRACRO_ERR(server, "Commit error: %s\n", e.what());
return error_box(xml_encode(e.what()));