Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -98,7 +98,7 @@ class _Advertisement extends \IPS\Patterns\ActiveRecord
|
||||
$where[] = array( "ad_start<?", time() );
|
||||
$where[] = array( "(ad_end=0 OR ad_end>?)", time() );
|
||||
|
||||
if( !isset( \IPS\Dispatcher::i()->dispatcherController ) OR !\IPS\Dispatcher::i()->dispatcherController->isContentPage )
|
||||
if( \IPS\Dispatcher::hasInstance() AND ( !isset( \IPS\Dispatcher::i()->dispatcherController ) OR !\IPS\Dispatcher::i()->dispatcherController->isContentPage ) )
|
||||
{
|
||||
$where[] =array( 'ad_nocontent_page_output=?', 1 );
|
||||
}
|
||||
@@ -440,7 +440,7 @@ class _Advertisement extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
if( \count( static::$advertisementIds ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_advertisements', "ad_impressions=ad_impressions+1", "ad_id IN(" . implode( ',', static::$advertisementIds ) . ")" );
|
||||
static::updateCounter( static::$advertisementIds );
|
||||
|
||||
/* Reset in case execution continues and more ads are shown */
|
||||
static::$advertisementIds = array();
|
||||
@@ -457,10 +457,43 @@ class _Advertisement extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
if( \count( static::$advertisementIdsEmail ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_advertisements', "ad_impressions=ad_impressions+" . $impressions, "ad_id IN(" . implode( ',', static::$advertisementIdsEmail ) . ")" );
|
||||
static::updateCounter( static::$advertisementIdsEmail, $impressions );
|
||||
|
||||
/* Reset in case execution continues and more ads are sent */
|
||||
static::$advertisementIdsEmail = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the advert impression counters
|
||||
*
|
||||
* @param array $ids Array of IDs
|
||||
* @param int $by Number to increment by
|
||||
* @return void
|
||||
*/
|
||||
protected static function updateCounter( array $ids, $by=1 )
|
||||
{
|
||||
$countUpdated = false;
|
||||
if ( \IPS\REDIS_ENABLED and \IPS\CACHE_METHOD == 'Redis' and ( \IPS\CACHE_CONFIG or \IPS\REDIS_CONFIG ) )
|
||||
{
|
||||
foreach( $ids as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Redis::i()->zIncrBy( 'advert_impressions', $by, $id );
|
||||
$countUpdated = true;
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $countUpdated )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_advertisements', "ad_impressions=ad_impressions+" . $by, "ad_id IN(" . implode( ',', $ids ) . ")" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user