2021-02-24 01:19:47 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef headerfile_winix_models_itemcontent
|
|
|
|
#define headerfile_winix_models_itemcontent
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include "space/space.h"
|
|
|
|
#include "date/date.h"
|
|
|
|
#include "model.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Winix
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
#define WINIX_ITEM_FILETYPE_NONE 0
|
|
|
|
#define WINIX_ITEM_FILETYPE_IMAGE 1
|
|
|
|
#define WINIX_ITEM_FILETYPE_DOCUMENT 2
|
|
|
|
#define WINIX_ITEM_FILETYPE_VIDEO 3
|
|
|
|
#define WINIX_ITEM_FILETYPE_UNKNOWN 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ItemContent : public morm::Model
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/*
|
|
|
|
* may we should add ct_none? and this will be default (set in Clear method)
|
|
|
|
*/
|
|
|
|
enum ContentType
|
|
|
|
{
|
|
|
|
ct_text = 0,
|
|
|
|
ct_formatted_text,
|
|
|
|
ct_html,
|
|
|
|
ct_bbcode,
|
|
|
|
ct_other, // no auto-formatting is applied
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* record id
|
|
|
|
*/
|
|
|
|
long id;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* how many Items references to this
|
|
|
|
*/
|
|
|
|
int references;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* user owner
|
|
|
|
* -1 means the item was created by a not logged in user and in such a case a 'guest_name' field is set
|
|
|
|
*/
|
|
|
|
long user_id;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* group owner
|
|
|
|
*/
|
|
|
|
long group_id;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* a guest name in a case when the item was created by a not logged in user (user_id is -1)
|
|
|
|
*/
|
|
|
|
std::wstring guest_name;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* who has modified the item last
|
|
|
|
* this field is not taken into account when checking permissions
|
|
|
|
*/
|
|
|
|
long modification_user_id;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* privileges, e.g: 0755
|
|
|
|
* IMPROVEME need some info here
|
|
|
|
*/
|
|
|
|
int privileges;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* when the object was created
|
|
|
|
*/
|
|
|
|
PT::Date date_creation;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* when the object was last modified
|
|
|
|
*/
|
|
|
|
PT::Date date_modification;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* name of a link in the case when type is a symlink or a directory
|
|
|
|
*/
|
|
|
|
std::wstring link_to;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* whether or not winix should make a redirect to link_to link
|
|
|
|
* IMPROVE ME should it be 'bool'?
|
|
|
|
*/
|
|
|
|
int link_redirect;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* static file (if exists)
|
|
|
|
* relative file path
|
|
|
|
*/
|
|
|
|
std::wstring file_path;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* file system type where the file was saved
|
|
|
|
*/
|
|
|
|
int file_fs;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* file type (none, image, doc, etc)
|
|
|
|
*/
|
|
|
|
int file_type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* whether or not we have a thumbnail
|
|
|
|
*/
|
|
|
|
bool file_has_thumb;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* file hash (md4, md5, ...)
|
|
|
|
*/
|
|
|
|
std::wstring file_hash;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* hash type WINIX_CRYPT_HASH_* (see crypt.h)
|
|
|
|
*/
|
|
|
|
int file_hash_type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* size of the file
|
|
|
|
*/
|
|
|
|
size_t file_size;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* object content as provided by the user
|
|
|
|
*/
|
|
|
|
std::wstring content_raw;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* raw content type
|
|
|
|
*/
|
|
|
|
ContentType content_raw_type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* parsed object content
|
|
|
|
* IMPROVEME not used in winix yet
|
|
|
|
*/
|
|
|
|
std::wstring content_parsed;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* parsed content type
|
|
|
|
* IMPROVEME not used in winix yet
|
|
|
|
*/
|
|
|
|
ContentType content_parsed_type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* meta information
|
|
|
|
* additional information in the form af a Space struct
|
|
|
|
*/
|
|
|
|
PT::Space meta;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* admin meta information
|
|
|
|
* additional information available to edit only by an admin
|
|
|
|
*/
|
|
|
|
PT::Space meta_admin;
|
|
|
|
|
|
|
|
|
|
|
|
ItemContent();
|
|
|
|
|
|
|
|
void map_fields();
|
2021-03-11 18:48:18 +01:00
|
|
|
void prepare_table();
|
2021-02-24 01:19:47 +01:00
|
|
|
void after_insert();
|
|
|
|
|
|
|
|
|
|
|
|
void SetDateToNow();
|
|
|
|
void SetDateModifyToNow();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* what about clear() from Model?
|
|
|
|
*/
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
static bool CanContentBeHtmlFiltered(ItemContent::ContentType ct);
|
|
|
|
bool CanContentBeHtmlFiltered();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Winix
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|