Marked some unfinished extensions as 'work-in-progress'
[mailer.git] / inc / extensions / ext-bonus.php
index b30b1ba113dac0c2af2a609d8dba624dd138e2c0..1227a605624ec35251f09433647693d369083252 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 04/04/2004 *
- * ================                             Last change: 06/13/2005 *
+ * Mailer v0.2.1-FINAL                                Start: 04/04/2004 *
+ * ===================                          Last change: 06/13/2005 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : ext-bonus.php                                    *
@@ -18,6 +18,7 @@
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -42,10 +43,10 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Version of this extension
-setThisExtensionVersion('0.8.9');
+setThisExtensionVersion('0.9.0');
 
 // Version history array (add more with , '0.1.0' and so on)
-setExtensionVersionHistory(array('0.0', '0.1.6', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5', '0.7.6', '0.7.7', '0.7.8', '0.7.9', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4', '0.8.5', '0.8.6', '0.8.7', '0.8.8', '0.8.9'));
+setExtensionVersionHistory(array('0.0', '0.1.6', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5', '0.7.6', '0.7.7', '0.7.8', '0.7.9', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4', '0.8.5', '0.8.6', '0.8.7', '0.8.8', '0.8.9', '0.9.0'));
 
 switch (getExtensionMode()) {
        case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
@@ -54,22 +55,22 @@ switch (getExtensionMode()) {
                addMemberMenuSql('main','bonus','Bonuspunkte','N','Y',7);
                addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bonus`");
                addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bonus` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-cat_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-subject VARCHAR(255) NOT NULL DEFAULT '',
-text LONGTEXT NOT NULL,
-receivers LONGTEXT NOT NULL,
-points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-time TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
-data_type ENUM('NEW','QUEUE','SEND') NOT NULL DEFAULT 'NEW',
-timestamp VARCHAR(10) NOT NULL DEFAULT 0,
-url VARCHAR(255) NOT NULL DEFAULT '',
-target_send BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-clicks BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-mails_sent BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-KEY (cat_id),
-PRIMARY KEY  (id)
-)TYPE={?_TABLE_TYPE?}");
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`cat_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`subject` VARCHAR(255) NOT NULL DEFAULT '',
+`text` LONGTEXT NOT NULL,
+`receivers` LONGTEXT NOT NULL,
+`points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`time` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
+`data_type` ENUM('NEW','QUEUE','SEND') NOT NULL DEFAULT 'NEW',
+`timestamp` VARCHAR(10) NOT NULL DEFAULT 0,
+`url` VARCHAR(255) NOT NULL DEFAULT '',
+`target_send` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`mails_sent` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+KEY (`cat_id`),
+PRIMARY KEY  (`id`)
+)TYPE={?_TABLE_TYPE?} COMMENT='Bonus mails'");
                addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` MODIFY `link_type` ENUM('NORMAL','BONUS') NOT NULL DEFAULT 'NORMAL'");
                addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` ADD `bonus_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
                addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` ADD INDEX (`bonus_id`)");
@@ -87,6 +88,9 @@ PRIMARY KEY  (id)
                addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bonus_urls`");
                addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bonus_customer`");
                addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bonus_turbo`");
+
+               // Unregister filter
+               unregisterFilter('member_login_check', 'ADD_LOGIN_BONUS', true, getExtensionDryRun());
                break;
 
        case 'activate': // Do stuff when admin activates this extension
@@ -107,14 +111,14 @@ PRIMARY KEY  (id)
                switch (getCurrentExtensionVersion()) {
                        case '0.1.6': // SQL queries for v0.1.6
                                // Update notes (these will be set as task text!)
-                               setExtensionUpdateNotes("Paid-Links wurden verschoben in die Erweiterung <strong>paidlinks</strong>.");
+                               setExtensionUpdateNotes("Paid-Links wurden verschoben in die Erweiterung <strong>sponsor</strong>.");
                                break;
 
                        case '0.2.0': // SQL queries for v0.2.0
                                addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `target_send`=`mails_sent` WHERE `target_send`=0 AND `mails_sent`>0 AND `receivers` != ''");
 
                                // Update notes (these will be set as task text!)
-                               setExtensionUpdateNotes("Behebt ein Versand-Problem mit den Bonus-Mails. Es wurde die Spalte target_send nicht beim Einf&uuml;gen der Buchung gessetzt. Bitte laden Sie sich dazu - wenn nicht bereits geschehen - alle Patches bis mindestens Patch 240 unter <a href=\"{?URL?}/modules.php?module=admin&amp;what=updates\">Updates pr&uuml;fen</a> herunter.");
+                               setExtensionUpdateNotes("Behebt ein Versand-Problem mit den Bonus-Mails. Es wurde die Spalte target_send nicht beim Einf&uuml;gen der Buchung gessetzt. Bitte laden Sie sich dazu - wenn nicht bereits geschehen - alle Patches bis mindestens Patch 240 unter <strike>Updates pr&uuml;fen</strike> herunter.");
                                break;
 
                        case '0.2.1': // SQL queries for v0.2.1
@@ -135,17 +139,17 @@ PRIMARY KEY  (id)
                        case '0.2.2': // SQL queries for v0.2.2
                                addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bonus_turbo`");
                                addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bonus_turbo` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-mail_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-bonus_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-level BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-points FLOAT(20,3) NOT NULL DEFAULT '0.000',
-timemark VARCHAR(32) NOT NULL DEFAULT 0,
-PRIMARY KEY (id),
-KEY mail_id (mail_id),
-KEY bonus_id (bonus_id),
-KEY userid (userid)
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`mail_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`bonus_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`points` FLOAT(20,3) NOT NULL DEFAULT '0.000',
+`timemark` VARCHAR(32) NOT NULL DEFAULT 0,
+PRIMARY KEY (`id`),
+INDEX `mail_id` (`mail_id`),
+INDEX `bonus_id` (`bonus_id`),
+INDEX `userid` (`userid`)
 ) TYPE={?_TABLE_TYPE?}");
 
                                // Update notes (these will be set as task text!)
@@ -170,7 +174,7 @@ KEY userid (userid)
                                addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bonus_customer`");
 
                                // Update notes (these will be set as task text!)
