From 4a204eb79d4076806a62e30dc35f7001a66e9d6e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 30 Dec 2010 18:45:43 +0000 Subject: [PATCH] Extension ext-forced enhanced, some code cleanup: - ext-forced enhanced: Table mxchange_forced_campaigns_ads is a n-n table which connects the ads with the campaigns - In same extension file more UNSIGNED added and other improvements - Removed old-lost value init in getConfig() - TODOs.txt updated --- DOCS/TODOs.txt | 2 +- inc/config-functions.php | 5 +---- inc/extensions/ext-forced.php | 31 ++++++++++++++++++++----------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 046d0145c2..0144fdb0df 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -6,7 +6,7 @@ ./inc/autopurge/purge-inact.php:55: // @TODO Rewrite these if() blocks to a filter ./inc/cache/config-local.php:124:// @TODO Rewrite the following three constants, somehow... ./inc/classes/cachesystem.class.php:501: // @TODO Add support for more types which break in last else-block -./inc/config-functions.php:139: // @TODO Make this all better... :-/ +./inc/config-functions.php:136: // @TODO Make this all better... :-/ ./inc/expression-functions.php:164:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again ./inc/expression-functions.php:46: // @TODO is escapeQuotes() enougth for strings with single/double quotes? ./inc/extensions/ext-html_mail.php:136: // @TODO Move these arrays into config diff --git a/inc/config-functions.php b/inc/config-functions.php index 209743115a..c7f4cdaa39 100644 --- a/inc/config-functions.php +++ b/inc/config-functions.php @@ -71,9 +71,6 @@ function initConfig () { // Getter for $GLOBALS['config'] entries function getConfig ($configEntry) { - // Default value - $value = null; - // Is the entry there? if (!isConfigEntrySet($configEntry)) { // Raise an error of missing entries @@ -104,7 +101,7 @@ function mergeConfig ($newConfig) { // Increment or init with given value or 1 as default the given config entry function incrementConfigEntry ($configEntry, $value=1) { - // Increment it if set or init it with 1 + // Increment it if set or init it with $value if (isConfigEntrySet($configEntry)) { $GLOBALS['config'][$configEntry] += $value; } else { diff --git a/inc/extensions/ext-forced.php b/inc/extensions/ext-forced.php index 0047f8a533..a8a06e8090 100644 --- a/inc/extensions/ext-forced.php +++ b/inc/extensions/ext-forced.php @@ -60,14 +60,14 @@ switch (getExtensionMode()) { `forced_ads_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT , `forced_ads_ad_url` VARCHAR( 255 ) NULL DEFAULT NULL , `forced_ads_click_url` VARCHAR( 255 ) NOT NULL , -`forced_ads_width` SMALLINT( 3 ) NULL DEFAULT NULL , -`forced_ads_height` SMALLINT( 3 ) NULL DEFAULT NULL , +`forced_ads_width` SMALLINT( 3 ) UNSIGNED NULL DEFAULT NULL , +`forced_ads_height` SMALLINT( 3 ) UNSIGNED NULL DEFAULT NULL , `forced_ads_alt_text` VARCHAR( 255 ) NULL DEFAULT NULL , `forced_ads_framebreaker` ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'Y', -`forced_ads_counter_views` BIGINT( 20 ) NOT NULL DEFAULT 0, -`forced_ads_counter_clicks` BIGINT( 20 ) NOT NULL DEFAULT 0, -`forced_ads_reload_lock` BIGINT( 20 ) NOT NULL DEFAULT 0, -`forced_ads_min_stay` BIGINT( 20 ) NOT NULL DEFAULT 0, +`forced_ads_views_counter` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0, +`forced_ads_clicks_counter` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0, +`forced_ads_reload_lock` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0, +`forced_ads_min_stay` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY ( `forced_ads_id` ) ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Ads Data'"); @@ -75,26 +75,34 @@ PRIMARY KEY ( `forced_ads_id` ) addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_forced_campaigns`'); addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_forced_campaigns` ( `forced_campaign_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT , -`forced_ads_id` BIGINT( 20 ) UNSIGNED NOT NULL , `forced_campaign_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `forced_campaign_status` ENUM( 'ACTIVE', 'PENDING', 'EXPIRED', 'LOCKED' ) NOT NULL DEFAULT 'PENDING', `forced_campaign_lock_reason` VARCHAR( 255 ) NULL DEFAULT NULL , `forced_campaign_lock_timetstamp` TIMESTAMP NULL DEFAULT NULL , `forced_campaign_expired` TIMESTAMP NULL DEFAULT NULL , -`forced_campaign_ordered_clicks` BIGINT( 20 ) NOT NULL DEFAULT 0, +`forced_campaign_ordered_clicks` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0, `forced_campaign_costs_api` FLOAT( 20 , 5 ) UNSIGNED NULL DEFAULT NULL, `forced_campaign_price_api` FLOAT( 20 , 5 ) UNSIGNED NULL DEFAULT NULL, `forced_costs_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL, -INDEX ( `forced_ads_id` ), INDEX ( `forced_costs_id` ), PRIMARY KEY ( `forced_campaign_id` ) ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaign Data'"); - // - Campaigns<->User + // - Campaigns <-> Ads + addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_forced_campaigns_ads`'); + addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_forced_campaigns_ads` ( +`forced_campaign_ads_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT , +`forced_campaign_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL , +`forced_ads_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL , +UNIQUE `ads_campaign` ( `forced_campaign_id` , `forced_ads_id` ), +PRIMARY KEY ( `forced_campaign_ads_id` ) +) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaigns<->Ads'"); + + // - Campaigns <-> User addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_forced_campaigns_user`'); addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_forced_campaigns_user` ( `forced_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT , -`forced_campaign_id` BIGINT( 20 ) UNSIGNED NOT NULL , +`forced_campaign_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL , `forced_user_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL , `forced_user_type` ENUM( 'MEMBER', 'SPONSOR', 'ADMIN', 'API' ) NULL DEFAULT NULL , UNIQUE `forced_campaign_user` ( `forced_campaign_id` , `forced_user_id` , `forced_user_type` ), @@ -117,6 +125,7 @@ PRIMARY KEY ( `forced_costs_id` ) // SQL commands to run addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_forced_ads`'); addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_forced_campaigns`'); + addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_forced_campaigns_ads`'); addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_forced_campaigns_user`'); addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_forced_costs`'); break; -- 2.39.2