summaryrefslogtreecommitdiff
path: root/server/src/journal_commit.cc
diff options
context:
space:
mode:
authordeva <deva>2009-05-11 11:57:50 +0000
committerdeva <deva>2009-05-11 11:57:50 +0000
commit1435d2c664f1c7696cbde2b41df6362f99d1df2c (patch)
tree302e686f55fc59ae28229df9c705c49d5c8a4dd8 /server/src/journal_commit.cc
parent9b5c88df87d285995fd0c483de369cd7854893b1 (diff)
New 'header' in each journal commit, taken from the course.
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,