<?php
/**
* This file implements the Item class.
*
* This file is part of the evoCore framework - {@link http://evocore.net/}
* See also {@link https://github.com/b2evolution/b2evolution}.
*
* @license GNU GPL v2 - {@link http://b2evolution.net/about/gnu-gpl-license}
*
* @copyright (c)2003-2020 by Francois Planque - {@link http://fplanque.com/}
* Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
*
* @package evocore
*/
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
/**
* Includes:
*/
load_funcs( 'items/model/_item.funcs.php');
load_class( 'slugs/model/_slug.class.php', 'Slug' );
load_class( 'links/model/_linkowner.class.php', 'LinkOwner' );
load_class( 'links/model/_linkitem.class.php', 'LinkItem' );
/**
* Item Class
*
* @package evocore
*/
class Item extends ItemLight
{
/**
* Creation date (timestamp)
* @var integer
*/
var $datecreated;
/**
* The User who has created the Item (lazy-filled).
* @see Item::get_creator_User()
* @see Item::set_creator_User()
* @var User
* @access protected
*/
var $creator_User;
/**
* The User who has edited the Item last time (lazy-filled).
* @see Item::get_lastedit_User()
* @var User
* @access protected
*/
var $lastedit_User;
/**
* ID of the user who has edited the Item last time
* @var integer
*/
var $lastedit_user_ID;
/**
* Date when comments or links were added/edited/deleted for this Item last time (timestamp)
* @see Item::update_last_touched_date()
* @var integer
*/
var $last_touched_ts;
/**
* Date when contents were updated for this Item last time (timestamp)
* @see Item::update_last_touched_date()
* @var integer
*/
var $contents_last_updated_ts;
/**
* The latest Comment on this Item (lazy-filled).
* @see Item::get_latest_Comment()
* @var Comment
* @access protected
*/
var $latest_Comment;
/**
* @deprecated by {@link $creator_User}
* @var User
*/
var $Author;
/**
* ID of the user that created the item
* @var integer
*/
var $creator_user_ID;
/**
* Login of the user that created the item (lazy-filled)
* @var string
*/
var $creator_user_login;
/**
* The assigned User to the item.
* Can be NULL
* @see Item::get_assigned_User()
* @see Item::assign_to()
*
* @var User
* @access protected
*/
var $assigned_User;
/**
* ID of the User assigned to the item
* Can be NULL
*
* @var integer
*/
var $assigned_user_ID;
/**
* Flag to know if item is assigned to a new user
* Used to determine if assignment notification should be sent
* @var boolean
*/
var $assigned_to_new_user;
/**
* The visibility status of the item.
*
* 'published', 'community', 'deprecated', 'protected', 'private', 'review' or 'draft'
*
* @var string
*/
var $status;
/**
* Item previous visibility status. It will be set only if the item status was changed.
* @var string
*/
var $previous_status;
/**
* Locale code for the Item content.
*
* Examples: en-US, zh-CN-utf-8
*
* @var string
*/
var $locale;
/**
* Display the Item in list depending on navigation locale
*
* 0 - Always show
* 1 - Show only if matching navigation locale
*
* @var integer|boolean
*/
var $locale_visibility = 'always';
var $content;
/**
* Flag to know if content was updated during current request
* Used to update excerpt
* @var boolean
*/
var $content_is_updated;
var $titletag;
/**
* Lazy filled, use split_page()
*/
var $content_pages = NULL;
var $wordcount;
/**
* The list of renderers, imploded by '.'.
* @var string
* @access protected
*/
var $renderers;
/**
* Comments status
*
* "open", "disabled" or "closed
*
* @var string
*/
var $comment_status;
var $pst_ID;
var $datedeadline = '';
var $priority;
/**
* @var array Item orders per category
*/
var $orders;
/**
* @var boolean
*/
var $featured;
/**
* Have post processing notifications been handled?
* @var string
*/
var $notifications_status;
/**
* Which cron task is responsible for handling notifications?
* @var integer
*/
var $notifications_ctsk_ID;
/**
* What have been notified?
* Possible values, separated by comma: 'moderators_notified,members_notified,community_notified,pings_sent'
* @var string
*/
var $notifications_flags;
/**
* array of IDs or NULL if we don't know...
*
* @var array
*/
var $extra_cat_IDs = NULL;
/**
* Has the publish date been explicitly set?
*
* @var integer
*/
var $dateset = 1;
var $priorities;
/**
* @access protected
* @see Item::get_excerpt()
* @var string
*/
var $excerpt;
/**
* Is the excerpt autogenerated?
* This will become false when we receive an excerpt that was manually changed in the edit form.
* @access protected
* @var boolean
*/
var $excerpt_autogenerated = 1;
/**
* Location IDs
* @var integer
*/
var $ctry_ID = NULL;
var $rgn_ID = NULL;
var $subrg_ID = NULL;
var $city_ID = NULL;
/**
* ID of parent Item.
* @var integer
*/
var $parent_ID = NULL;
/**
* Parent Item.
* @var object
*/
var $parent_Item = NULL;
/**
* Item Group ID
* @var integer
*/
var $igrp_ID = NULL;
/**
* Other versions of this Item, linked by igrp_ID
* @var array
*/
var $other_version_items;
/**
* Additional settings for the items. lazy filled.
*
* @see Item::get_setting()
* @see Item::set_setting()
* @see Item::load_ItemSettings()
* Any non vital params should go into there.
*
* @var ItemSettings
*/
var $ItemSettings;
/**
* Current User read status on this post content ( Only about the post content and not about the post's comments ).
* This value is not saved into the db. Lazy filled.
*
* @var string ( read, new, updated )
*/
var $content_read_status = NULL;
/**
* The Type of the Item (lazy filled, use {@link get_ItemType()} to access it.
* @access protected
* @var object ItemType
*/
var $ItemType;
/**
* Voting result of all votes
*
* @var integer
*/
var $addvotes;
/**
* A count of all votes
*
* @var integer
*/
var $countvotes;
/**
* Lazy filled, use {@link get_social_media_image()} to access it.
*/
var $social_media_image_File = NULL;
/**
* Current revision
*
* @var integer
*/
var $revision;
/**
* Cached revisions in order to don't load them twice
*
* @var array
*/
var $revisions;
/**
* Constructor
*
* @param object table Database row
* @param string
* @param string
* @param string
* @param string for derived classes
* @param string datetime field name
* @param string datetime field name
* @param string User ID field name
* @param string User ID field name
*/
function __construct( $db_row = NULL, $dbtable = 'T_items__item', $dbprefix = 'post_', $dbIDname = 'post_ID', $objtype = 'Item',
$datecreated_field = 'datecreated', $datemodified_field = 'datemodified',
$creator_field = 'creator_user_ID', $lasteditor_field = 'lastedit_user_ID' )
{
global $localtimenow, $default_locale, $current_User;
// Call parent constructor:
parent::__construct( $db_row, $dbtable, $dbprefix, $dbIDname, $objtype,
$datecreated_field, $datemodified_field,
$creator_field, $lasteditor_field );
if( is_null($db_row) )
{ // New item:
global $Collection, $Blog;
if( isset($current_User) )
{ // use current user as default, if available (which won't be the case during install)
$this->creator_user_login = $current_User->login;
$this->set_creator_User( $current_User );
}
$this->set( 'dateset', 0 ); // Date not explicitly set yet
$this->set( 'notifications_status', 'noreq' );
// Set the renderer list to 'default' will trigger all 'opt-out' renderers:
$this->set( 'renderers', array('default') );
$this->set( 'priority', 3 );
if( ! empty( $Blog ) )
{ //