Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Advertisements Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 30 Sept 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ class _Advertisement extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
/**
|
||||
* @brief Advertisements loaded during this request (used to update impression count)
|
||||
* @see \IPS\Output::sendOutput()
|
||||
* @see static::updateImpressions()
|
||||
*/
|
||||
public static $advertisementIds = array();
|
||||
|
||||
@@ -68,7 +68,7 @@ class _Advertisement extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
static::$advertisements = array();
|
||||
|
||||
if( !isset( \IPS\Data\Cache::i()->advertisements ) )
|
||||
if( !isset( \IPS\Data\Cache::i()->advertisements ) OR \IPS\Data\Cache::i()->advertisements === NULL )
|
||||
{
|
||||
$ads = array();
|
||||
|
||||
@@ -156,7 +156,12 @@ class _Advertisement extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
case 'least':
|
||||
usort( static::$advertisements[ $location ], function( $a, $b ){
|
||||
return strcmp( $a->impressions, $b->impressions );
|
||||
if ( $a->impressions == $b->impressions )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ( $a->impressions < $b->impressions ) ? -1 : 1;
|
||||
} );
|
||||
|
||||
$advertisement = static::$advertisements[ $location ][0];
|
||||
@@ -205,7 +210,7 @@ class _Advertisement extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
/* Store the id so we can update impression count and return the ad */
|
||||
self::$advertisementIds[] = $this->id;
|
||||
static::$advertisementIds[] = $this->id;
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -287,4 +292,18 @@ class _Advertisement extends \IPS\Patterns\ActiveRecord
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update ad impressions for advertisements loaded
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function updateImpressions()
|
||||
{
|
||||
if( count( static::$advertisementIds ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_advertisements', "ad_impressions=ad_impressions+1", "ad_id IN(" . implode( ',', static::$advertisementIds ) . ")" );
|
||||
unset( \IPS\Data\Cache::i()->advertisements );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user