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
|
|
|
|
*
|
2012-01-08 04:59:51 +01:00
|
|
|
* Copyright (c) 2008-2012, 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/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
|
|
|
|
2012-01-08 04:59:51 +01:00
|
|
|
Db() : item_cols(*this)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-14 18:23:18 +02:00
|
|
|
|
2012-02-28 22:09:44 +01:00
|
|
|
bool GetUserPass(const std::wstring & login, long & user_id, UserPass & up);
|
2012-01-08 04:59:51 +01:00
|
|
|
Error AddUser(User & user, const UserPass & up);
|
2012-03-09 23:56:54 +01:00
|
|
|
Error ChangeUserPass(long user_id, const UserPass & up);
|
2012-01-12 03:24:08 +01:00
|
|
|
Error ChangeUserEnv(long user_id, const PT::Space & space);
|
|
|
|
Error ChangeUserAdminEnv(long user_id, const PT::Space & space);
|
2012-02-28 22:09:44 +01:00
|
|
|
Error ChangeUserStatus(long user_id, int status);
|
2012-03-09 03:36:25 +01:00
|
|
|
Error ChangeUserEmail(long user_id, const std::wstring & email);
|
|
|
|
Error RemoveUser(long user_id);
|
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);
|
2011-01-05 22:24:11 +01:00
|
|
|
|
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);
|
2011-01-05 22:24:11 +01:00
|
|
|
Error GetItem(Item & item, const DbItemQuery & item_query);
|
2009-06-05 22:29:06 +02:00
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
bool GetPriv(Item & item, long id);
|
2011-11-25 05:51:55 +01:00
|
|
|
Error EditPrivById(Item & item, long id); // !! dlaczego tu nie ma const?
|
2010-03-15 02:47:26 +01:00
|
|
|
Error EditParentUrlById(Item & item, long id);
|
2010-12-11 23:55:48 +01:00
|
|
|
Error EditFileById(const Item & item, long id); // file_path, file_fs, file_type
|
|
|
|
Error EditHasThumbById(bool has_thumb, long id);
|
2012-01-12 03:24:08 +01:00
|
|
|
Error EditMetaById(const PT::Space & meta, long id);
|
2011-01-24 00:23:24 +01:00
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
Error DelDirById(long id);
|
2011-01-24 00:23:24 +01:00
|
|
|
Error DelFileById(long file_id);
|
|
|
|
Error DelSymlinkById(long symlink_id);
|
2010-05-20 20:28:19 +02:00
|
|
|
|
|
|
|
Error EditSubjectById(Item & item, long id);
|
|
|
|
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
Error 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);
|
2011-01-05 22:24:11 +01:00
|
|
|
Error EditLinkItem(long id, const std::wstring & link_to, int link_redirect);
|
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
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
Error AddHardLink(Item & item);
|
2011-06-24 22:53:21 +02:00
|
|
|
Error EditSortIndexItemById(long id, int sort_index);
|
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;
|
2011-01-05 22:24:11 +01:00
|
|
|
Item dir_temp;
|
2011-11-25 05:51:55 +01:00
|
|
|
Item get_item_temp;
|
2011-01-20 19:37:51 +01:00
|
|
|
std::wstring iq_id_list;
|
2011-11-25 05:51:55 +01:00
|
|
|
DbItemColumns item_cols;
|
|
|
|
|
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);
|
2011-01-05 22:24:11 +01:00
|
|
|
Error EditItemGetIdsByUrl(Item & item);
|
|
|
|
long GetContentId(long item_id);
|
2008-12-14 06:28:28 +01:00
|
|
|
|
2010-02-22 23:52:09 +01:00
|
|
|
|
2011-01-24 00:23:24 +01:00
|
|
|
Error DelItemDelItem(long item_id, int type);
|
|
|
|
Error DelItemDelContent(long content_id);
|
2008-12-14 06:28:28 +01:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
Error IncrementContentRef(long content_id);
|
|
|
|
Error DecrementContentRef(long content_id);
|
2011-06-24 22:53:21 +02:00
|
|
|
|
2011-06-27 23:38:19 +02:00
|
|
|
void GetItemsQuerySelect(const DbItemQuery & iq, DbTextStream & query, bool skip_other_sel);
|
|
|
|
void GetItemsQueryJoin(const DbItemQuery & iq, DbTextStream & query);
|
|
|
|
void GetItemsQueryWhere(const DbItemQuery & iq, DbTextStream & query);
|
|
|
|
void GetItemsQueryOrder(const DbItemQuery & iq, DbTextStream & query);
|
|
|
|
void GetItemsQueryLimit(const DbItemQuery & iq, DbTextStream & query);
|
2011-06-24 22:53:21 +02:00
|
|
|
PGresult * GetItemsQuery(const DbItemQuery & iq, DbTextStream & query, bool skip_other_sel = false);
|
|
|
|
PGresult * GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel = false);
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
};
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|