0.0.0 shall be our first version
[mailer.git] / inc / extensions / ext-holiday.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/17/2004 *
4  * ===================                          Last change: 01/13/2006 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-holiday.php                                  *
8  * -------------------------------------------------------------------- *
9  * Short description : Holiday requests from members                    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Ferienantraege von Mitgliedern                   *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Version number
44 setThisExtensionVersion('0.2.1');
45
46 // Version history array (add more with , '0.0.1' and so on)
47 setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1'));
48
49 switch (getExtensionMode()) {
50         case 'register': // Do stuff when installation is running
51                 // Create database
52                 addDropTableSql('user_holidays');
53                 addCreateTableSql('user_holidays', "(
54 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
55 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
56 `holiday_start` VARCHAR(10) NOT NULL DEFAULT 0,
57 `holiday_end` VARCHAR(10) NOT NULL DEFAULT 0,
58 `comments` LONGTEXT NOT NULL,
59 INDEX (`userid`),
60 PRIMARY KEY (`id`)
61 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'User holiday data'");
62
63                 // Add default values to config
64                 addConfigAddSql('holiday_max', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 30');
65
66                 // Add member menu
67                 addMemberMenuSql('main', 'holiday', 'Urlaubsschaltung', 'Y', 'Y', 4);
68
69                 // Add admin menus
70                 addAdminMenuSql('holiday', NULL, 'Urlaubsmanagement', 'Hier k&ouml;nnen Sie Urlaubsschaltungen Ihrer Mitglieder auflisten oder auch wieder aufheben.', 4);
71                 addAdminMenuSql('holiday', 'list_holiday', 'Auflisten', 'Alle Urlaubsschaltungen auflisten.', 1);
72                 addAdminMenuSql('holiday', 'del_holiday', 'Urlaub beenden', 'Urlaubsschaltungen aufheben. Geben Sie bitte mehr als nur &quot;Verstoss gegen unsere AGBs&quot; ein!', 2);
73                 addAdminMenuSql('holiday', 'config_holiday', 'Einstellungen', 'Maximale Tage f&uuml;r Urlaub usw. einstellen.', 3);
74
75                 // Remove 0 max mails per day
76                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE value=0 LIMIT 1");
77                 break;
78
79         case 'remove': // Do stuff when removing extension
80                 // SQL commands to run
81                 addDropTableSql('user_holidays');
82                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='holiday' LIMIT 1");
83                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='holiday' LIMIT 4");
84                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `value`=0 LIMIT 1");
85                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_max_receive` (`value`, `comment`) VALUES (0,'Urlaub')");
86                 break;
87
88         case 'activate': // Do stuff when admin activates this extension
89                 // SQL commands to run
90                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='holiday' LIMIT 1");
91                 break;
92
93         case 'deactivate': // Do stuff when admin deactivates this extension
94                 // SQL commands to run
95                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='holiday' LIMIT 1");
96                 break;
97
98         case 'update': // Update an extension
99                 switch (getCurrentExtensionVersion())
100                 {
101                         case '0.0.2': // SQL queries for v0.0.2
102                                 // Update notes (these will be set as task text!)
103                                 setExtensionUpdateNotes("Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.");
104                                 break;
105
106                         case '0.0.3': // SQL queries for v0.0.3
107                                 // Update notes (these will be set as task text!)
108                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
109                                 break;
110
111                         case '0.0.4': // SQL queries for v0.0.4
112                                 // Update notes (these will be set as task text!)
113                                 setExtensionUpdateNotes("Problem mit Speicherung der Einstellungen beseitigt.");
114                                 break;
115
116                         case '0.0.5': // SQL queries for v0.0.5
117                                 // Update notes (these will be set as task text!)
118                                 setExtensionUpdateNotes("Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
119                                 break;
120
121                         case '0.0.6': // SQL queries for v0.0.6
122                                 // Update notes (these will be set as task text!)
123                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
124                                 break;
125
126                         case '0.0.7': // SQL queries for v0.0.7
127                                 // Update notes (these will be set as task text!)
128                                 setExtensionUpdateNotes("IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.");
129                                 break;
130
131                         case '0.0.8': // SQL queries for v0.0.8
132                                 // Update notes (these will be set as task text!)
133                                 setExtensionUpdateNotes("Link zum Mitgliedsprofil in Funktion <u>generateUserProfileLink()</u> ausgelagert.");
134                                 break;
135
136                         case '0.0.9': // SQL queries for v0.0.9
137                                 // Update notes (these will be set as task text!)
138                                 setExtensionUpdateNotes("W&ouml;rter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.");
139                                 break;
140
141                         case '0.1.0': // SQL queries for v0.2.1
142                                 // Update notes (these will be set as task text!)
143                                 setExtensionUpdateNotes("Sicherheitsupdate: SQL-Anweisungen gesch&uuml;tzt.");
144                                 break;
145
146                         case '0.1.1': // SQL queries for v0.1.1
147                                 // Update notes (these will be set as task text!)
148                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
149                                 break;
150
151                         case '0.1.2': // SQL queries for v0.1.2
152                                 // Update notes (these will be set as task text!)
153                                 setExtensionUpdateNotes("Abspeichern der Urlaubsanfrage korregiert.");
154                                 break;
155
156                         case '0.1.3': // SQL queries for v0.1.3
157                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `holiday_active` ENUM('Y','N') NOT NULL DEFAULT 'N'");
158                                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `value`=0 LIMIT 1");
159                                 addConfigAddSql('holiday_lock', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 2));
160
161                                 // Update notes (these will be set as task text!)
162                                 setExtensionUpdateNotes("Die Mitglieder-Accounts werden nicht mehr gesperrt, sondern nur auf <strong>Urlaub</strong> geschaltet. Lassen Sie sich nicht davon verwirren, dass sie &quot;freigegeben&quot; sind!");
163                                 break;
164
165                         case '0.1.4': // SQL queries for v0.1.4
166                                 addConfigAddSql('holiday_mode', "ENUM('DIRECT','RESET') NOT NULL DEFAULT 'RESET'");
167
168                                 // Update notes (these will be set as task text!)
169                                 setExtensionUpdateNotes("Urlaubsschaltung wird erst Abends um 00:00 Uhr aktiv und nicht durch die Beantragung. Dies kann nun auch auf direkte Umstellung eingestellt werden.");
170                                 break;
171
172                         case '0.1.5': // SQL queries for v0.1.5
173                                 // Update notes (these will be set as task text!)
174                                 setExtensionUpdateNotes("Sicherheitsupdate f&uuml;r die Include-Befehle.");
175                                 break;
176
177                         case '0.1.6': // SQL queries for v0.1.6
178                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD holiday_activated BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
179
180                                 // Update notes (these will be set as task text!)
181                                 setExtensionUpdateNotes("Fehlende Tabellenspalte hinzugef&uuml;gt.");
182                                 break;
183
184                         case '0.1.7': // SQL queries for v0.1.7
185                                 // Update notes (these will be set as task text!)
186                                 setExtensionUpdateNotes("if-Anweisungen auf Funktion <strong>empty()</strong> umgestellt.");
187                                 break;
188
189                         case '0.1.8': // SQL queries for v0.1.8
190                                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`, `la_action`, `la_what`) VALUES ('member', '', 'list_holiday')");
191                                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`, `la_action`, `la_what`) VALUES ('member', '', 'del_holiday')");
192                                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`, `la_action`, `la_what`) VALUES ('config', '', 'config_holiday')");
193
194                                 // Depends on sql_patches (or you have to execute these both SQL statements by phpMyAdmin
195                                 addExtensionDependency('sql_patches');
196
197                                 // Update notes (these will be set as task text!)
198                                 setExtensionUpdateNotes("Erweiterung in's neue Men&uuml;system integriert.");
199                                 break;
200
201                         case '0.1.9': // SQL queries for v0.1.9
202                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='account', `sort`=2, `title`='In Urlaub' WHERE `what`='holiday' LIMIT 1");
203
204                                 // Update notes (these will be set as task text!)
205                                 setExtensionUpdateNotes("Mitgliedsmen&uuml; komplett umgebaut.");
206                                 break;
207
208                         case '0.2.0': // SQL queries for v0.2.0
209                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='Urlaubsmanagement' WHERE `action`='holiday' AND (`what`='' OR `what` IS NULL) LIMIT 1");
210
211                                 // Update notes (these will be set as task text!)
212                                 setExtensionUpdateNotes("Mitgliedsmen&uuml; komplett umgebaut.");
213                                 break;
214
215                         case '0.2.1': // SQL queries for v0.2.1
216                                 // Update notes (these will be set as task text!)
217                                 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
218                                 break;
219                 } // END - switch
220                 break;
221
222         case 'modify': // When the extension got modified
223                 break;
224
225         case 'test': // For testing purposes
226                 break;
227
228         case 'init': // Do stuff when extension is initialized
229                 break;
230
231         default: // Unknown extension mode
232                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
233                 break;
234 } // END - switch
235
236 // [EOF]
237 ?>