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:
Tomasz Sowa 2009-03-22 23:54:15 +00:00
parent 951d0e8653
commit bbaefd0f77
20 changed files with 274 additions and 107 deletions

View File

@ -1,4 +1,4 @@
o = content.o priv.o emacs.o login.o rm.o cat.o logout.o ls.o node.o mkdir.o default.o run.o
o = content.o priv.o emacs.o login.o rm.o cat.o logout.o ls.o node.o mkdir.o default.o run.o last.o
all: content.a

View File

@ -10,9 +10,8 @@ cat.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
cat.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
cat.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
cat.o: ../core/users.h ../core/groups.h ../core/log.h
cat.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
cat.o: ../core/function.h ../core/functionparser.h ../core/request.h
cat.o: ../core/data.h ../app/content.h
cat.o: ../templates/patterncacher.h ../core/misc.h ../core/function.h
cat.o: ../core/functionparser.h ../core/request.h ../core/data.h
content.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
content.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
content.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
@ -24,9 +23,8 @@ content.o: ../core/getparser.h ../core/httpsimpleparser.h
content.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
content.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
content.o: ../core/users.h ../core/groups.h ../core/log.h
content.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
content.o: ../core/function.h ../core/functionparser.h ../core/request.h
content.o: ../core/data.h ../app/content.h
content.o: ../templates/patterncacher.h ../core/misc.h ../core/function.h
content.o: ../core/functionparser.h ../core/request.h ../core/data.h
default.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
default.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
default.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
@ -38,9 +36,8 @@ default.o: ../core/getparser.h ../core/httpsimpleparser.h
default.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
default.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
default.o: ../core/users.h ../core/groups.h ../core/log.h
default.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
default.o: ../core/function.h ../core/functionparser.h ../core/request.h
default.o: ../core/data.h ../app/content.h
default.o: ../templates/patterncacher.h ../core/misc.h ../core/function.h
default.o: ../core/functionparser.h ../core/request.h ../core/data.h
emacs.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
emacs.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
emacs.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
@ -51,9 +48,22 @@ emacs.o: ../core/requesttypes.h ../core/session.h ../core/done.h
emacs.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
emacs.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
emacs.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
emacs.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
emacs.o: ../core/misc.h ../core/function.h ../core/functionparser.h
emacs.o: ../core/request.h ../core/data.h ../app/content.h
emacs.o: ../core/log.h ../templates/patterncacher.h ../core/misc.h
emacs.o: ../core/function.h ../core/functionparser.h ../core/request.h
emacs.o: ../core/data.h
last.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
last.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
last.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
last.o: ../core/group.h ../core/ugcontainer.h ../core/users.h
last.o: ../core/groups.h ../core/functions.h ../core/function.h
last.o: ../core/functioncodeparser.h ../core/request.h ../core/requesttypes.h
last.o: ../core/session.h ../core/done.h ../core/getparser.h
last.o: ../core/httpsimpleparser.h ../core/postparser.h
last.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
last.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
last.o: ../core/log.h ../templates/patterncacher.h ../core/misc.h
last.o: ../core/function.h ../core/functionparser.h ../core/request.h
last.o: ../core/data.h ../app/content.h
login.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
login.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
login.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
@ -64,9 +74,9 @@ login.o: ../core/requesttypes.h ../core/session.h ../core/done.h
login.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
login.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
login.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
login.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
login.o: ../core/misc.h ../core/function.h ../core/functionparser.h
login.o: ../core/request.h ../core/data.h ../app/content.h
login.o: ../core/log.h ../templates/patterncacher.h ../core/misc.h
login.o: ../core/function.h ../core/functionparser.h ../core/request.h
login.o: ../core/data.h
logout.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
logout.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
logout.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
@ -77,9 +87,9 @@ logout.o: ../core/requesttypes.h ../core/session.h ../core/done.h
logout.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
logout.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
logout.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
logout.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
logout.o: ../core/misc.h ../core/function.h ../core/functionparser.h
logout.o: ../core/request.h ../core/data.h ../app/content.h
logout.o: ../core/log.h ../templates/patterncacher.h ../core/misc.h
logout.o: ../core/function.h ../core/functionparser.h ../core/request.h
logout.o: ../core/data.h
ls.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
ls.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
ls.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
@ -90,9 +100,8 @@ ls.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
ls.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h ../core/db.h
ls.o: ../core/error.h ../core/user.h ../core/group.h ../core/users.h
ls.o: ../core/groups.h ../core/log.h ../templates/patterncacher.h
ls.o: ../app/templates.h ../core/misc.h ../core/function.h
ls.o: ../core/functionparser.h ../core/request.h ../core/data.h
ls.o: ../app/content.h
ls.o: ../core/misc.h ../core/function.h ../core/functionparser.h
ls.o: ../core/request.h ../core/data.h
mkdir.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
mkdir.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
mkdir.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
@ -103,9 +112,9 @@ mkdir.o: ../core/requesttypes.h ../core/session.h ../core/done.h
mkdir.o: ../core/getparser.h ../core/httpsimpleparser.h ../core/postparser.h
mkdir.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
mkdir.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
mkdir.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
mkdir.o: ../core/misc.h ../core/function.h ../core/functionparser.h
mkdir.o: ../core/request.h ../core/data.h ../app/content.h
mkdir.o: ../core/log.h ../templates/patterncacher.h ../core/misc.h
mkdir.o: ../core/function.h ../core/functionparser.h ../core/request.h
mkdir.o: ../core/data.h
node.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
node.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
node.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
@ -116,9 +125,9 @@ node.o: ../core/session.h ../core/done.h ../core/getparser.h
node.o: ../core/httpsimpleparser.h ../core/postparser.h
node.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
node.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
node.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
node.o: ../core/misc.h ../core/function.h ../core/functionparser.h
node.o: ../core/request.h ../core/data.h ../app/content.h
node.o: ../core/log.h ../templates/patterncacher.h ../core/misc.h
node.o: ../core/function.h ../core/functionparser.h ../core/request.h
node.o: ../core/data.h
priv.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
priv.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
priv.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
@ -129,9 +138,9 @@ priv.o: ../core/session.h ../core/done.h ../core/getparser.h
priv.o: ../core/httpsimpleparser.h ../core/postparser.h
priv.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
priv.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
priv.o: ../core/log.h ../templates/patterncacher.h ../app/templates.h
priv.o: ../core/misc.h ../core/function.h ../core/functionparser.h
priv.o: ../core/request.h ../core/data.h ../app/content.h
priv.o: ../core/log.h ../templates/patterncacher.h ../core/misc.h
priv.o: ../core/function.h ../core/functionparser.h ../core/request.h
priv.o: ../core/data.h
rm.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
rm.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
rm.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
@ -142,9 +151,8 @@ rm.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
rm.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h ../core/db.h
rm.o: ../core/error.h ../core/user.h ../core/group.h ../core/users.h
rm.o: ../core/groups.h ../core/log.h ../templates/patterncacher.h
rm.o: ../app/templates.h ../core/misc.h ../core/function.h
rm.o: ../core/functionparser.h ../core/request.h ../core/data.h
rm.o: ../app/content.h
rm.o: ../core/misc.h ../core/function.h ../core/functionparser.h
rm.o: ../core/request.h ../core/data.h
run.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
run.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
run.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
@ -155,9 +163,9 @@ run.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
run.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
run.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
run.o: ../core/users.h ../core/groups.h ../core/log.h
run.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
run.o: ../core/function.h ../core/functionparser.h ../core/request.h
run.o: ../core/data.h ../app/content.h
run.o: ../templates/patterncacher.h ../core/misc.h ../core/function.h
run.o: ../core/functionparser.h ../core/request.h ../core/data.h
run.o: ../app/content.h
who.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
who.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
who.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
@ -168,6 +176,6 @@ who.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
who.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
who.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
who.o: ../core/users.h ../core/groups.h ../core/log.h
who.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
who.o: ../core/function.h ../core/functionparser.h ../core/request.h
who.o: ../core/data.h ../app/content.h
who.o: ../templates/patterncacher.h ../core/misc.h ../core/function.h
who.o: ../core/functionparser.h ../core/request.h ../core/data.h
who.o: ../app/content.h

