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()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user