-                               setExtensionUpdateNotes("Tabellen <u>{?_MYSQL_PREFIX?}_bonus_urls</u> und <u>{?_MYSQL_PREFIX?}_bonus_customer</u> entfernt, da dies bald von der Erweiterung <u>paidlinks</u> erledigt wird.");
+                               setExtensionUpdateNotes("Tabellen <u>{?_MYSQL_PREFIX?}_bonus_urls</u> und <u>{?_MYSQL_PREFIX?}_bonus_customer</u> entfernt, da dies bald von der Erweiterung <u>sponsor</u> erledigt wird.");
                                break;
 
                        case '0.2.6': // SQL queries for v0.2.6
@@ -184,12 +188,12 @@ KEY userid (userid)
                                break;
 
                        case '0.2.8': // SQL queries for v0.2.8
-                               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET timestamp=0 WHERE timestamp='0000000000'");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus_turbo` CHANGE points points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` CHANGE turbo_bonus turbo_bonus FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` CHANGE login_bonus login_bonus FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE turbo_bonus turbo_bonus FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE login_bonus login_bonus FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
+                               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `timestamp`=0 WHERE `timestamp`='0000000000'");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_bonus_turbo` CHANGE `points` `points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` CHANGE `turbo_bonus` `turbo_bonus` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` CHANGE `login_bonus` `login_bonus` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `turbo_bonus` `turbo_bonus` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `login_bonus` `login_bonus` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("5 Nachkommastellen implementiert");
@@ -302,7 +306,7 @@ KEY userid (userid)
                                break;
 
                        case '0.4.7': // SQL queries for v0.4.7
-                               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET login_bonus=0, turbo_bonus=0,bonus_ref=0,bonus_order=0,bonus_stats=0");
+                               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `login_bonus`=0, `turbo_bonus`=0, `bonus_ref`=0, `bonus_order`=0, `bonus_stats`=0");
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Die Aktiv-Rallye wurde nicht auf 0 {?POINTS?} gesetzt. Dieser Fehler ist nun behoben. Allerdings ist mit diesem Update auch die Aktiv-Rallye zur&uuml;ckgesetzt worden.");
@@ -351,7 +355,7 @@ KEY userid (userid)
                        case '0.5.6': // SQL queries for v0.5.6
                                // Get current month
                                $curr = date('m', time());
-                               if (strlen($curr) == 1) $curr = 0 . $curr;
+                               if (strlen($curr) == 1) $curr = '0' . $curr;
                                if ($curr == "00") $curr = "12";
 
                                // Generate timemark...
@@ -538,6 +542,14 @@ WHERE `last_online` < ".$mark." ORDER BY `userid` ASC");
                                // Update notes
                                setExtensionUpdateNotes("Benachrichtigungsmails f&uuml;r z.B. Bettel- oder Aktiv-Rallye werden nun angezeigt.");
                                break;
+
+                       case '0.9.0': // SQL queries for v0.9.0
+                               // Register filter
+                               registerFilter('member_login_check', 'ADD_LOGIN_BONUS', false, true, getExtensionDryRun());
+
+                               // Update notes
+                               setExtensionUpdateNotes("Filter hinzugef&uuml;gt der den Login-Bonus aktualisiert (bzw. soll) (internes TODO).");
+                               break;
                }
                break;
 
@@ -570,7 +582,7 @@ WHERE `last_online` < ".$mark." ORDER BY `userid` ASC");
                break;
 
        default: // Unknown extension mode
-               DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));
+               logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
                break;
 } // END - switch