View File

@ -12,6 +12,7 @@
#include <cstdlib>
#include <fcgiapp.h>
#include <ctime>
#include "../templates/templates.h"
#include "../core/request.h"
@ -58,6 +59,7 @@ class Content
void FunDefault();
void FunRun();
void FunWho();
void FunLast();
void PostFunLogin();

View File

@ -42,6 +42,8 @@ void Content::PostFunEmacsAdd()
request.item.parent_id = request.dir_table.back()->id;
request.item.type = Item::file;
// dates (creation and modification) is set by request.item.Clear() at the beginning
if( !request.HasWriteAccess(*request.dir_table.back() ) )
throw Error(Error::permision_denied);
@ -56,7 +58,10 @@ void Content::PostFunEmacsEdit(bool with_url)
if( !request.HasWriteAccess(request.item) )
throw Error(Error::permision_denied);
time_t t = std::time(0);
request.item.date_modification = *std::localtime( &t );
request.session->done_status = db.EditItemById(request.item, with_url);
if( request.session->done_status == Error::ok )

30
content/last.cpp Executable file
View File

@ -0,0 +1,30 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* and is not publicly distributed
*
* Copyright (c) 2008, Tomasz Sowa
* All rights reserved.
*
*/
#include "content.h"
#include "../app/content.h"
void Content::FunLast()
{
}

