Introduced wrapper function addCreateTableSql(), fixed parameter order:
[mailer.git] / inc / extensions / ext-birthday.php
index ffbfc09f501eebb65ec9d6b1dbea3e85350fc830..330bc843d64b426ffbfcaa63702f2812a7b27d3c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 05/23/2004 *
- * ================                             Last change: 06/26/2004 *
+ * Mailer v0.2.1-FINAL                                Start: 05/23/2004 *
+ * ===================                          Last change: 06/26/2004 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : ext-birthday.php                                 *
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
+       die();
+} // END - if
 
 // Version number
-EXT_SET_VERSION("0.3.9");
-
-// Version history array (add more with , "0.1" and so on)
-EXT_SET_VER_HISTORY(array("0.0", "0.1", "0.2", "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"));
-
-switch ($EXT_LOAD_MODE)
-{
-case "register": // Do stuff when installation is running (modules.php?module=admin&action=login is called)
-       // SQL commands to run
-       ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` ADD birthday_sent VARCHAR(10) NOT NULL DEFAULT 0");
-       break;
-
-case "remove": // Do stuff when removing extension
-       // SQL commands to run
-       ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` DROP birthday_sent");
-       ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_user_birthday`");
-       ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE `what`='config_birthday'");
-       break;
-
-case "activate": // Do stuff when admin activates this extension
-       // SQL commands to run
-       ADD_SQL("");
-       break;
-
-case "deactivate": // Do stuff when admin deactivates this extension
-       // SQL commands to run
-       ADD_SQL("");
-       break;
-
-case "update": // Update an extension
-       switch ($EXT_VER)
-       {
-       case "0.1": // SQL queries for v0.1
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Wenn t&auml;glicher Reset war, wird eine ben&ouml;tigte Include-Datei nicht mehr von daily-reset.php eingebunden, sondern von der Erweiterungsdatei selber.");
-               break;
-
-       case "0.2": // SQL queries for v0.2
-               ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD birthday_points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
-               ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_user_birthday`");
-               ADD_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_user_birthday` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-chk_value VARCHAR(255) NOT NULL DEFAULT '',
-KEY(userid),
-PRIMARY KEY(id)
-) Type={!_TABLE_TYPE!}");
-               ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('setup','config_birthday','Geburtstagsmails','Stellen Sie hier ein, ob die Mitglieder {!POINTS!} (nicht automatisch) gutgeschrieben kommen sollen oder nicht.', 9)");
-
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Es kann nun eine Gutschrift an die Geburtstagmail angeh&auml;ngt werden. Diese wird erst beim Klick auf einen Best&auml;tigungslink gutgeschrieben.");
-               break;
-
-       case "0.2.1": // SQL queries for v0.2.1
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Abstand zwischen ausgesendeter Geburtstagsmails auf 364 Tage erh&ouml;ht.");
-               break;
-
-       case "0.2.4": // SQL queries for v0.2.4
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Laden der birthday_mails.php &quot;intelligenter&quot; per Datenfeld und Lade-Schleife in load_extensions.php realisiert.");
-               break;
-
-       case "0.2.5": // SQL queries for v0.2.5
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
-               break;
-
-       case "0.2.6": // SQL queries for v0.2.6
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Problem mit Speicherung der Einstellungen beseitigt.");
-               break;
-
-       case "0.2.7": // SQL queries for v0.2.7
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Sicherheitsupdate am Script <u>birtday_confirm.php</u> durchgef&uuml;hrt.");
-               break;
-
-       case "0.2.8": // SQL queries for v0.2.8
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Vergessenes <strong>_OB_CACHING</strong> gesetzt.");
-               break;
-
-       case "0.2.9": // SQL queries for v0.2.9
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Seit <a href=\"#\">Patch 340</a> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
-               break;
-
-       case "0.3.0": // SQL queries for v0.3.0
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Ausgabe des generierten HTML-Codes nach <u>inc/footer.php</u> verlagert.");
-               break;
-
-       case "0.3.1": // SQL queries for v0.3.1
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Wort <strong>Punkte</strong> dynamisiert.");
-               break;
-
-       case "0.3.2": // SQL queries for v0.3.2
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Sicherheitsupdate: SQL-Anweisungen gesch&uuml;tzt.");
-               break;
-
-       case "0.3.3": // SQL queries for v0.3.3
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Bitte verschieben Sie die birthday-Templates (Ordner: {!PATH!}/templates/".GET_LANGUAGE()."/html/) in den neuen Order birthday!");
-               break;
-
-       case "0.3.4": // SQL queries for v0.3.4
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Abspeichern von Einstellungen repariert.");
-               break;
+setThisExtensionVersion('0.3.9');
+
+// Version history array (add more with , '0.1.0' and so on)
+setExtensionVersionHistory(array('0.0', '0.1.0', '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'));
+
+switch (getExtensionMode()) {
+       case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
+               // SQL commands to run
+               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD birthday_sent VARCHAR(10) NOT NULL DEFAULT 0");
+               break;
+
+       case 'remove': // Do stuff when removing extension
+               // SQL commands to run
+               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` DROP birthday_sent");
+               addDropTableSql('user_birthday');
+               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='config_birthday'");
+               break;
+
+       case 'activate': // Do stuff when admin activates this extension
+               // SQL commands to run
+               addExtensionSql('');
+               break;
+
+       case 'deactivate': // Do stuff when admin deactivates this extension
+               // SQL commands to run
+               addExtensionSql('');
+               break;
+
+       case 'update': // Update an extension
+               switch (getCurrentExtensionVersion()) {
+                       case '0.1.0': // SQL queries for v0.1
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Wenn t&auml;glicher Reset war, wird eine ben&ouml;tigte Include-Datei nicht mehr von daily-reset.php eingebunden, sondern von der Erweiterungsdatei selber.");
+                               break;
+
+                       case '0.2.0': // SQL queries for v0.2
+                               addConfigAddSql('birthday_points', "BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
+                               addDropTableSql('user_birthday');
+                               addCreateTableSql('user_birthday', "(
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`chk_value` VARCHAR(255) NOT NULL DEFAULT '',
+KEY (`userid`),
+PRIMARY KEY (`id`)
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Pending birthday codes'");
+                               addAdminMenuSql('setup','config_birthday','Geburtstagsmails','Stellen Sie hier ein, ob die Mitglieder {OPEN_CONFIG}POINTS{CLOSE_CONFIG} (nicht automatisch) gutgeschrieben kommen sollen oder nicht.', 9);
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Es kann nun eine Gutschrift an die Geburtstagmail angeh&auml;ngt werden. Diese wird erst beim Klick auf einen Best&auml;tigungslink gutgeschrieben.");
+                               break;
+
+                       case '0.2.1': // SQL queries for v0.2.1
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Abstand zwischen ausgesendeter Geburtstagsmails auf 364 Tage erh&ouml;ht.");
+                               break;
+
+                       case '0.2.4': // SQL queries for v0.2.4
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Laden der birthday_mails.php &quot;intelligenter&quot; per Datenfeld und Lade-Schleife in load_extensions.php realisiert.");
+                               break;
+
+                       case '0.2.5': // SQL queries for v0.2.5
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
+                               break;
+
+                       case '0.2.6': // SQL queries for v0.2.6
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Problem mit Speicherung der Einstellungen beseitigt.");
+                               break;
+
+                       case '0.2.7': // SQL queries for v0.2.7
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Sicherheitsupdate am Script <u>birtday_confirm.php</u> durchgef&uuml;hrt.");
+                               break;
+
+                       case '0.2.8': // SQL queries for v0.2.8
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Vergessenes <strong>_OB_CACHING</strong> gesetzt.");
+                               break;
+
+                       case '0.2.9': // SQL queries for v0.2.9
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
+                               break;
+
+                       case '0.3.0': // SQL queries for v0.3.0
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Ausgabe des generierten HTML-Codes nach <u>inc/footer.php</u> verlagert.");
+                               break;
+
+                       case '0.3.1': // SQL queries for v0.3.1
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Wort <strong>Punkte</strong> dynamisiert.");
+                               break;
+
+                       case '0.3.2': // SQL queries for v0.3.2
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Sicherheitsupdate: SQL-Anweisungen gesch&uuml;tzt.");
+                               break;
+
+                       case '0.3.3': // SQL queries for v0.3.3
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Bitte verschieben Sie die birthday-Templates (Ordner: {?PATH?}/templates/".getLanguage()."/html/) in den neuen Order birthday!");
+                               break;
+
+                       case '0.3.4': // SQL queries for v0.3.4
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
+                               break;
+
+                       case '0.3.5': // SQL queries for v0.3.5
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
+                               break;
+
+                       case '0.3.6': // SQL queries for v0.3.6
+                               addConfigAddSql('birthday_mode', "ENUM('DIRECT','REF') NOT NULL DEFAULT 'DIRECT'");
+                               addConfigAddSql('birthday_active', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Verg&uuml;tungsmodus des Geburtstagsbonus einstellbar.");
+                               break;
+
+                       case '0.3.7': // SQL queries for v0.3.7
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Im Script <strong>inc/birthday_mails.php</strong> hat sich ein Zeichen mit dem Code 160 eingeschlichen, welches einen <strong>Parser Error</strong> verursachte, aber wie eine gew&ouml;hnliche Leerstelle aussah.");
+                               break;
+
+                       case '0.3.8': // SQL queries for v0.3.8
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
+                               break;
+
+                       case '0.3.9': // SQL queries for v0.3.9
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `birth_day` `birth_day` SMALLINT(2) UNSIGNED ZEROFILL NOT NULL DEFAULT '01',
+CHANGE `birth_month` `birth_month` SMALLINT(2) UNSIGNED ZEROFILL NOT NULL DEFAULT '01',
+CHANGE `birth_year` `birth_year` SMALLINT(4) UNSIGNED ZEROFILL NOT NULL DEFAULT 1970");
 
-       case "0.3.5": // SQL queries for v0.3.5
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Vorbereitung auf die neue Mediendaten v0.0.4.");
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Datenbankspalten umgestellt auf SMALLINT() UNSIGNED ZEROFILL.");
+                               break;
+               }
                break;
 
-       case "0.3.6": // SQL queries for v0.3.6
-               ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD birthday_mode ENUM('DIRECT','REF') NOT NULL DEFAULT 'DIRECT'");
-               ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD birthday_active ENUM('Y','N') NOT NULL DEFAULT 'N'");
-
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Verg&uuml;tungsmodus des Geburtstagsbonus einstellbar.");
+       case 'modify': // When the extension got modified
                break;
 
-       case "0.3.7": // SQL queries for v0.3.7
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Im Script <strong>inc/birthday_mails.php</strong> hat sich ein Zeichen mit dem Code 160 eingeschlichen, welches einen <strong>Parser Error</strong> verursachte, aber wie eine gew&ouml;hnliche Leerstelle aussah.");
+       case 'test': // For testing purposes
                break;
 
-       case "0.3.8": // SQL queries for v0.3.8
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
+       case 'init': // Do stuff when extension is initialized
                break;
 
-       case "0.3.9": // SQL queries for v0.3.9
-               ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` CHANGE `birth_day` `birth_day` SMALLINT(2) UNSIGNED ZEROFILL NOT NULL DEFAULT '01',
-CHANGE `birth_month` `birth_month` SMALLINT(2) UNSIGNED ZEROFILL NOT NULL DEFAULT '01',
-CHANGE `birth_year` `birth_year` SMALLINT(4) UNSIGNED ZEROFILL NOT NULL DEFAULT 1970");
-
-               // Update notes (these will be set as task text!)
-               EXT_SET_UPDATE_NOTES("Datenbankspalten umgestellt auf SMALLINT() UNSIGNED ZEROFILL.");
+       default: // Unknown extension mode
+               logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
                break;
-       }
-       break;
-
-case "modify": // When the extension got modified
-       break;
-
-case "test": // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
-       break;
-
-default: // Do stuff when extension is loaded
-       if ((isResetModeEnabled()) && (getConfig('birthday_points') > 0)) {
-               // Daily reset was run and we shall pay points so we start checking for members who
-               // has a birthday for today
-               $INC_POOL[] = sprintf("%sinc/mails/birthday_mails.php", constant('PATH'));
-       }
-       break;
 }
 
-//
+// [EOF]
 ?>