struct Item has modification_user_id (long) now
this is the id of a user who has modified the item recently this is only for information, persmissions don't use it git-svn-id: svn://ttmath.org/publicrep/winix/trunk@614 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
56075857f2
commit
759135fd7d
|
@ -94,6 +94,7 @@ void Content::PostFunCreateThread()
|
|||
return;
|
||||
|
||||
ReadItem(request.item, Item::dir);
|
||||
SetUser(request.item);
|
||||
ReadThread(request.thread);
|
||||
request.item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty
|
||||
|
||||
|
|
|
@ -182,6 +182,7 @@ void Content::PostFunCreateTicket()
|
|||
return;
|
||||
|
||||
ReadItem(request.item, Item::dir);
|
||||
SetUser(request.item);
|
||||
ReadTicket(request.ticket);
|
||||
request.item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty
|
||||
|
||||
|
|
|
@ -138,8 +138,9 @@ void Content::PostFunEditTicket()
|
|||
if( !FunEditTicketCheckAccess() )
|
||||
return;
|
||||
|
||||
|
||||
ReadItem(request.item, Item::dir);
|
||||
// co z uzytkownikiem i grupš? chyba nie wczytane? !!! (wczesniej bylo SetUser() w ReadItem() - teraz nie ma)
|
||||
// dodac informacje o modyfikacji !!!
|
||||
|
||||
if( !FunCreateTicketCheckAbuse() )
|
||||
{
|
||||
|
|
|
@ -56,8 +56,14 @@ void Content::PostFunEmacsAdd(Item & item)
|
|||
|
||||
void Content::PostFunEmacsEdit(bool with_url)
|
||||
{
|
||||
if( request.session->puser )
|
||||
request.item.modification_user_id = request.session->puser->id;
|
||||
else
|
||||
request.item.modification_user_id = -1;
|
||||
|
||||
request.item.SetDateModifyToNow();
|
||||
request.status = db.EditItemById(request.item, with_url);
|
||||
|
||||
|
||||
if( request.status == WINIX_ERR_OK )
|
||||
{
|
||||
|
@ -131,6 +137,7 @@ void Content::PostFunEmacs()
|
|||
{
|
||||
request.is_item = true;
|
||||
request.item.privileges = 0644; // !! tymczasowo, bedzie uzyte umask
|
||||
SetUser(request.item);
|
||||
PostFunEmacsAdd(request.item);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -114,8 +114,6 @@ bool Content::ReadItem(Item & item, Item::Type item_type)
|
|||
|
||||
bool edit_with_url = ReadItemUrlSubject(item, item_type);
|
||||
|
||||
SetUser(item);
|
||||
|
||||
if( item_type == Item::file )
|
||||
ReadItemContentWithType(item);
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ void Content::PostFunMkdir(bool add_to_dir_table, int privileges)
|
|||
return;
|
||||
|
||||
ReadItem(request.item, Item::dir);
|
||||
SetUser(request.item);
|
||||
request.item.privileges = privileges;
|
||||
|
||||
Mkdir(request.item, add_to_dir_table);
|
||||
|
|
|
@ -136,6 +136,7 @@ void Content::UploadSingle()
|
|||
bool has_url = (new_url && (*new_url)[0] != 0 );
|
||||
|
||||
ReadItem(request.item, Item::file); // ReadItem() changes the url if it is empty
|
||||
SetUser(request.item);
|
||||
request.item.privileges = 0644; // !! tymczasowo
|
||||
|
||||
const char * file_name = request.post_file_table.begin()->second.filename.c_str();
|
||||
|
|
13
core/db.cpp
13
core/db.cpp
|
@ -455,9 +455,10 @@ Error Db::AddItemIntoItem(Item & item)
|
|||
{
|
||||
AssertConnection();
|
||||
std::ostringstream query;
|
||||
query << "insert into core.item (user_id, group_id, privileges, date_creation, date_modification, type, "
|
||||
query << "insert into core.item (user_id, modification_user_id, group_id, privileges, date_creation, date_modification, type, "
|
||||
"parent_id, content_id, auth, auth_path, default_item, subject, guest_name, url) values (";
|
||||
query << '\'' << item.user_id << "', ";
|
||||
query << '\'' << item.modification_user_id << "', ";
|
||||
query << '\'' << item.group_id << "', ";
|
||||
query << '\'' << item.privileges << "', ";
|
||||
query << '\'' << ConvertTime(item.date_creation) << "', ";
|
||||
|
@ -562,7 +563,7 @@ Error Db::EditItemInItem(Item & item, bool with_url)
|
|||
{
|
||||
AssertConnection();
|
||||
std::ostringstream query;
|
||||
query << "update core.item set (user_id, group_id, privileges, date_creation, date_modification, type, "
|
||||
query << "update core.item set (user_id, modification_user_id, group_id, privileges, date_creation, date_modification, type, "
|
||||
"default_item, parent_id, subject, guest_name, auth, auth_path";
|
||||
|
||||
if( with_url )
|
||||
|
@ -570,6 +571,7 @@ Error Db::EditItemInItem(Item & item, bool with_url)
|
|||
|
||||
query << ") = (";
|
||||
query << '\'' << item.user_id << "', ";
|
||||
query << '\'' << item.modification_user_id << "', ";
|
||||
query << '\'' << item.group_id << "', ";
|
||||
query << '\'' << item.privileges << "', ";
|
||||
query << '\'' << ConvertTime(item.date_creation) << "', ";
|
||||
|
@ -795,7 +797,7 @@ PGresult * Db::GetItemsQuery(const ItemQuery & iq)
|
|||
query << "select item.id";
|
||||
|
||||
if( iq.sel_parent_id ) query << " ,parent_id";
|
||||
if( iq.sel_user_id ) query << " ,user_id";
|
||||
if( iq.sel_user_id ) query << " ,user_id, modification_user_id";
|
||||
if( iq.sel_group_id ) query << " ,group_id";
|
||||
if( iq.sel_guest_name) query << " ,guest_name";
|
||||
if( iq.sel_privileges ) query << " ,privileges";
|
||||
|
@ -1092,7 +1094,7 @@ bool result = false;
|
|||
AssertConnection();
|
||||
|
||||
std::ostringstream query;
|
||||
query << "select user_id, group_id, privileges, guest_name from core.item"
|
||||
query << "select user_id, modification_user_id, group_id, privileges, guest_name from core.item"
|
||||
<< " where item.id='" << id << "';";
|
||||
|
||||
r = AssertQuery( query.str() );
|
||||
|
@ -1129,8 +1131,9 @@ Error Db::EditPrivById(Item & item, long id)
|
|||
{
|
||||
AssertConnection();
|
||||
std::ostringstream query;
|
||||
query << "update core.item set (user_id, group_id, privileges, guest_name) = (";
|
||||
query << "update core.item set (user_id, modification_user_id, group_id, privileges, guest_name) = (";
|
||||
query << '\'' << item.user_id << "', ";
|
||||
query << '\'' << item.modification_user_id << "', ";
|
||||
query << '\'' << item.group_id << "', ";
|
||||
query << '\'' << item.privileges << "', ";
|
||||
query << '\'' << Escape(item.guest_name) << "' ";
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
{
|
||||
// id is selected always
|
||||
bool sel_parent_id; // parent_id
|
||||
bool sel_user_id; // user_id
|
||||
bool sel_user_id; // user_id, modification_user_id
|
||||
bool sel_group_id; // group_id
|
||||
bool sel_guest_name; // guest_name
|
||||
bool sel_privileges; // privileges
|
||||
|
@ -223,7 +223,7 @@ protected:
|
|||
struct ItemColumns
|
||||
{
|
||||
int id, user_id, group_id, privileges, date_creation, date_modification, url, type, parent_id,
|
||||
content_id, default_item, subject, content, content_type, guest_name, auth, auth_path;
|
||||
content_id, default_item, subject, content, content_type, guest_name, auth, auth_path, modification_user_id;
|
||||
|
||||
void SetColumns(PGresult * r);
|
||||
void SetItem(PGresult * r, long row, Item & item);
|
||||
|
|
|
@ -31,6 +31,7 @@ void Db::ItemColumns::SetColumns(PGresult * r)
|
|||
guest_name = PQfnumber(r, "guest_name");
|
||||
auth = PQfnumber(r, "auth");
|
||||
auth_path = PQfnumber(r, "auth_path");
|
||||
modification_user_id = PQfnumber(r, "modification_user_id");
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,6 +55,7 @@ void Db::ItemColumns::SetItem(PGresult * r, long row, Item & item)
|
|||
if( guest_name != -1 ) item.guest_name = Db::AssertValue(r, row, guest_name);
|
||||
if( auth != -1 ) item.auth = static_cast<Item::Auth>( atoi(Db::AssertValue(r, row, auth)) );
|
||||
if( auth_path != -1 ) item.auth_path = Db::AssertValue(r, row, auth_path);
|
||||
if( modification_user_id != -1 ) item.modification_user_id = atol( Db::AssertValue(r, row, modification_user_id) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ long user_id;
|
|||
long group_id;
|
||||
std::string guest_name; // used as a user name when user_id is equal -1
|
||||
|
||||
long modification_user_id; // who has modified the item last (not taken into account when checking permissions)
|
||||
|
||||
int privileges;
|
||||
|
||||
tm date_creation;
|
||||
|
@ -109,7 +111,8 @@ void Clear()
|
|||
user_id = -1;
|
||||
group_id = -1;
|
||||
privileges = 0;
|
||||
|
||||
modification_user_id = -1;
|
||||
|
||||
guest_name.clear();
|
||||
|
||||
subject.clear();
|
||||
|
|
|
@ -1 +1 @@
|
|||
<p class="iteminfo">{added_by}: [item_user], [item_date_creation_nice][if-no item_dates_equal], {last_modified}: [item_date_modification_nice][end]</p>
|
||||
<p class="iteminfo">{added_by}: [item_user], [item_date_creation_nice][if-no item_dates_equal], {last_modified}[if-one item_users_different] {by}: [item_modification_user], [else]: [end][item_date_modification_nice][end]</p>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<p class="[if-index item_tab odd]itemtabinfo[else][is mount_thread_is "subject"]itemtabinfo[else]itemtabinfo2[end][end]">{added_by}: [item_tab_user], [item_tab_date_creation_nice][if-no item_tab_dates_equal], {last_modified}: [item_tab_date_modification_nice][end]</p>
|
||||
<p class="[if-index item_tab odd]itemtabinfo[else][is mount_thread_is "subject"]itemtabinfo[else]itemtabinfo2[end][end]">{added_by}: [item_tab_user], [item_tab_date_creation_nice][if-no item_tab_dates_equal], {last_modified}[if-one item_tab_users_different] {by}: [item_tab_modification_user], [else]: [end][item_tab_date_modification_nice][end]</p>
|
||||
|
|
|
@ -20,6 +20,7 @@ req_per_sec = Requests per second
|
|||
|
||||
added_by = Added by
|
||||
last_modified = Last modified
|
||||
by = by
|
||||
|
||||
error_404 = Error 404
|
||||
error_404_msg = We are sory but there is no such a page in our service.
|
||||
|
|
|
@ -20,6 +20,7 @@ req_per_sec = wywo
|
|||
|
||||
added_by = Dodane przez
|
||||
last_modified = ostatnio modyfikowany
|
||||
by = przez
|
||||
|
||||
error_404 = Błąd 404
|
||||
error_404_msg = Przykro nam ale podanej strony nie ma w naszym serwisie.
|
||||
|
|
|
@ -21,6 +21,22 @@ namespace TemplatesFunctions
|
|||
|
||||
|
||||
|
||||
void print_user_name(Info & i, const User * puser, const std::string & guest_name)
|
||||
{
|
||||
if( puser )
|
||||
{
|
||||
HtmlEscape(i.out, puser->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
i.out << "~";
|
||||
|
||||
if( !guest_name.empty() )
|
||||
HtmlEscape(i.out, guest_name);
|
||||
else
|
||||
i.out << "guest"; // !! dodac do konfiga
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -208,18 +224,21 @@ void item_info(Info & i)
|
|||
void item_user(Info & i)
|
||||
{
|
||||
User * puser = data.users.GetUser(request.item.user_id);
|
||||
|
||||
if( puser )
|
||||
HtmlEscape(i.out, puser->name);
|
||||
else
|
||||
{
|
||||
i.out << "~";
|
||||
|
||||
if( !request.item.guest_name.empty() )
|
||||
HtmlEscape(i.out, request.item.guest_name);
|
||||
else
|
||||
i.out << "guest"; // !! dodac do konfiga
|
||||
}
|
||||
print_user_name(i, puser, request.item.guest_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_modification_user(Info & i)
|
||||
{
|
||||
User * puser = data.users.GetUser(request.item.modification_user_id);
|
||||
print_user_name(i, puser, request.item.guest_name);
|
||||
}
|
||||
|
||||
|
||||
void item_users_different(Info & i)
|
||||
{
|
||||
i.res = (request.item.user_id != request.item.modification_user_id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -434,22 +453,33 @@ void item_tab_user(Info & i)
|
|||
if( item_index < request.item_table.size() )
|
||||
{
|
||||
User * puser = data.users.GetUser(request.item_table[item_index].user_id);
|
||||
|
||||
if( puser )
|
||||
HtmlEscape(i.out, puser->name);
|
||||
else
|
||||
{
|
||||
i.out << "~";
|
||||
|
||||
if( !request.item_table[item_index].guest_name.empty() )
|
||||
HtmlEscape(i.out, request.item_table[item_index].guest_name);
|
||||
else
|
||||
i.out << "guest"; // !! dodac do konfiga
|
||||
}
|
||||
print_user_name(i, puser, request.item_table[item_index].guest_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_tab_modification_user(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
{
|
||||
User * puser = data.users.GetUser(request.item_table[item_index].modification_user_id);
|
||||
print_user_name(i, puser, request.item_table[item_index].guest_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_tab_users_different(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
{
|
||||
i.res = (request.item_table[item_index].user_id != request.item_table[item_index].modification_user_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_tab_group(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
|
@ -492,17 +522,22 @@ void item_tab_date_creation_nice(Info & i)
|
|||
if( item_index < request.item_table.size() )
|
||||
{
|
||||
tm * ptm = &request.item_table[item_index].date_creation;
|
||||
TemplatesMisc::print_date_nice(i, ptm);
|
||||
TemplatesMisc::print_date_nice(i, ptm);
|
||||
|
||||
i.out << "<!-- creation hour: " << ptm->tm_hour << " -->";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_tab_date_modification_nice(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
{
|
||||
tm * ptm = &request.item_table[item_index].date_modification;
|
||||
TemplatesMisc::print_date_nice(i, ptm);
|
||||
TemplatesMisc::print_date_nice(i, ptm);
|
||||
|
||||
i.out << "<!-- modification hour: " << ptm->tm_hour << " -->";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -520,15 +555,6 @@ void item_tab_dates_equal(Info & i)
|
|||
ptm1->tm_hour == ptm2->tm_hour &&
|
||||
ptm1->tm_min == ptm2->tm_min &&
|
||||
ptm1->tm_sec == ptm2->tm_sec;
|
||||
|
||||
i.out << "<!-- equal:(" << (int)i.res << ") \n";
|
||||
i.out << 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
|
||||
<< " -->";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,14 @@ namespace TemplatesMisc
|
|||
{
|
||||
|
||||
|
||||
void print_date_nice(Ezc::Info & i, tm * ptm)
|
||||
void print_date_nice(Ezc::Info & i, const tm * ptm)
|
||||
{
|
||||
time_t t = mktime(ptm);
|
||||
tm tm_temp(*ptm);
|
||||
|
||||
time_t t = mktime(&tm_temp); // mktime do something in tm_temp
|
||||
time_t now = time(0);
|
||||
time_t one_day = 60 * 60 * 24;
|
||||
|
||||
|
||||
if( t + one_day > now )
|
||||
i.out << DateToStr(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace TemplatesMisc
|
|||
typedef std::vector<std::vector<Ezc::Pattern> > Patterns;
|
||||
|
||||
|
||||
void print_date_nice(Ezc::Info & i, tm * ptm);
|
||||
void print_date_nice(Ezc::Info & i, const tm * ptm);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -216,6 +216,8 @@ void Templates::CreateFunctions()
|
|||
functions.Insert("item_can_remove", item_can_remove);
|
||||
functions.Insert("item_info", item_info);
|
||||
functions.Insert("item_user", item_user);
|
||||
functions.Insert("item_modification_user", item_modification_user);
|
||||
functions.Insert("item_users_different", item_users_different);
|
||||
functions.Insert("item_date_creation", item_date_creation);
|
||||
functions.Insert("item_date_modification", item_date_modification);
|
||||
functions.Insert("item_date_creation_nice", item_date_creation_nice);
|
||||
|
@ -239,9 +241,11 @@ void Templates::CreateFunctions()
|
|||
functions.Insert("item_tab_can_read", item_tab_can_read);
|
||||
functions.Insert("item_tab_info", item_tab_info);
|
||||
functions.Insert("item_tab_user", item_tab_user);
|
||||
functions.Insert("item_tab_modification_user", item_tab_modification_user);
|
||||
functions.Insert("item_tab_users_different", item_tab_users_different);
|
||||
functions.Insert("item_tab_group", item_tab_group);
|
||||
functions.Insert("item_tab_date_creation", item_tab_date_creation);
|
||||
functions.Insert("item_tab_date_modification", item_tab_date_modification);
|
||||
functions.Insert("item_tab_date_creation", item_tab_date_creation);
|
||||
functions.Insert("item_tab_date_modification", item_tab_date_modification);
|
||||
functions.Insert("item_tab_date_creation_nice", item_tab_date_creation_nice);
|
||||
functions.Insert("item_tab_date_modification_nice", item_tab_date_modification_nice);
|
||||
functions.Insert("item_tab_dates_equal", item_tab_dates_equal);
|
||||
|
|
|
@ -127,6 +127,8 @@ namespace TemplatesFunctions
|
|||
void item_can_remove(Info & i);
|
||||
void item_info(Info & i);
|
||||
void item_user(Info & i);
|
||||
void item_modification_user(Info & i);
|
||||
void item_users_different(Info & i);
|
||||
void item_date_creation(Info & i);
|
||||
void item_date_modification(Info & i);
|
||||
void item_date_creation_nice(Info & i);
|
||||
|
@ -150,6 +152,8 @@ namespace TemplatesFunctions
|
|||
void item_tab_can_read(Info & i);
|
||||
void item_tab_info(Info & i);
|
||||
void item_tab_user(Info & i);
|
||||
void item_tab_modification_user(Info & i);
|
||||
void item_tab_users_different(Info & i);
|
||||
void item_tab_group(Info & i);
|
||||
void item_tab_date_creation(Info & i);
|
||||
void item_tab_date_modification(Info & i);
|
||||
|
|
Loading…
Reference in New Issue