View File

@ -32,6 +32,8 @@ void Content::PostFunMkdir()
item.privileges = 0755; // !! tymczasowo, bedzie uzyte umask
item.default_item = -1; // !! tymczasowo, bedzie formularz z wprowadzeniem
// dates (creation and modification) is set by the Item() constructor
PrepareUrl(item);
request.session->done_status = db.AddItem(item);

View File

@ -21,8 +21,7 @@ functionparser.o: functionparser.h request.h requesttypes.h log.h session.h
functionparser.o: error.h item.h done.h user.h getparser.h httpsimpleparser.h
functionparser.o: postparser.h cookieparser.h function.h data.h misc.h dirs.h
functionparser.o: db.h dircontainer.h group.h ugcontainer.h users.h groups.h
functionparser.o: functions.h functioncodeparser.h ../app/content.h
functionparser.o: ../core/log.h ../core/data.h ../core/function.h
functionparser.o: functions.h functioncodeparser.h
functions.o: functions.h function.h log.h item.h functioncodeparser.h
groups.o: groups.h group.h db.h log.h item.h misc.h error.h dircontainer.h
groups.o: user.h ugcontainer.h
@ -36,9 +35,8 @@ main.o: cookieparser.h ../content/content.h ../templates/templates.h
main.o: ../../ezc/src/ezc.h ../core/data.h ../core/request.h ../core/item.h
main.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
main.o: ../core/users.h ../core/groups.h ../core/log.h
main.o: ../templates/patterncacher.h ../app/templates.h ../core/misc.h
main.o: ../core/function.h ../core/functionparser.h ../app/content.h
main.o: sessionmanager.h sessioncontainer.h config.h
main.o: ../templates/patterncacher.h ../core/misc.h ../core/function.h
main.o: ../core/functionparser.h sessionmanager.h sessioncontainer.h config.h
main.o: ../confparser/confparser.h
misc.o: misc.h log.h item.h
request.o: request.h requesttypes.h log.h session.h error.h item.h done.h
@ -55,9 +53,9 @@ requestcontroller.o: ../core/data.h ../core/request.h ../core/item.h
requestcontroller.o: ../core/db.h ../core/error.h ../core/user.h
requestcontroller.o: ../core/group.h ../core/users.h ../core/groups.h
requestcontroller.o: ../core/log.h ../templates/patterncacher.h
requestcontroller.o: ../app/templates.h ../core/misc.h ../core/function.h
requestcontroller.o: ../core/functionparser.h ../app/content.h
requestcontroller.o: sessionmanager.h sessioncontainer.h
requestcontroller.o: ../core/misc.h ../core/function.h
requestcontroller.o: ../core/functionparser.h sessionmanager.h
requestcontroller.o: sessioncontainer.h
session.o: session.h requesttypes.h error.h log.h item.h done.h user.h
sessioncontainer.o: sessioncontainer.h session.h requesttypes.h error.h log.h
sessioncontainer.o: item.h done.h user.h

