added: date_creation and date_modification to items
changed: function 'run' is using a template: fun_run.html there is: [item_run] called from this template git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@489 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
18
core/db.cpp
18
core/db.cpp
@@ -417,10 +417,12 @@ Error Db::AddItemIntoItem(Item & item)
|
||||
{
|
||||
AssertConnection();
|
||||
std::ostringstream query;
|
||||
query << "insert into core.item (user_id, group_id, privileges, type, parent_id, content_id, default_item, url) values (";
|
||||
query << "insert into core.item (user_id, group_id, privileges, date_creation, date_modification, type, parent_id, content_id, default_item, url) values (";
|
||||
query << '\'' << item.user_id << "', ";
|
||||
query << '\'' << item.group_id << "', ";
|
||||
query << '\'' << item.privileges << "', ";
|
||||
query << '\'' << ConvertTime(item.date_creation) << "', ";
|
||||
query << '\'' << ConvertTime(item.date_modification) << "', ";
|
||||
query << '\'' << static_cast<int>(item.type) << "', ";
|
||||
query << '\'' << item.parent_id << "', ";
|
||||
query << '\'' << item.content_id << "', ";
|
||||
@@ -518,7 +520,7 @@ Error Db::EditItemInItem(Item & item, bool with_subject)
|
||||
{
|
||||
AssertConnection();
|
||||
std::ostringstream query;
|
||||
query << "update core.item set (user_id, group_id, privileges, type, default_item, parent_id";
|
||||
query << "update core.item set (user_id, group_id, privileges, date_creation, date_modification, type, default_item, parent_id";
|
||||
|
||||
if( with_subject )
|
||||
query << ", url";
|
||||
@@ -527,6 +529,8 @@ Error Db::EditItemInItem(Item & item, bool with_subject)
|
||||
query << '\'' << item.user_id << "', ";
|
||||
query << '\'' << item.group_id << "', ";
|
||||
query << '\'' << item.privileges << "', ";
|
||||
query << '\'' << ConvertTime(item.date_creation) << "', ";
|
||||
query << '\'' << ConvertTime(item.date_modification) << "', ";
|
||||
query << '\'' << static_cast<int>(item.type) << "', ";
|
||||
query << '\'' << item.default_item << "', ";
|
||||
query << '\'' << item.parent_id << "' ";
|
||||
@@ -1341,6 +1345,16 @@ return t;
|
||||
}
|
||||
|
||||
|
||||
const char * Db::ConvertTime(const tm & t)
|
||||
{
|
||||
// not thread safe
|
||||
static char buffer[100];
|
||||
|
||||
sprintf(buffer, "%04d-%02d-%02d %02d:%02d:%02d", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user