rewritten to new functions, some parts rewritten to filters
[mailer.git] / inc / extensions / ext-holiday.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Version number
41 EXT_SET_VERSION("0.2.1");
42
43 // Version history array (add more with , "0.1" and so on)
44 EXT_SET_VER_HISTORY(array("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"));
45
46 switch ($EXT_LOAD_MODE)
47 {
48 case "register": // Do stuff when installation is running (modules.php?module=admin&action=login is called)
49         // Create database
50         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_user_holidays`");
51         ADD_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_user_holidays` (
52 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
53 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
54 holiday_start VARCHAR(10) NOT NULL DEFAULT 0,
55 holiday_end VARCHAR(10) NOT NULL DEFAULT 0,
56 comments LONGBLOB NOT NULL,
57 KEY (userid),
58 PRIMARY KEY(id)
59 ) TYPE=MyISAM");
60
61         // Add default values to config
62         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD holiday_max BIGINT(20) UNSIGNED NOT NULL DEFAULT '30'");
63
64         // Add member menu
65         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`sort`,`visible`,`locked`) VALUES ('main','holiday','Urlaubsschaltung','4','Y','Y')");
66
67         // Add admin menus
68         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`, `what`, `title`, `sort`, `descr`) VALUES ('holiday', NULL, 'Urlaubsmanagement','4','Hier k&ouml;nnen Sie Urlaubsschaltungen Ihrer Mitglieder auflisten oder auch wieder aufheben.')");
69         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`, `what`, `title`, `sort`, `descr`) VALUES ('holiday','list_holiday','Auflisten','1','Alle Urlaubsschaltungen auflisten.')");
70         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`, `what`, `title`, `sort`, `descr`) VALUES ('holiday','del_holiday','Urlaub beenden','2','Urlaubsschaltungen aufheben. Geben Sie bitte mehr als nur &quot;Verstoss gegen unsere AGBs&quot; ein!')");
71         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`, `what`, `title`, `sort`, `descr`) VALUES ('holiday','config_holiday','Einstellungen','3','Maximale Tage f&uuml;r Urlaub usw. einstellen.')");
72
73         // Remove 0 max mails per day
74         ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_max_receive` WHERE value='0' LIMIT 1");
75         break;
76
77 case "remove": // Do stuff when removing extension
78         // SQL commands to run
79         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_user_holidays`");
80         ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_member_menu` WHERE `what`='holiday' LIMIT 1");
81         ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE `action`='holiday' LIMIT 4");
82         ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_max_receive` WHERE value='0' LIMIT 1");
83         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_max_receive` (value, comment) VALUES ('0','Urlaub')");
84         break;
85
86 case "activate": // Do stuff when admin activates this extension
87         // SQL commands to run
88         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='holiday' LIMIT 1");
89         break;
90
91 case "deactivate": // Do stuff when admin deactivates this extension
92         // SQL commands to run
93         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='holiday' LIMIT 1");
94         break;
95
96 case "update": // Update an extension
97         switch ($EXT_VER)
98         {
99         case "0.0.2": // SQL queries for v0.0.2
100                 // Update notes (these will be set as task text!)
101                 EXT_SET_UPDATE_NOTES("Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.");
102                 break;
103
104         case "0.0.3": // SQL queries for v0.0.3
105                 // Update notes (these will be set as task text!)
106                 EXT_SET_UPDATE_NOTES("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
107                 break;
108
109         case "0.0.4": // SQL queries for v0.0.4
110                 // Update notes (these will be set as task text!)
111                 EXT_SET_UPDATE_NOTES("Problem mit Speicherung der Einstellungen beseitigt.");
112                 break;
113
114         case "0.0.5": // SQL queries for v0.0.5
115                 // Update notes (these will be set as task text!)
116                 EXT_SET_UPDATE_NOTES("Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
117                 break;
118
119         case "0.0.6": // SQL queries for v0.0.6
120                 // Update notes (these will be set as task text!)
121                 EXT_SET_UPDATE_NOTES("Seit <a href=\"#\">Patch 340</a> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
122                 break;
123
124         case "0.0.7": // SQL queries for v0.0.7
125                 // Update notes (these will be set as task text!)
126                 EXT_SET_UPDATE_NOTES("IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.");
127                 break;
128
129         case "0.0.8": // SQL queries for v0.0.8
130                 // Update notes (these will be set as task text!)
131                 EXT_SET_UPDATE_NOTES("Link zum Mitgliedsprofil in Funktion <u>ADMIN_USER_PROFILE_LINK()</u> ausgelagert.");
132                 break;
133
134         case "0.0.9": // SQL queries for v0.0.9
135                 // Update notes (these will be set as task text!)
136                 EXT_SET_UPDATE_NOTES("W&ouml;rter <strong>Mailtausch</strong>, <strong>Mailtausches</strong> und <strong>Mailtauscher</strong> sind austauschbar.");
137                 break;
138
139         case "0.1.0": // SQL queries for v0.2.1
140                 // Update notes (these will be set as task text!)
141                 EXT_SET_UPDATE_NOTES("Sicherheitsupdate: SQL-Anweisungen gesch&uuml;tzt.");
142                 break;
143
144         case "0.1.1": // SQL queries for v0.1.1
145                 // Update notes (these will be set as task text!)
146                 EXT_SET_UPDATE_NOTES("Abspeichern von Einstellungen repariert.");
147                 break;
148
149         case "0.1.2": // SQL queries for v0.1.2
150                 // Update notes (these will be set as task text!)
151                 EXT_SET_UPDATE_NOTES("Abspeichern der Urlaubsanfrage korregiert.");
152                 break;
153
154         case "0.1.3": // SQL queries for v0.1.3
155                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` ADD holiday_active ENUM('Y','N') NOT NULL DEFAULT 'N'");
156                 ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_max_receive` WHERE value='0' LIMIT 1");
157                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD holiday_lock BIGINT(20) UNSIGNED NOT NULL DEFAULT '".(getConfig('one_day')*2)."'");
158
159                 // Update notes (these will be set as task text!)
160                 EXT_SET_UPDATE_NOTES("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!");
161                 break;
162
163         case "0.1.4": // SQL queries for v0.1.4
164                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD holiday_mode ENUM('DIRECT','RESET') NOT NULL DEFAULT 'RESET'");
165
166                 // Update notes (these will be set as task text!)
167                 EXT_SET_UPDATE_NOTES("Urlaubsschaltung wird erst Abends um 00:00 Uhr aktiv und nicht durch die Beantragung. Dies kann nun auch auf direkte Umstellung eingestellt werden.");
168                 break;
169
170         case "0.1.5": // SQL queries for v0.1.5
171                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD holiday_mode ENUM('DIRECT','RESET') NOT NULL DEFAULT 'RESET'");
172
173                 // Update notes (these will be set as task text!)
174                 EXT_SET_UPDATE_NOTES("Sicherheitsupdate f&uuml;r die Include-Befehle.");
175                 break;
176
177         case "0.1.6": // SQL queries for v0.1.6
178                 ADD_SQL("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                 EXT_SET_UPDATE_NOTES("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                 EXT_SET_UPDATE_NOTES("if-Anweisungen auf Funktion <strong>empty()</strong> umgestellt.");
187                 break;
188
189         case "0.1.8": // SQL queries for v0.1.8
190                 ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu_las` (la_id, la_action, la_what) VALUES ('member', '', 'list_holiday')");
191                 ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu_las` (la_id, la_action, la_what) VALUES ('member', '', 'del_holiday')");
192                 ADD_SQL("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                 EXT_SET_UPDATE_DEPENDS("sql_patches");
196
197                 // Update notes (these will be set as task text!)
198                 EXT_SET_UPDATE_NOTES("Erweiterung in's neue Men&uuml;system integriert.");
199                 break;
200
201         case "0.1.9": // SQL queries for v0.1.9
202                 ADD_SQL("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                 EXT_SET_UPDATE_NOTES("Mitgliedsmen&uuml; komplett umgebaut.");
206                 break;
207
208         case "0.2.0": // SQL queries for v0.2.0
209                 ADD_SQL("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                 EXT_SET_UPDATE_NOTES("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                 EXT_SET_UPDATE_NOTES("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
218                 break;
219         }
220         break;
221
222 case "test": // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
223         break;
224
225 default: // Do stuff when extension is loaded
226         break;
227 }
228
229 //
230 ?>