View File

@ -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;
}

View File

@ -68,7 +68,8 @@ public:
long GetFileId(long parent_id, const std::string & url);
long GetDirId(long parent_id, const std::string & url);
tm ConvertTime(const char * str);
static tm ConvertTime(const char * str);
static const char * ConvertTime(const tm & t);
PGconn * GetPGconn();
@ -114,7 +115,8 @@ protected:
struct ItemColumns
{
int id, user_id, group_id, privileges, url, type, parent_id, content_id, default_item, subject, content, content_type;
int id, user_id, group_id, privileges, date_creation, date_modification, url, type, parent_id, content_id, default_item, subject, content, content_type;
void SetColumns(PGresult * r);
void SetItem(PGresult * r, long row, Item & item);

View File

@ -14,36 +14,40 @@
void Db::ItemColumns::SetColumns(PGresult * r)
{
// PQfnumber returns -1 if there is no such a column
id = PQfnumber(r, "id"); // !! why item.id doesn't work?
user_id = PQfnumber(r, "user_id");
group_id = PQfnumber(r, "group_id");
privileges = PQfnumber(r, "privileges");
url = PQfnumber(r, "url");
type = PQfnumber(r, "type");
parent_id = PQfnumber(r, "parent_id");
content_id = PQfnumber(r, "content_id");
default_item = PQfnumber(r, "default_item");
subject = PQfnumber(r, "subject");
content = PQfnumber(r, "content");
content_type = PQfnumber(r, "content_type");
id = PQfnumber(r, "id");
user_id = PQfnumber(r, "user_id");
group_id = PQfnumber(r, "group_id");
privileges = PQfnumber(r, "privileges");
date_creation = PQfnumber(r, "date_creation");
date_modification = PQfnumber(r, "date_modification");
url = PQfnumber(r, "url");
type = PQfnumber(r, "type");
parent_id = PQfnumber(r, "parent_id");
content_id = PQfnumber(r, "content_id");
default_item = PQfnumber(r, "default_item");
subject = PQfnumber(r, "subject");
content = PQfnumber(r, "content");
content_type = PQfnumber(r, "content_type");
}
void Db::ItemColumns::SetItem(PGresult * r, long row, Item & item)
{
if( id != -1 ) item.id = atol( Db::AssertValue(r, row, id) );
if( user_id != -1 ) item.user_id = atol( Db::AssertValue(r, row, user_id) );
if( group_id != -1 ) item.group_id = atol( Db::AssertValue(r, row, group_id) );
if( privileges != -1 ) item.privileges = atoi( Db::AssertValue(r, row, privileges) );
if( url != -1 ) item.url = Db::AssertValue(r, row, url);
if( type != -1 ) item.type = static_cast<Item::Type>( atoi( Db::AssertValue(r, row, type) ) );
if( parent_id != -1 ) item.parent_id = atol( Db::AssertValue(r, row, parent_id) );
if( content_id != -1 ) item.content_id = atol( Db::AssertValue(r, row, content_id) );
if( default_item != -1 ) item.default_item = atol( Db::AssertValue(r, row, default_item) );
if( subject != -1 ) item.subject = Db::AssertValue(r, row, subject);
if( content != -1 ) item.content = Db::AssertValue(r, row, content);
if( content_type != -1 ) item.content_type = atoi( Db::AssertValue(r, row, content_type) );
if( id != -1 ) item.id = atol( Db::AssertValue(r, row, id) );
if( user_id != -1 ) item.user_id = atol( Db::AssertValue(r, row, user_id) );
if( group_id != -1 ) item.group_id = atol( Db::AssertValue(r, row, group_id) );
if( privileges != -1 ) item.privileges = atoi( Db::AssertValue(r, row, privileges) );
if( date_creation != -1 ) item.date_creation = ConvertTime( Db::AssertValue(r, row, date_creation) );
if( date_modification != -1 ) item.date_modification = ConvertTime( Db::AssertValue(r, row, date_modification) );
if( url != -1 ) item.url = Db::AssertValue(r, row, url);
if( type != -1 ) item.type = static_cast<Item::Type>( atoi( Db::AssertValue(r, row, type) ) );
if( parent_id != -1 ) item.parent_id = atol( Db::AssertValue(r, row, parent_id) );
if( content_id != -1 ) item.content_id = atol( Db::AssertValue(r, row, content_id) );
if( default_item != -1 ) item.default_item = atol( Db::AssertValue(r, row, default_item) );
if( subject != -1 ) item.subject = Db::AssertValue(r, row, subject);
if( content != -1 ) item.content = Db::AssertValue(r, row, content);
if( content_type != -1 ) item.content_type = atoi( Db::AssertValue(r, row, content_type) );
}

View File

@ -28,7 +28,7 @@
#define FUN_LOGOUT 10
#define FUN_RUN 11
#define FUN_WHO 12
#define FUN_LAST 13

View File

@ -83,6 +83,9 @@ void Functions::ReadFunctions()
f.item.url = "who";
table.insert( std::make_pair(f.item.url, f) );
f.code = FUN_LAST;
f.item.url = "last";
table.insert( std::make_pair(f.item.url, f) );
// -----------
// FunctionCodeParser fc;

View File

@ -24,6 +24,8 @@ long user_id;
long group_id;
int privileges;
tm date_creation;
tm date_modification;
std::string subject;
std::string content;
@ -82,6 +84,10 @@ void Clear()
default_item = -1;
content_id = -1;
time_t t = std::time(0);
date_creation = *std::localtime( &t );
date_modification = date_creation;
}

