Extension ext-forced enhanced, some code cleanup:
authorRoland Häder <roland@mxchange.org>
Thu, 30 Dec 2010 18:45:43 +0000 (18:45 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 30 Dec 2010 18:45:43 +0000 (18:45 +0000)
- 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
inc/config-functions.php
inc/extensions/ext-forced.php

index 046d0145c2806877fe70d4ae61b0fb022e193cdb..0144fdb0dfdf9f0eb2a1e9e95e1a036865fefa8c 100644 (file)
@@ -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
index 209743115ad8d477ba58a38c1826d4fd09d0e1d3..c7f4cdaa397e6a44de3192727e1e08cc2740e71e 100644 (file)
@@ -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 {
index 0047f8a53302690b96e1197e46810169691e68a0..a8a06e809034ac92fed2cb077786ba67530b8750 100644 (file)
@@ -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;