2010-10-24 01:12:47 +02: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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2014-02-12 17:30:49 +01:00
|
|
|
* Copyright (c) 2010-2014, Tomasz Sowa
|
2010-10-24 01:12:47 +02: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.
|
|
|
|
*
|
2010-10-24 01:12:47 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "item.h"
|
|
|
|
#include "misc.h"
|
2011-06-24 22:53:21 +02:00
|
|
|
#include "crypt.h"
|
2010-10-24 01:12:47 +02:00
|
|
|
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-24 01:12:47 +02:00
|
|
|
|
|
|
|
Item::Item()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-17 06:19:24 +01:00
|
|
|
// !! IMPROVE ME
|
2012-05-27 20:11:34 +02:00
|
|
|
// now we have Request::start_time and Request::start_date
|
2012-02-17 06:19:24 +01:00
|
|
|
// we can somehow get the current time from the request
|
|
|
|
// may setting the date should be completetly removed from here?
|
2010-10-24 01:12:47 +02:00
|
|
|
void Item::SetDateToNow()
|
|
|
|
{
|
2012-05-27 01:04:49 +02:00
|
|
|
date_creation = std::time(0);
|
2010-10-24 01:12:47 +02:00
|
|
|
date_modification = date_creation;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Item::SetDateModifyToNow()
|
|
|
|
{
|
2012-05-27 01:04:49 +02:00
|
|
|
date_modification = std::time(0);
|
2010-10-24 01:12:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Item::Clear()
|
|
|
|
{
|
|
|
|
id = -1;
|
|
|
|
|
|
|
|
user_id = -1;
|
|
|
|
group_id = -1;
|
|
|
|
privileges = 0;
|
|
|
|
modification_user_id = -1;
|
|
|
|
|
|
|
|
guest_name.clear();
|
|
|
|
|
|
|
|
subject.clear();
|
|
|
|
content.clear();
|
2011-01-05 22:24:11 +01:00
|
|
|
modify_index = 0;
|
2010-10-24 01:12:47 +02:00
|
|
|
url.clear();
|
|
|
|
|
|
|
|
content_type = ct_formatted_text;
|
|
|
|
|
|
|
|
type = none;
|
|
|
|
parent_id = -1;
|
2011-01-05 22:24:11 +01:00
|
|
|
|
|
|
|
link_to.clear();
|
|
|
|
link_redirect = false;
|
2010-10-24 01:12:47 +02:00
|
|
|
|
|
|
|
content_id = -1;
|
2011-01-05 22:24:11 +01:00
|
|
|
ref = 1;
|
2010-10-24 01:12:47 +02:00
|
|
|
|
2010-12-10 22:07:01 +01:00
|
|
|
file_path.clear();
|
|
|
|
file_fs = -1;
|
|
|
|
file_type = WINIX_ITEM_FILETYPE_NONE;
|
2011-06-24 22:53:21 +02:00
|
|
|
hash.clear();
|
|
|
|
hash_type = WINIX_CRYPT_HASH_NONE;
|
|
|
|
file_size = 0;
|
2010-12-11 23:55:48 +01:00
|
|
|
has_thumb = false;
|
|
|
|
|
2010-10-24 01:12:47 +02:00
|
|
|
html_template.clear();
|
2011-06-24 22:53:21 +02:00
|
|
|
sort_index = 0;
|
2011-11-25 05:51:55 +01:00
|
|
|
meta.Clear();
|
2012-11-04 22:01:02 +01:00
|
|
|
ameta.Clear();
|
2010-10-24 01:12:47 +02:00
|
|
|
|
|
|
|
SetDateToNow();
|
|
|
|
}
|
2010-12-10 22:07:01 +01:00
|
|
|
|
|
|
|
|
2016-07-13 15:13:56 +02:00
|
|
|
/*
|
|
|
|
* we're using the HtmlFilter only for those contents
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
bool Item::CanContentBeHtmlFiltered(Item::ContentType ct)
|
|
|
|
{
|
|
|
|
return ct == ct_text || ct == ct_formatted_text || ct == ct_html || ct == ct_bbcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Item::CanContentBeHtmlFiltered()
|
|
|
|
{
|
|
|
|
return CanContentBeHtmlFiltered(content_type);
|
|
|
|
}
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
|
|
|
|
} // namespace Winix
|
|
|
|
|