2008-12-10 05:42:49 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2014-10-04 20:04:03 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2016-04-04 18:02:36 +02:00
|
|
|
* Copyright (c) 2008-2016, Tomasz Sowa
|
2008-12-10 05:42:49 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-10-04 20:04:03 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2008-12-10 05:42:49 +01:00
|
|
|
*/
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
#ifndef headerfile_winix_core_item
|
|
|
|
#define headerfile_winix_core_item
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
#include <string>
|
2012-05-01 00:53:54 +02:00
|
|
|
#include "space/space.h"
|
2012-05-27 01:04:49 +02:00
|
|
|
#include "date/date.h"
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2010-12-10 22:07:01 +01:00
|
|
|
#define WINIX_ITEM_FILETYPE_NONE 0
|
|
|
|
#define WINIX_ITEM_FILETYPE_IMAGE 1
|
|
|
|
#define WINIX_ITEM_FILETYPE_DOCUMENT 2
|
2011-07-29 00:18:10 +02:00
|
|
|
#define WINIX_ITEM_FILETYPE_VIDEO 3
|
|
|
|
#define WINIX_ITEM_FILETYPE_UNKNOWN 10
|
2010-12-10 22:07:01 +01:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
struct Item
|
|
|
|
{
|
2011-06-24 22:53:21 +02:00
|
|
|
long id;
|
|
|
|
long parent_id;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
long user_id;
|
|
|
|
long group_id;
|
|
|
|
std::wstring guest_name; // used as a user name when user_id is equal -1
|
2008-12-14 06:28:28 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
long modification_user_id; // who has modified the item last (not taken into account when checking permissions)
|
2010-06-22 23:09:37 +02:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
int privileges;
|
2009-06-07 04:40:27 +02:00
|
|
|
|
2012-05-27 01:04:49 +02:00
|
|
|
PT::Date date_creation;
|
|
|
|
PT::Date date_modification;
|
2008-12-14 06:28:28 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
std::wstring subject;
|
|
|
|
std::wstring content;
|
2011-01-05 22:24:11 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
std::wstring url;
|
|
|
|
int modify_index;
|
2008-12-14 06:28:28 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
enum ContentType
|
|
|
|
{
|
|
|
|
ct_text = 0,
|
|
|
|
ct_formatted_text,
|
|
|
|
ct_html,
|
|
|
|
ct_bbcode,
|
2016-07-13 15:13:56 +02:00
|
|
|
ct_other, // no auto-formatting is applied
|
2011-06-24 22:53:21 +02:00
|
|
|
};
|
2008-12-14 06:28:28 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
ContentType content_type;
|
2008-12-14 06:28:28 +01:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
dir = 0,
|
|
|
|
file = 1,
|
|
|
|
symlink = 2,
|
2009-06-05 22:29:06 +02:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
none = 1000
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Type type;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
// used when type is symlink or to a directory too (function 'default')
|
|
|
|
std::wstring link_to;
|
2013-12-03 13:33:41 +01:00
|
|
|
int link_redirect; // !! IMPROVE ME should it be 'bool'?
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
// static file (if exists)
|
|
|
|
std::wstring file_path; // relative file path
|
|
|
|
int file_fs; // file system type where the file was saved
|
|
|
|
int file_type; // file type (none, image, doc, etc)
|
|
|
|
bool has_thumb; // whether or not we have a thumbnail
|
|
|
|
std::wstring hash; // file hash (md4, md5, ...)
|
|
|
|
int hash_type; // hash type WINIX_CRYPT_HASH_* (see crypt.h)
|
|
|
|
size_t file_size; // size of the file
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
std::wstring html_template;
|
2009-12-30 21:46:12 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
|
|
|
|
// sort index used when displaying a group of items
|
|
|
|
int sort_index;
|
2010-08-13 22:04:57 +02:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2011-11-25 05:51:55 +01:00
|
|
|
// meta information
|
2012-01-12 03:24:08 +01:00
|
|
|
PT::Space meta;
|
2012-11-04 22:01:02 +01:00
|
|
|
PT::Space ameta;
|
2011-11-25 05:51:55 +01:00
|
|
|
|
|
|
|
|
2010-10-24 01:12:47 +02:00
|
|
|
// methods
|
|
|
|
Item();
|
|
|
|
void SetDateToNow();
|
|
|
|
void SetDateModifyToNow();
|
|
|
|
void Clear();
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
|
2016-07-13 15:13:56 +02:00
|
|
|
static bool CanContentBeHtmlFiltered(Item::ContentType ct);
|
|
|
|
bool CanContentBeHtmlFiltered();
|
|
|
|
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
private:
|
|
|
|
// used by the database
|
|
|
|
long content_id; // content id in 'content' table
|
|
|
|
int ref; // content references
|
|
|
|
|
2012-02-29 23:52:55 +01:00
|
|
|
friend class Db;
|
|
|
|
friend struct DbItemColumns;
|
2008-12-10 05:42:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
} // namespace Winix
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
#endif
|