New naming convention applied to many functions, see #118 for details
[mailer.git] / inc / extensions / ext-birthday.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 05/23/2004 *
4  * ================                             Last change: 06/26/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-birthday.php                                 *
8  * -------------------------------------------------------------------- *
9  * Short description : Sends out happy-birthday mails                   *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Versendet Geburtstagsmails an die Mitglieder     *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
42         require($INC);
43 }
44
45 // Version number
46 EXT_SET_VERSION('0.3.9');
47
48 // Version history array (add more with , '0.1.0' and so on)
49 EXT_SET_VER_HISTORY(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'));
50
51 switch ($EXT_LOAD_MODE)
52 {
53 case 'register': // Do stuff when installation is running (modules.php?module=admin&action=login is called)
54         // SQL commands to run
55         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` ADD birthday_sent VARCHAR(10) NOT NULL DEFAULT 0");
56         break;
57
58 case 'remove': // Do stuff when removing extension
59         // SQL commands to run
60         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` DROP birthday_sent");
61         ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_user_birthday`");
62         ADD_EXT_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE `what`='config_birthday'");
63         break;
64
65 case 'activate': // Do stuff when admin activates this extension
66         // SQL commands to run
67         ADD_EXT_SQL("");
68         break;
69
70 case 'deactivate': // Do stuff when admin deactivates this extension
71         // SQL commands to run
72         ADD_EXT_SQL("");
73         break;
74
75 case 'update': // Update an extension
76         switch ($EXT_VER)
77         {
78         case '0.1.0': // SQL queries for v0.1
79                 // Update notes (these will be set as task text!)
80                 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.");
81                 break;
82
83         case '0.2.0': // SQL queries for v0.2
84                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD birthday_points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
85                 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_user_birthday`");
86                 ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_user_birthday` (
87 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
88 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
89 points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
90 chk_value VARCHAR(255) NOT NULL DEFAULT '',
91 KEY(userid),
92 PRIMARY KEY(id)
93 ) Type={!_TABLE_TYPE!}");
94                 ADD_EXT_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)");
95
96                 // Update notes (these will be set as task text!)
97                 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.");
98                 break;
99
100         case '0.2.1': // SQL queries for v0.2.1
101                 // Update notes (these will be set as task text!)
102                 EXT_SET_UPDATE_NOTES("Abstand zwischen ausgesendeter Geburtstagsmails auf 364 Tage erh&ouml;ht.");
103                 break;
104
105         case '0.2.4': // SQL queries for v0.2.4
106                 // Update notes (these will be set as task text!)
107                 EXT_SET_UPDATE_NOTES("Laden der birthday_mails.php &quot;intelligenter&quot; per Datenfeld und Lade-Schleife in load_extensions.php realisiert.");
108                 break;
109
110         case '0.2.5': // SQL queries for v0.2.5
111                 // Update notes (these will be set as task text!)
112                 EXT_SET_UPDATE_NOTES("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
113                 break;
114
115         case '0.2.6': // SQL queries for v0.2.6
116                 // Update notes (these will be set as task text!)
117                 EXT_SET_UPDATE_NOTES("Problem mit Speicherung der Einstellungen beseitigt.");
118                 break;
119
120         case '0.2.7': // SQL queries for v0.2.7
121                 // Update notes (these will be set as task text!)
122                 EXT_SET_UPDATE_NOTES("Sicherheitsupdate am Script <u>birtday_confirm.php</u> durchgef&uuml;hrt.");
123                 break;
124
125         case '0.2.8': // SQL queries for v0.2.8
126                 // Update notes (these will be set as task text!)
127                 EXT_SET_UPDATE_NOTES("Vergessenes <strong>_OB_CACHING</strong> gesetzt.");
128                 break;
129
130         case '0.2.9': // SQL queries for v0.2.9
131                 // Update notes (these will be set as task text!)
132                 EXT_SET_UPDATE_NOTES("Seit <a href=\"#\">Patch 340</a> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
133                 break;
134
135         case '0.3.0': // SQL queries for v0.3.0
136                 // Update notes (these will be set as task text!)
137                 EXT_SET_UPDATE_NOTES("Ausgabe des generierten HTML-Codes nach <u>inc/footer.php</u> verlagert.");
138                 break;
139
140         case '0.3.1': // SQL queries for v0.3.1
141                 // Update notes (these will be set as task text!)
142                 EXT_SET_UPDATE_NOTES("Wort <strong>Punkte</strong> dynamisiert.");
143                 break;
144
145         case '0.3.2': // SQL queries for v0.3.2
146                 // Update notes (these will be set as task text!)
147                 EXT_SET_UPDATE_NOTES("Sicherheitsupdate: SQL-Anweisungen gesch&uuml;tzt.");
148                 break;
149
150         case '0.3.3': // SQL queries for v0.3.3
151                 // Update notes (these will be set as task text!)
152                 EXT_SET_UPDATE_NOTES("Bitte verschieben Sie die birthday-Templates (Ordner: {!PATH!}/templates/".getLanguage()."/html/) in den neuen Order birthday!");
153                 break;
154
155         case '0.3.4': // SQL queries for v0.3.4
156                 // Update notes (these will be set as task text!)
157                 EXT_SET_UPDATE_NOTES("Abspeichern von Einstellungen repariert.");
158                 break;
159
160         case '0.3.5': // SQL queries for v0.3.5
161                 // Update notes (these will be set as task text!)
162                 EXT_SET_UPDATE_NOTES("Vorbereitung auf die neue Mediendaten v0.0.4.");
163                 break;
164
165         case '0.3.6': // SQL queries for v0.3.6
166                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD birthday_mode ENUM('DIRECT','REF') NOT NULL DEFAULT 'DIRECT'");
167                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD birthday_active ENUM('Y','N') NOT NULL DEFAULT 'N'");
168
169                 // Update notes (these will be set as task text!)
170                 EXT_SET_UPDATE_NOTES("Verg&uuml;tungsmodus des Geburtstagsbonus einstellbar.");
171                 break;
172
173         case '0.3.7': // SQL queries for v0.3.7
174                 // Update notes (these will be set as task text!)
175                 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.");
176                 break;
177
178         case '0.3.8': // SQL queries for v0.3.8
179                 // Update notes (these will be set as task text!)
180                 EXT_SET_UPDATE_NOTES("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
181                 break;
182
183         case '0.3.9': // SQL queries for v0.3.9
184                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` CHANGE `birth_day` `birth_day` SMALLINT(2) UNSIGNED ZEROFILL NOT NULL DEFAULT '01',
185 CHANGE `birth_month` `birth_month` SMALLINT(2) UNSIGNED ZEROFILL NOT NULL DEFAULT '01',
186 CHANGE `birth_year` `birth_year` SMALLINT(4) UNSIGNED ZEROFILL NOT NULL DEFAULT 1970");
187
188                 // Update notes (these will be set as task text!)
189                 EXT_SET_UPDATE_NOTES("Datenbankspalten umgestellt auf SMALLINT() UNSIGNED ZEROFILL.");
190                 break;
191         }
192         break;
193
194 case 'modify': // When the extension got modified
195         break;
196
197 case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
198         break;
199
200 default: // Do stuff when extension is loaded
201         if ((isResetModeEnabled()) && (getConfig('birthday_points') > 0)) {
202                 // Daily reset was run and we shall pay points so we start checking for members who
203                 // has a birthday for today
204                 ADD_INC_TO_POOL(sprintf("%sinc/mails/birthday_mails.php", constant('PATH')));
205         }
206         break;
207 }
208
209 //
210 ?>