View File

@ -187,7 +187,7 @@ return out.str();
const char * DateToStr(int month, int day, int hour, int min, int sec)
const char * DateToStr(int year, int month, int day, int hour, int min, int sec)
{
static const char * month_letter[] = { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII" };
static char buffer[100];
@ -200,7 +200,10 @@ static char buffer[100];
if( month > 11 )
month = 11;
sprintf(buffer, "%s.%02d %02d:%02d:%02d", month_letter[month], day, hour, min, sec);
if( year == 0 )
sprintf(buffer, "%s.%02d %02d:%02d:%02d", month_letter[month], day, hour, min, sec);
else
sprintf(buffer, "%02d.%s.%02d %02d:%02d:%02d", year, month_letter[month], day, hour, min, sec);
// warning: not thread safe (we do not use threads)
return buffer;
@ -208,3 +211,10 @@ static char buffer[100];
const char * DateToStr(time_t t)
{
tm * ptm = std::localtime(&t);
return DateToStr(ptm->tm_year + 1900, ptm->tm_mon, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
}

View File

@ -13,6 +13,7 @@
#include <string>
#include <sstream>
#include <ctime>
#include "log.h"
#include "item.h"
@ -31,7 +32,8 @@ void SetUrlFromSubject(Item & item);
void HtmlEscape(std::ostringstream & out, const std::string & in);
std::string HtmlEscape(const std::string & in);
const char * DateToStr(int month, int day, int hour, int min, int sec);
const char * DateToStr(int year, int month, int day, int hour, int min, int sec);
const char * DateToStr(time_t t);
#endif

View File

@ -10,7 +10,6 @@ dir.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
dir.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
dir.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
dir.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
dir.o: ../app/templates.h
doc.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
doc.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
doc.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
@ -21,7 +20,6 @@ doc.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
doc.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
doc.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
doc.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
doc.o: ../app/templates.h
done.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
done.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
done.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
@ -32,7 +30,6 @@ done.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
done.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
done.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
done.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
done.o: ../app/templates.h
item.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
item.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
item.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
@ -43,7 +40,6 @@ item.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
item.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
item.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
item.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
item.o: ../app/templates.h
patterncacher.o: patterncacher.h ../core/item.h ../../ezc/src/ezc.h
patterncacher.o: ../core/log.h
priv.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
@ -56,7 +52,6 @@ priv.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
priv.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
priv.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
priv.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
priv.o: ../app/templates.h
sys.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
sys.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
sys.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
@ -67,7 +62,6 @@ sys.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
sys.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
sys.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
sys.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
sys.o: ../app/templates.h
templates.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
templates.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
templates.o: ../core/db.h ../core/dircontainer.h ../core/user.h
@ -79,7 +73,6 @@ templates.o: ../core/getparser.h ../core/httpsimpleparser.h
templates.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
templates.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
templates.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
templates.o: ../app/templates.h
user.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
user.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
user.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
@ -90,7 +83,6 @@ user.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
user.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
user.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
user.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
user.o: ../app/templates.h
who.o: templates.h ../../ezc/src/ezc.h ../core/data.h ../core/misc.h
who.o: ../core/log.h ../core/item.h ../core/error.h ../core/dirs.h
who.o: ../core/db.h ../core/dircontainer.h ../core/user.h ../core/group.h
@ -101,8 +93,7 @@ who.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
who.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
who.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
who.o: ../core/users.h ../core/groups.h ../core/log.h patterncacher.h
who.o: ../app/templates.h ../core/sessioncontainer.h
who.o: ../core/requestcontroller.h ../core/data.h ../core/request.h
who.o: ../content/content.h ../templates/templates.h ../core/misc.h
who.o: ../core/function.h ../core/functionparser.h ../app/content.h
who.o: ../core/sessioncontainer.h ../core/requestcontroller.h ../core/data.h
who.o: ../core/request.h ../content/content.h ../templates/templates.h
who.o: ../core/misc.h ../core/function.h ../core/functionparser.h
who.o: ../core/sessionmanager.h ../core/sessioncontainer.h

View File

@ -85,6 +85,80 @@ void item_link(Info & i)
void item_can_read(Info & i)
{
if( request.HasReadAccess(request.item) )
i.result = true;
}
void item_info(Info & i)
{
Ezc::Generator gen(i.out, pat_item_info, functions);
gen.Generate();
}
void item_user(Info & i)
{
User * puser = data.users.GetUser(request.item.user_id);
if( puser )
HtmlEscape(i.out, puser->name);
else
i.out << "unknown";
}
void item_date_creation(Info & i)
{
tm * ptm = &request.item.date_creation;
i.out << DateToStr(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
}
void item_date_modification(Info & i)
{
tm * ptm = &request.item.date_modification;
i.out << DateToStr(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
}
void item_dates_equal(Info & i)
{
tm * ptm1 = &request.item.date_creation;
tm * ptm2 = &request.item.date_modification;
i.result = ptm1->tm_year == ptm2->tm_year &&
ptm1->tm_mon == ptm2->tm_mon &&
ptm1->tm_mday == ptm2->tm_mday &&
ptm1->tm_hour == ptm2->tm_hour &&
ptm1->tm_min == ptm2->tm_min &&
ptm1->tm_sec == ptm2->tm_sec;
}
void item_run(Info & i)
{
if( !request.is_item )
{
i.out << "<!-- there is no an item to run -->";
return;
}
if( !request.HasReadExecAccess(request.item) )
{
i.out << "<!-- run: permission denied -->";
return;
}
Ezc::Pattern * p = pattern_cacher.GetPattern(request.item);
Ezc::Generator gen(i.out, *p, functions);
gen.Generate();
}
@ -155,7 +229,6 @@ void item_old_link(Info & i)
static size_t item_index;
@ -240,12 +313,6 @@ void item_tab_link(Info & i)
}
void item_can_read(Info & i)
{
if( request.HasReadAccess(request.item) )
i.result = true;
}
} // namespace TemplatesFunctions

View File

@ -23,11 +23,12 @@ Ezc::Pattern pat_fun_default;
Ezc::Pattern pat_fun_priv;
Ezc::Pattern pat_fun_rm;
Ezc::Pattern pat_fun_who;
Ezc::Pattern pat_fun_run;
Ezc::Pattern pat_err_item_required;
Ezc::Pattern pat_err_404;
Ezc::Pattern pat_err_per_denied;
Ezc::Pattern pat_err_others;
Ezc::Pattern pat_item_info;
Ezc::Functions functions;
@ -38,6 +39,8 @@ PatternCacher pattern_cacher;
// !! tymczasowa funkcja
void is_group_tv(Info & i)
{
@ -93,8 +96,7 @@ Ezc::Pattern * p = 0;
break;
case FUN_RUN:
if( request.is_item )
p = pattern_cacher.GetPattern(request.item);
p = &pat_fun_run;
break;
case FUN_WHO:
@ -202,7 +204,12 @@ void Templates::CreateFunctions()
functions.Insert("item_url", item_url);
functions.Insert("item_link", item_link);
functions.Insert("item_can_read", item_can_read);
functions.Insert("item_info", item_info);
functions.Insert("item_user", item_user);
functions.Insert("item_date_creation", item_date_creation);
functions.Insert("item_date_modification", item_date_modification);
functions.Insert("item_dates_equal", item_dates_equal);
functions.Insert("item_run", item_run);
functions.Insert("item_old_id", item_old_id);
functions.Insert("item_old_subject", item_old_subject);
@ -353,6 +360,12 @@ void Templates::Read()
pat_fun_who.Directory(data.templates);
pat_fun_who.ParseFile("fun_who.html");
pat_fun_run.Directory(data.templates);
pat_fun_run.ParseFile("fun_run.html");
pat_item_info.Directory(data.templates);
pat_item_info.ParseFile("item_info.html");
CreateFunctions();
#ifdef APPTEMPLATES

View File

@ -39,7 +39,9 @@ namespace TemplatesFunctions
using Ezc::Info;
extern PatternCacher pattern_cacher;
extern Ezc::Functions functions;
extern Ezc::Pattern pat_item_info;
/*
sys
*/
@ -74,6 +76,12 @@ namespace TemplatesFunctions
void item_url(Info & i);
void item_link(Info & i);
void item_can_read(Info & i);
void item_info(Info & i);
void item_user(Info & i);
void item_date_creation(Info & i);
void item_date_modification(Info & i);
void item_dates_equal(Info & i);
void item_run(Info & i);
// !! wprowadzic item_old_is ?
void item_old_id(Info & i);

View File

@ -75,7 +75,8 @@ void who_tab_time(Info & i)
if( !who_init() )
return;
i.out << DateToStr( who_iterator->tm_time.tm_mon + 1,
i.out << DateToStr( 0,
who_iterator->tm_time.tm_mon + 1,
who_iterator->tm_time.tm_mday,
who_iterator->tm_time.tm_hour,
who_iterator->tm_time.tm_min,
@ -88,7 +89,8 @@ void who_tab_last_time(Info & i)
if( !who_init() )
return;
i.out << DateToStr( who_iterator->tm_last_time.tm_mon + 1,
i.out << DateToStr( 0,
who_iterator->tm_last_time.tm_mon + 1,
who_iterator->tm_last_time.tm_mday,
who_iterator->tm_last_time.tm_hour,
who_iterator->tm_last_time.tm_min,