2008-12-10 05:42:49 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2008-12-10 05:42:49 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2008-12-10 05:42:49 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
#ifndef headerfile_winix_db_db
|
|
|
|
#define headerfile_winix_db_db
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <cstdio>
|
2009-01-26 21:49:28 +01:00
|
|
|
#include <ctime>
|
|
|
|
#include <cstring>
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
#include "dbbase.h"
|
|
|
|
#include "dbitemquery.h"
|
|
|
|
#include "dbitemcolumns.h"
|
|
|
|
|
|
|
|
#include "core/item.h"
|
|
|
|
#include "core/user.h"
|
|
|
|
#include "core/group.h"
|
|
|
|
#include "core/thread.h"
|
|
|
|
#include "core/dircontainer.h"
|
|
|
|
#include "core/ugcontainer.h"
|
2010-09-29 23:24:34 +02:00
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
|
|
|
|
class Db : public DbBase
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2008-12-31 19:28:12 +01:00
|
|
|
// !! przerobic tak aby GetItem zwracalo wszystkie pozycja
|
|
|
|
// !! GetFile tylko dla plikow
|
|
|
|
// !! GetDir tylko dla katalogow
|
|
|
|
// !! GetFile i GetDir beda uzywac GetItem
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
|
2010-08-14 18:23:18 +02:00
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
bool CheckUser(const std::wstring & login, const std::wstring & password, long & user_id);
|
|
|
|
Error AddUser(User & user, const std::wstring & password);
|
2010-02-28 01:08:10 +01:00
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
Error AddItem(Item & item);
|
2009-06-05 22:29:06 +02:00
|
|
|
Error EditItemById(Item & item, bool with_url = true);
|
|
|
|
Error EditItemByUrl(Item & item, bool with_url = true);
|
2008-12-14 06:28:28 +01:00
|
|
|
void CheckAllUrlSubject();
|
2009-06-05 22:29:06 +02:00
|
|
|
|
2010-02-22 23:52:09 +01:00
|
|
|
|
2010-10-19 02:31:20 +02:00
|
|
|
// !! nie zwracac zadnych kodow bledow?
|
2010-09-18 02:51:12 +02:00
|
|
|
void GetItems(std::vector<Item> & item_tab, const DbItemQuery & item_query);
|
|
|
|
void GetItems(std::vector<long> & item_tab, const DbItemQuery & item_query);
|
2010-02-22 23:52:09 +01:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
|
2010-02-16 01:37:00 +01:00
|
|
|
// !! pobiera tylko jeden item (cos wymyslec innego z nazwa albo argumentem)
|
2010-08-10 22:43:38 +02:00
|
|
|
void GetItem(std::vector<Item> & item_tab, long id);
|
2009-06-05 22:29:06 +02:00
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
bool GetPriv(Item & item, long id);
|
2008-12-30 02:05:03 +01:00
|
|
|
Error EditPrivById(Item & item, long id);
|
2010-03-15 02:47:26 +01:00
|
|
|
Error EditParentUrlById(Item & item, long id);
|
|
|
|
Error EditAuthById(Item & item, long id);
|
2009-02-06 14:12:03 +01:00
|
|
|
Error DelDirById(long id);
|
2010-05-20 20:28:19 +02:00
|
|
|
|
|
|
|
Error EditSubjectById(Item & item, long id);
|
|
|
|
|
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
bool DelItem(const Item & item);
|
2010-08-10 22:43:38 +02:00
|
|
|
void GetDirs(DirContainer & dir_tab);
|
|
|
|
void GetUsers(UGContainer<User> & user_tab);
|
|
|
|
void GetGroups(UGContainer<Group> & group_tab);
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
// !! nowy interfejs
|
2009-11-18 02:58:38 +01:00
|
|
|
long Size(long parent_id, Item::Type type = Item::none);
|
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
Error GetItemById(long item_id, Item & item);
|
2010-11-21 01:19:17 +01:00
|
|
|
Error GetItem(long parent_id, const std::wstring & url, Item & item);
|
2008-12-31 19:28:12 +01:00
|
|
|
Error EditDefaultItem(long id, long new_default_item);
|
2010-11-21 01:19:17 +01:00
|
|
|
Error EditTemplateItemById(long id, const std::wstring & new_html_template);
|
2010-08-13 22:04:57 +02:00
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
long GetItemId(long parent_id, const std::wstring & url, Item::Type type);
|
|
|
|
long GetFileId(long parent_id, const std::wstring & url);
|
|
|
|
long GetDirId(long parent_id, const std::wstring & url);
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2009-01-27 19:43:44 +01:00
|
|
|
|
2009-04-21 01:49:28 +02:00
|
|
|
|
|
|
|
Error AddThread(Thread & thread);
|
|
|
|
Error GetThreadByDirId(long dir_id, Thread & thread);
|
2009-06-05 22:29:06 +02:00
|
|
|
Error GetThreads(long parent_id, std::vector<Thread> & thread_tab);
|
|
|
|
Error EditThreadAddItem(long dir_id, long item_id);
|
2009-06-07 04:40:27 +02:00
|
|
|
Error EditThreadRemoveItem(long dir_id);
|
|
|
|
Error RemoveThread(long dir_id);
|
2009-06-05 22:29:06 +02:00
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
|
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
protected:
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
DbTextStream query, query_create_url;
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring temp_url;
|
2010-09-18 02:51:12 +02:00
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
bool AddItemCreateUrlSubject(Item & item);
|
|
|
|
|
|
|
|
Error AddItemIntoContent(Item & item);
|
|
|
|
Error AddItemIntoItem(Item & item);
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
Error EditItemInItem(Item & item, bool with_url);
|
2008-12-14 06:28:28 +01:00
|
|
|
Error EditItemInContent(Item & item);
|
2008-12-21 22:17:09 +01:00
|
|
|
Error EditItemGetId(Item & item);
|
|
|
|
Error EditItemGetContentId(Item & item);
|
2008-12-14 06:28:28 +01:00
|
|
|
|
|
|
|
void CheckAllUrlSubjectModifyItem(Item & item);
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
PGresult * GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel = false);
|
2010-02-22 23:52:09 +01:00
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
bool DelItemDelItem(const Item & item);
|
|
|
|
void DelItemDelContent(const Item & item);
|
|
|
|
Error DelItemCountContents(const Item & item, long & contents);
|
|
|
|
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
};
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|