Version 3.2.3
This commit is contained in:
1 parent
ae5c01cc78
commit
78706903a2
2641 files changed
+228363
-201264
No files matched your search
@@ -3,19 +3,19 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* Item Marking
|
||||
* Owner: Matt "Oh Lord, why did I get assigned this?" Mecham
|
||||
* Last Updated: $Date: 2010-10-06 06:09:32 -0400 (Wed, 06 Oct 2010) $
|
||||
* Last Updated: $Date: 2011-06-07 15:07:17 -0400 (Tue, 07 Jun 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: mmecham $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @link http://hatynka.in
|
||||
* @since 9th March 2005 11:03
|
||||
* @version $Revision: 6946 $
|
||||
* @version $Revision: 8994 $
|
||||
*
|
||||
* @todo [Future] Perhaps find more ways to reduce the size of items_read
|
||||
* @todo [Future] Maybe add an IN_DEV tool to warn when markers have been cancelled out / size drastically reduced
|
||||
@@ -145,21 +145,21 @@ class classItemMarking
|
||||
/**
|
||||
* Can compress cookies
|
||||
*/
|
||||
private $_canCompressCookies = false;
|
||||
protected $_canCompressCookies = false;
|
||||
|
||||
/**
|
||||
* Disable all marking for guests
|
||||
*/
|
||||
private $_noGuestMarking = false;
|
||||
protected $_noGuestMarking = false;
|
||||
|
||||
private $_setSaveCookie = false;
|
||||
protected $_setSaveCookie = false;
|
||||
|
||||
/**
|
||||
* Method constructor
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry Object
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
@@ -234,33 +234,30 @@ class classItemMarking
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Fetch cookies */
|
||||
foreach( ipsRegistry::$applications as $_app => $data )
|
||||
foreach( IPSLib::getEnabledApplications() as $_app => $data )
|
||||
{
|
||||
if ( isset( $data['app_enabled'] ) AND $data['app_enabled'] )
|
||||
{
|
||||
$_value = $this->_inflateCookie( IPSCookie::get( 'itemMarking_' . $_app ) );
|
||||
$_value2 = $this->_inflateCookie( IPSCookie::get( 'itemMarking_' . $_app . '_items' ) );
|
||||
|
||||
$this->_cookie[ 'itemMarking_' . $_app ] = ( is_array( $_value ) ) ? $_value : array();
|
||||
$this->_cookie[ 'itemMarking_' . $_app . '_items'] = ( is_array( $_value2 ) ) ? $_value2 : array();
|
||||
|
||||
/* Clean up */
|
||||
if ( $this->_cookie[ 'itemMarking_' . $_app . '_items'] )
|
||||
{
|
||||
$_items = ( is_array( $this->_cookie[ 'itemMarking_' . $_app . '_items'] ) ) ? $this->_cookie[ 'itemMarking_' . $_app . '_items'] : unserialize( $this->_cookie[ 'itemMarking_' . $_app . '_items'] );
|
||||
|
||||
$this->_cookieCounter = 0;
|
||||
arsort( $_items, SORT_NUMERIC );
|
||||
$_value = $this->_inflateCookie( IPSCookie::get( 'itemMarking_' . $_app ) );
|
||||
$_value2 = $this->_inflateCookie( IPSCookie::get( 'itemMarking_' . $_app . '_items' ) );
|
||||
|
||||
$_newData = array_filter( $_items, array( $this, 'arrayFilterCookieItems' ) );
|
||||
|
||||
$this->_cookie[ 'itemMarking_' . $_app . '_items'] = $_newData;
|
||||
|
||||
IPSDebug::addMessage( 'Cookie loaded: itemMarking_' . $_app . '_items' . ' - ' . serialize( $_newData ) );
|
||||
IPSDebug::addMessage( 'Cookie loaded: itemMarking_' . $_app . ' - ' . serialize( $_value ) );
|
||||
}
|
||||
$this->_cookie[ 'itemMarking_' . $_app ] = ( is_array( $_value ) ) ? $_value : array();
|
||||
$this->_cookie[ 'itemMarking_' . $_app . '_items'] = ( is_array( $_value2 ) ) ? $_value2 : array();
|
||||
|
||||
/* Clean up */
|
||||
if ( $this->_cookie[ 'itemMarking_' . $_app . '_items'] )
|
||||
{
|
||||
$_items = ( is_array( $this->_cookie[ 'itemMarking_' . $_app . '_items'] ) ) ? $this->_cookie[ 'itemMarking_' . $_app . '_items'] : unserialize( $this->_cookie[ 'itemMarking_' . $_app . '_items'] );
|
||||
|
||||
$this->_cookieCounter = 0;
|
||||
arsort( $_items, SORT_NUMERIC );
|
||||
|
||||
$_newData = array_filter( $_items, array( $this, 'arrayFilterCookieItems' ) );
|
||||
|
||||
$this->_cookie[ 'itemMarking_' . $_app . '_items'] = $_newData;
|
||||
|
||||
IPSDebug::addMessage( 'Cookie loaded: itemMarking_' . $_app . '_items' . ' - ' . serialize( $_newData ) );
|
||||
IPSDebug::addMessage( 'Cookie loaded: itemMarking_' . $_app . ' - ' . serialize( $_value ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,11 +267,11 @@ class classItemMarking
|
||||
/**
|
||||
* Compressed the cookie
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @param mixed Data (array or string)
|
||||
* @return string compressed data
|
||||
*/
|
||||
private function _compressCookie( $data )
|
||||
protected function _compressCookie( $data )
|
||||
{
|
||||
if ( $this->_canCompressCookies )
|
||||
{
|
||||
@@ -292,11 +289,11 @@ class classItemMarking
|
||||
/**
|
||||
* Inflate the cookie
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @param mixed Compressed string
|
||||
* @return string Uncompressed data
|
||||
*/
|
||||
private function _inflateCookie( $data )
|
||||
protected function _inflateCookie( $data )
|
||||
{
|
||||
/* already inflated? */
|
||||
if ( ! $data OR is_array( $data ) )
|
||||
@@ -321,7 +318,7 @@ class classItemMarking
|
||||
* Disable instant save
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function disableInstantSave()
|
||||
{
|
||||
@@ -332,7 +329,7 @@ class classItemMarking
|
||||
* Enable instant save (Default mode anyway)
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function enableInstantSave()
|
||||
{
|
||||
@@ -343,7 +340,7 @@ class classItemMarking
|
||||
* Fetch status
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function fetchInstantSaveStatus()
|
||||
{
|
||||
@@ -356,7 +353,7 @@ class classItemMarking
|
||||
* @access protected
|
||||
* @param string Key
|
||||
* @param array
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
protected function _updateCookieData( $key, $array )
|
||||
{
|
||||
@@ -409,7 +406,7 @@ class classItemMarking
|
||||
* Set the flag to save cookies in mydestruct
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
protected function _setSaveCookie()
|
||||
{
|
||||
@@ -421,7 +418,7 @@ class classItemMarking
|
||||
*
|
||||
* @access protected
|
||||
* @param string Key name (leave blank to save out all cookies)
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
protected function _saveCookie( $key='' )
|
||||
{
|
||||
@@ -524,20 +521,27 @@ class classItemMarking
|
||||
*
|
||||
* <code>$itemMarking->markAsRead( array( 'forumID' => 34, 'itemID' => 99 ) );</code>
|
||||
* <code>$itemMarking->markAsRead( array( 'forumID' => 34 ) );</code>
|
||||
*
|
||||
* If you pass in a timestamp, it will set that as the read date so a topic, for example
|
||||
* won't appear read until you're on the last page
|
||||
* <code>$itemMarking->markAsRead( array( 'forumID' => 34, 'itemID' => 99, 'markDate' => 123456790 ) );</code>
|
||||
*
|
||||
* If you pass a "containerLastActivityDate" timestamp it will compare the markDate against it and not run the fetchUnreadCount query
|
||||
* <code>$itemMarking->markAsRead( array( 'forumID' => 34, 'itemID' => 99, 'markDate' => 123456790, 'containerLastActivityDate' => 1234567890 ) );</code>
|
||||
* @access public
|
||||
* @param array
|
||||
* @param string [App]
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function markRead( $data, $app='' )
|
||||
{
|
||||
$app = ( $app ) ? $app : IPS_APP_COMPONENT;
|
||||
$origData = $data;
|
||||
$data = $this->_fetchModule( $app )->convertData( $data );
|
||||
$cookie = $this->_fetchCookieData( 'itemMarking_' . $app );
|
||||
$cookieItems = $this->_fetchCookieData( 'itemMarking_' . $app . '_items');
|
||||
$mainKey = $this->_findMainRowByKey( $data, $app );
|
||||
$app = ( $app ) ? $app : IPS_APP_COMPONENT;
|
||||
$origData = $data;
|
||||
$data = $this->_fetchModule( $app )->convertData( $data );
|
||||
$cookie = $this->_fetchCookieData( 'itemMarking_' . $app );
|
||||
$cookieItems = $this->_fetchCookieData( 'itemMarking_' . $app . '_items');
|
||||
$mainKey = $this->_findMainRowByKey( $data, $app );
|
||||
$markDate = ( ! empty( $data['markDate'] ) ) ? intval( $data['markDate'] ) : time();
|
||||
$containerLastActivityDate = ( ! empty( $data['containerLastActivityDate'] ) ) ? intval( $data['containerLastActivityDate'] ) : false;
|
||||
|
||||
/* Search engine? */
|
||||
if ( $this->member->is_not_human === TRUE )
|
||||
@@ -559,7 +563,7 @@ class classItemMarking
|
||||
if ( $data['itemID'] )
|
||||
{
|
||||
/* Cookie */
|
||||
$cookieItems[ $data['itemID'] ] = time();
|
||||
$cookieItems[ $data['itemID'] ] = $markDate;
|
||||
$this->_updateCookieData( 'itemMarking_' . $app . '_items', $cookieItems );
|
||||
|
||||
$_cookieGreset = isset( $cookie['greset'][ $this->_makeKey( $data, TRUE ) ] ) ? intval( $cookie['greset'][ $this->_makeKey( $data, TRUE ) ] ) : 0;
|
||||
@@ -569,7 +573,7 @@ class classItemMarking
|
||||
if ( $this->settings['topic_marking_enable'] )
|
||||
{
|
||||
/* DB */
|
||||
$this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'][ $data['itemID'] ] = time();
|
||||
$this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'][ $data['itemID'] ] = $markDate;
|
||||
|
||||
/* Check the cookie again.. */
|
||||
if ( $_cookieGreset AND $_cookieGreset > $this->_itemMarkers[ $app ][ $mainKey ]['item_global_reset'] )
|
||||
@@ -586,13 +590,17 @@ class classItemMarking
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Check last reset time */
|
||||
$_lastReset = IPSLib::fetchHighestNumber( array( $_cookieGreset, isset( $cookie['global']) ? $cookie['global'] : 0, intval( $this->_itemMarkers[ $app ][ $mainKey ]['item_global_reset'] ) ) );
|
||||
$_lastReset = IPSLib::fetchHighestNumber( array( $_cookieGreset, isset( $cookie['global']) ? $cookie['global'] : 0, intval( $this->_itemMarkers[ $app ][ $mainKey ]['item_global_reset'] ), intval( $this->memberData['_cache']['gb_mark__'. $app ] ) ) );
|
||||
$_doQuery = ( $this->settings['topic_marking_enable'] OR ( ! $this->settings['topic_marking_enable'] AND ! $this->settings['topic_marking_noquery'] ) );
|
||||
|
||||
/* Fetch unread items */
|
||||
if ( $this->settings['topic_marking_enable'] OR ( ! $this->settings['topic_marking_enable'] AND ! $this->settings['topic_marking_noquery'] ) )
|
||||
if ( $_doQuery === true )
|
||||
{
|
||||
$_oldest = IPS_UNIX_TIME_NOW - ( $this->settings['topic_marking_keep_days'] * 86400 );
|
||||
$_lastReset = ( $_lastReset >= $_oldest ) ? $_lastReset : $_oldest;
|
||||
|
||||
$_unreadCount = $this->_fetchModule( $app )->fetchUnreadCount( $origData, $_readItems, $_lastReset );
|
||||
|
||||
if ( $_unreadCount['count'] > 0 )
|
||||
@@ -653,7 +661,7 @@ class classItemMarking
|
||||
*
|
||||
* @access public
|
||||
* @param string [App Optional. If ommited, all apps are marked as read]
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function markAppAsRead( $app='' )
|
||||
{
|
||||
@@ -713,12 +721,12 @@ class classItemMarking
|
||||
{
|
||||
/* Only process is the app actually does topic marking */
|
||||
$f = IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php';
|
||||
|
||||
if ( file_exists( $f ) )
|
||||
|
||||
if ( is_file( $f ) )
|
||||
{
|
||||
require_once( $f );
|
||||
$classToLoad = IPSLib::loadLibrary( $f, 'itemMarking__'.$app, $app );
|
||||
|
||||
if ( ! @class_exists( 'itemMarking__' . $app ) )
|
||||
if ( !class_exists( $classToLoad ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -779,7 +787,7 @@ class classItemMarking
|
||||
{
|
||||
$times[] = intval( $this->_findLatestItemReset( $data, $app ) );
|
||||
}
|
||||
|
||||
|
||||
return IPSLib::fetchHighestNumber( $times );
|
||||
}
|
||||
|
||||
@@ -801,7 +809,7 @@ class classItemMarking
|
||||
|
||||
$times = array();
|
||||
|
||||
if( isset( $data['item_app_key_1'] ) )
|
||||
if ( isset( $data['item_app_key_1'] ) )
|
||||
{
|
||||
$mainKey = $this->_findMainRowByKey( $data, $app );
|
||||
|
||||
@@ -916,7 +924,7 @@ class classItemMarking
|
||||
*
|
||||
* @access public
|
||||
* @return int Number of rows saved
|
||||
* @deprecated 3.1.0
|
||||
* @deprecated 3.1.0 Is this really deprecated? It's still being called external to this class by sessions and markasread functions
|
||||
*/
|
||||
public function writeMyMarkersToDB()
|
||||
{
|
||||
@@ -1141,15 +1149,14 @@ class classItemMarking
|
||||
else
|
||||
{
|
||||
$_file = IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php';
|
||||
$_class = 'itemMarking__' . $app;
|
||||
|
||||
if ( file_exists( $_file ) )
|
||||
|
||||
if ( is_file( $_file ) )
|
||||
{
|
||||
require_once( $_file );
|
||||
|
||||
if( class_exists( $_class ) )
|
||||
$classToLoad = IPSLib::loadLibrary( $_file, 'itemMarking__'.$app, $app );
|
||||
|
||||
if( class_exists( $classToLoad ) )
|
||||
{
|
||||
$this->_moduleApps[ $app ] = new $_class( $this->registry );
|
||||
$this->_moduleApps[ $app ] = new $classToLoad( $this->registry );
|
||||
|
||||
return $this->_moduleApps[ $app ];
|
||||
}
|
||||
@@ -1176,7 +1183,7 @@ class classItemMarking
|
||||
protected function _makeKey( $data, $isCookie=FALSE )
|
||||
{
|
||||
/* Not interested in this for the main row */
|
||||
unset( $data['itemID'], $data['itemLastUpdate'] );
|
||||
unset( $data['itemID'], $data['itemLastUpdate'], $data['containerLastActivityDate'], $data['markDate'] );
|
||||
|
||||
return ( $isCookie === TRUE ) ? $data['item_app_key_1'] : md5( serialize( $data ) );
|
||||
}
|
||||
@@ -1255,7 +1262,7 @@ class classItemMarking
|
||||
*
|
||||
* @access protected
|
||||
* @param array Array of Member IDs
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
protected function _save( $memberIDs )
|
||||
{
|
||||
@@ -1302,16 +1309,19 @@ class classItemMarking
|
||||
'item_global_reset' => intval( $data['item_global_reset'] ),
|
||||
'item_last_update' => intval( $data['item_last_update'] ),
|
||||
'item_is_deleted' => 0 );
|
||||
|
||||
|
||||
/* Ensure $data is valid */
|
||||
foreach( $data as $k => $v )
|
||||
{
|
||||
if ( ! strstr( $k, 'item_' ) )
|
||||
{
|
||||
unset( $data[ $k ] );
|
||||
}
|
||||
}
|
||||
|
||||
/* Overwrite $data with the values in $row */
|
||||
$new_array = array_merge( $data, $row );
|
||||
|
||||
/* Somehow "member_id" column ends up in here... */
|
||||
if ( isset( $new_array['member_id'] ) )
|
||||
{
|
||||
unset( $new_array['member_id'] );
|
||||
}
|
||||
|
||||
/* Weed out useless rows */
|
||||
if ( ! $new_array['item_global_reset'] AND ! $new_array['item_unread_count'] AND ( ! $new_array['item_read_array'] OR $new_array['item_read_array'] == 'a:0:{}' ) )
|
||||
{
|
||||
@@ -1337,7 +1347,7 @@ class classItemMarking
|
||||
* classes are culled
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __myDestruct()
|
||||
{
|
||||
|
||||
@@ -1,413 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* Item Marking
|
||||
* Owner: Matt "Oh Lord, why did I get assigned this?" Mecham
|
||||
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @since 9th March 2005 11:03
|
||||
* @version $Revision: 5713 $
|
||||
*
|
||||
* @todo [Future] Perhaps find more ways to reduce the size of items_read
|
||||
* @todo [Future] Maybe add an IN_DEV tool to warn when markers have been cancelled out / size drastically reduced
|
||||
*/
|
||||
|
||||
require_once( dirname(__FILE__) . '/classItemMarking.php' );
|
||||
|
||||
class classItemMarking_debug extends classItemMarking
|
||||
{
|
||||
/**
|
||||
* Tracing this user?
|
||||
* @var bool
|
||||
*/
|
||||
private $TRACE = false;
|
||||
|
||||
/**
|
||||
* Marking session key
|
||||
* @var string
|
||||
*/
|
||||
private $SESSION_KEY = '';
|
||||
|
||||
/**
|
||||
* Marking URL
|
||||
* @var string
|
||||
*/
|
||||
private $URL = '';
|
||||
|
||||
/**
|
||||
* Method constructor
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry Object
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
parent::__construct( $registry );
|
||||
|
||||
/* Are we tracing this user? */
|
||||
list( $_groups, $_ids ) = explode( '&', trim( IPS_TOPICMARKERS_TRACE ) );
|
||||
|
||||
/* Groups */
|
||||
list( $_t, $groups ) = explode( '=', trim( $_groups ) );
|
||||
list( $_t, $ids ) = explode( '=', trim( $_ids ) );
|
||||
|
||||
if ( $groups )
|
||||
{
|
||||
foreach( explode( ',', $groups ) as $gid )
|
||||
{
|
||||
if ( $this->memberData['member_group_id'] == $gid )
|
||||
{
|
||||
$this->TRACE = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $ids AND ! $this->TRACE )
|
||||
{
|
||||
foreach( explode( ',', $ids ) as $id )
|
||||
{
|
||||
if ( $this->memberData['member_id'] == trim( $id ) )
|
||||
{
|
||||
$this->TRACE = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create session key */
|
||||
$this->SESSION_KEY = md5( uniqid( microtime() . 'tms', true ) );
|
||||
|
||||
/* Create URL */
|
||||
$this->URL = my_getenv('HTTP_HOST') . my_getenv('REQUEST_URI');
|
||||
|
||||
|
||||
/* Got a table? */
|
||||
//$this->DB->dropTable( 'core_topicmarker_debug' );
|
||||
if ( ! $this->DB->checkForTable( 'core_topicmarker_debug' ) )
|
||||
{
|
||||
$prefix = $this->registry->dbFunctions()->getPrefix();
|
||||
|
||||
$this->DB->query( "CREATE TABLE " . $prefix . "core_topicmarker_debug (
|
||||
marker_member_id INT(10) NOT NULL default 0,
|
||||
marker_session_key VARCHAR(32) NOT NULL default '',
|
||||
marker_message VARCHAR(255) NOT NULL default '',
|
||||
marker_data_freezer MEDIUMTEXT,
|
||||
marker_data_storage MEDIUMTEXT,
|
||||
marker_data_memory MEDIUMTEXT,
|
||||
marker_timestamp INT(10) NOT NULL default 0,
|
||||
marker_microtime VARCHAR(200) NOT NULL default '0',
|
||||
marker_url TEXT,
|
||||
marker_data_1 TEXT,
|
||||
marker_data_2 TEXT,
|
||||
marker_data_3 TEXT,
|
||||
marker_data_4 TEXT,
|
||||
marker_data_5 TEXT,
|
||||
KEY marker_member_id (marker_member_id),
|
||||
KEY marker_microtime (marker_microtime),
|
||||
KEY marker_session_key (marker_session_key),
|
||||
KEY marker_timestamp (marker_timestamp ) )" );
|
||||
}
|
||||
|
||||
/* Kick start the session off */
|
||||
$this->_addEntry( 'Marker session INIT done' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the read status of an item
|
||||
*
|
||||
* Forum example (forumID is mapped to :item_app_key_1). itemID is the topic ID
|
||||
*
|
||||
* <code>$read = $itemMarking->isRead( array( 'forumID' => 2, 'itemID' => 99, 'itemLastUpdate' => 1989098989 ) );</code>
|
||||
*
|
||||
* @access public
|
||||
* @param array Array of data
|
||||
* @param string Optional app
|
||||
* @return boolean TRUE is read / FALSE is unread
|
||||
*/
|
||||
public function isRead( $data, $app='' )
|
||||
{
|
||||
return parent::isRead( $data, $app );
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark as read
|
||||
*
|
||||
* Forum example (forumID is mapped to :item_app_key_1). itemID is the topic ID
|
||||
*
|
||||
* <code>$itemMarking->markAsRead( array( 'forumID' => 34, 'itemID' => 99 ) );</code>
|
||||
* <code>$itemMarking->markAsRead( array( 'forumID' => 34 ) );</code>
|
||||
*
|
||||
* @access public
|
||||
* @param array
|
||||
* @param string [App]
|
||||
* @return void
|
||||
*/
|
||||
public function markRead( $data, $app='' )
|
||||
{
|
||||
/* Add Debug entry */
|
||||
$this->_addEntry( 'Marked item as read ', array( 'marker_data_1' => $app, 'marker_data_2' => $data ) );
|
||||
|
||||
parent::markRead( $data, $app );
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks everything within an app as read
|
||||
*
|
||||
* @access public
|
||||
* @param string App
|
||||
* @return void
|
||||
*/
|
||||
public function markAppAsRead( $app )
|
||||
{
|
||||
parent::markAppAsRead( $app );
|
||||
|
||||
/* Add Debug entry */
|
||||
$this->_addEntry( 'Marked APP as read: ' . $app, array( 'marker_data_1' => $app ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the last time an item was marked
|
||||
* checks app reset... then the different key resets.. then an individual key
|
||||
*
|
||||
* In this example: itemID is within 'item_read_array'.
|
||||
* $lastReset = $this->fetchTimeLastMarked( array( 'forumID' => 2, 'itemID' => '99' ) );
|
||||
*
|
||||
* @access public
|
||||
* @param array Data
|
||||
* @param string Optional app
|
||||
* @return int Timestamp item was last marked or 0 if unread
|
||||
*/
|
||||
public function fetchTimeLastMarked( $data, $app='' )
|
||||
{
|
||||
return parent::fetchTimeLastMarked( $data, $app );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the unread count
|
||||
*
|
||||
* In this example we are retrieving the number of unread items for a forum id 2
|
||||
* $unreadCount = $this->fetchUnreadCount( array( 'forumID' => 2 ) );
|
||||
*
|
||||
* @access public
|
||||
* @param array Data
|
||||
* @param string App
|
||||
* @return int Number of unread items left
|
||||
*/
|
||||
public function fetchUnreadCount( $data, $app='' )
|
||||
{
|
||||
$num = parent::fetchUnreadCount( $data, $app );
|
||||
|
||||
/* Add Debug entry */
|
||||
$this->_addEntry( 'fetchUnreadCount - ' . $num, array( 'marker_data_1' => $app, 'marker_data_2' => $data ) );
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch read IDs since last global reset
|
||||
* Returns IDs read based on incoming data
|
||||
*
|
||||
* <code>$readIDs = $itemMarking->fetchReadIds( array( 'forumID' => 2 ) );</code>
|
||||
* @access public
|
||||
* @param array Array of data
|
||||
* @param strng [App]
|
||||
* @return array Array of read item IDs
|
||||
*/
|
||||
public function fetchReadIds( $data, $app='' )
|
||||
{
|
||||
parent::fetchReadIds( $data, $app );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save my markers to DB
|
||||
*
|
||||
* Saves the current values in $this->_itemMarkers back to the DB
|
||||
*
|
||||
* @access public
|
||||
* @return int Number of rows saved
|
||||
*/
|
||||
public function writeMyMarkersToDB()
|
||||
{
|
||||
parent::writeMyMarkersToDB();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manual clean up
|
||||
* Currently run via a task and in the __myDestruct method, but can be run from anywhere
|
||||
*
|
||||
* @access public
|
||||
* @param int Number of items to limit
|
||||
* @param int Number of hours (ago) to check
|
||||
* @param boolean Check for active sessions first
|
||||
* @return int Number of items cleaned
|
||||
*/
|
||||
public function manualCleanUp( $limit=0, $hours=6, $checkSessions=TRUE )
|
||||
{
|
||||
$num = parent::manualCleanUp( $limit, $hours, $checkSessions );
|
||||
|
||||
if ( $num !== FALSE )
|
||||
{
|
||||
$this->_addEntry( 'manualCleanUp called. Cleaned: ' . $num );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update topic markers
|
||||
*
|
||||
* @access protected
|
||||
* @param array Array of Member IDs
|
||||
* @return void
|
||||
*/
|
||||
protected function _save( $memberIDs )
|
||||
{
|
||||
parent::_save( $memberIDs );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update markers storage table
|
||||
*
|
||||
* @access protected
|
||||
* @return bool
|
||||
*/
|
||||
protected function _saveStorage()
|
||||
{
|
||||
$result = parent::_saveStorage();
|
||||
|
||||
if ( $result )
|
||||
{
|
||||
$this->_addEntry( 'Storage table updated' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manual destructor called by ips_MemberRegistry::__myDestruct()
|
||||
* Gives us a chance to do anything we need to do before other
|
||||
* classes are culled
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __myDestruct()
|
||||
{
|
||||
/* Add Debug entry */
|
||||
$this->_addEntry( 'Destructor Run' );
|
||||
|
||||
parent::__myDestruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add entry
|
||||
*
|
||||
* @access private
|
||||
* @param string Message
|
||||
* @param array Array of data
|
||||
* @return bool
|
||||
*/
|
||||
private function _addEntry( $message, $data=array() )
|
||||
{
|
||||
if ( $this->TRACE AND $this->memberData['member_id'] AND ! IPS_IS_TASK)
|
||||
{
|
||||
/* Clean up data */
|
||||
foreach( array( 1,2,3,4,5 ) as $n )
|
||||
{
|
||||
if ( isset( $data['marker_data_' . $n ] ) )
|
||||
{
|
||||
if ( is_array( $data['marker_data_' . $n ] ) )
|
||||
{
|
||||
$data['marker_data_' . $n ] = serialize( $data['marker_data_' . $n ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Add it.. */
|
||||
$this->DB->insert( 'core_topicmarker_debug', array( 'marker_member_id' => $this->memberData['member_id'],
|
||||
'marker_session_key' => $this->SESSION_KEY,
|
||||
'marker_message' => $message,
|
||||
'marker_data_freezer' => serialize( ( isset( $data['marker_data_freezer'] ) ) ? $data['marker_data_freezer'] : $this->_fetchFromFreezer() ),
|
||||
'marker_data_storage' => serialize( ( isset( $data['marker_data_storage'] ) ) ? $data['marker_data_storage'] : $this->_fetchFromCache() ),
|
||||
'marker_data_memory' => serialize( ( isset( $data['marker_data_memory'] ) ) ? $data['marker_data_memory'] : $this->_fetchFromMemory() ),
|
||||
'marker_timestamp' => time(),
|
||||
'marker_microtime' => microtime(),
|
||||
'marker_url' => $this->URL,
|
||||
'marker_data_1' => isset( $data['marker_data_1'] ),
|
||||
'marker_data_2' => isset( $data['marker_data_2'] ),
|
||||
'marker_data_3' => isset( $data['marker_data_3'] ),
|
||||
'marker_data_4' => isset( $data['marker_data_4'] ),
|
||||
'marker_data_5' => isset( $data['marker_data_5'] ) ) );
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch freezer markers
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function _fetchFromFreezer()
|
||||
{
|
||||
$items = array();
|
||||
|
||||
if ( $this->memberData['member_id'] )
|
||||
{
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'core_item_markers',
|
||||
'where' => 'item_member_id=' . $this->memberData['member_id'] ) );
|
||||
|
||||
$itemMarking = $this->DB->execute();
|
||||
|
||||
while( $row = $this->DB->fetch( $itemMarking ) )
|
||||
{
|
||||
$items[ $row['item_app'] ][ $row['item_key'] ] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch "hot" cache markers
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function _fetchFromCache()
|
||||
{
|
||||
$items = array();
|
||||
|
||||
if ( $this->memberData['member_id'] )
|
||||
{
|
||||
$items = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'core_item_markers_storage',
|
||||
'where' => 'item_member_id=' . $this->memberData['member_id'] ) );
|
||||
|
||||
$items = unserialize( $items['item_markers'] );
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch in memory cache markers
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function _fetchFromMemory()
|
||||
{
|
||||
return ( is_array( $this->_itemMarkers ) ) ? $this->_itemMarkers : array();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,6 +5,6 @@
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionboard.com/">IP.Board</a>
|
||||
<a href="http://www.invisionpower.com">IP.Board</a>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user