summaryrefslogtreecommitdiff
path: root/server/src/journal_commit.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/journal_commit.cc')
-rw-r--r--server/src/journal_commit.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/server/src/journal_commit.cc b/server/src/journal_commit.cc
index ce99b63..accf839 100644
--- a/server/src/journal_commit.cc
+++ b/server/src/journal_commit.cc
@@ -49,6 +49,9 @@
#include <time.h>
#include <errno.h>
+#include "template.h"
+#include "templateparser.h"
+
/**
* Remove all spaces, tabs and newline trailing the string.
*/
@@ -194,12 +197,32 @@ JournalWriter::JournalWriter(std::string host, unsigned short int port)
this->port = port;
}
-void JournalWriter::addEntry(Transaction &transaction, Commit &commit, std::string resume)
+void JournalWriter::addEntry(Transaction &transaction, Commit &commit,
+ std::string resume, std::string course)
{
// 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: course(%s)\n", course.c_str());
+
+ // Add the course resume as the header (ie. first entry) of the journal entry.
+ if(entrylist.size() == 0 && course != "") {
+ TemplateParser tp(course);
+ tp.parse();
+ Template *templ = tp.getTemplate();
+ std::string course_resume = templ->course.attributes["resume"];
+
+ PRACRO_DEBUG(journal, "CourseResume: %s\n", course_resume.c_str());
+
+ if(course_resume != "") {
+ ResumeEntry re;
+ re.resume = course_resume;
+ re.macro = "course_header";
+ entrylist.push_back(re);
+ }
+ }
+
// Test if the username or the cpr has changed... if so, commit and clear the list.
if(currentuser != transaction.user || currentcpr != transaction.cpr) {
this->commit();
@@ -244,6 +267,8 @@ void JournalWriter::commit()
i++;
}
+ if(resume == "") return;
+
// Connect to praxisuploadserver and commit all resumes in one bulk.
journal_commit(currentcpr.c_str(), currentuser.c_str(),
host.c_str(), port,