454c67a062717f07dc04fada7aad840f516bee66
[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 ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])))
36 {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 // Version number
42 $EXT_VERSION = "0.2.1";
43
44 // Auto-set extension version
45 if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;
46
47 // Version history array (add more with , "0.1" and so on)
48 $EXT_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");
49
50 switch ($EXT_LOAD_MODE)
51 {
52 case "register": // Do stuff when installtion is running (modules.php?module=admin&action=login is called)
53         // Create database
54         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_holidays";
55         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_user_holidays (
56 id bigint(20) not null auto_increment,
57 userid bigint(20) not null default '0',
58 holiday_start varchar(10) not null default '0',
59 holiday_end varchar(10) not null default '0',
60 comments longblob not null,
61 KEY (userid),
62 PRIMARY KEY(id)
63 ) TYPE=MyISAM";
64
65         // Add default values to config
66         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD holiday_max bigint(20) not null default '30'";
67
68         // Add member menu
69         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, sort, visible, locked) VALUES ('main', 'holiday', 'Urlaubsschaltung', '4', 'Y', 'Y')";
70
71         // Add admin menus
72         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, sort, descr) VALUES ('holiday', '', 'Urlaubsmanagement', '4', 'Hier k&ouml;nnen Sie Urlaubsschaltungen Ihrer Mitglieder auflisten oder auch wieder aufheben.')";
73         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, sort, descr) VALUES ('holiday', 'list_holiday', 'Auflisten', '1', 'Alle Urlaubsschaltungen auflisten.')";
74         $SQLs[] = "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!')";
75         $SQLs[] = "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.')";
76
77         // Remove 0 max mails per day
78         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_max_receive WHERE value='0' LIMIT 1";
79         break;
80
81 case "remove": // Do stuff when removing extension
82         // SQL commands to run
83         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_holidays";
84         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE what='holiday' LIMIT 1";
85         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE action='holiday' LIMIT 4";
86         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_max_receive WHERE value='0' LIMIT 1";
87         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_max_receive (value, comment) VALUES('0', 'Urlaub')";
88         break;
89
90 case "activate": // Do stuff when admin activates this extension
91         // SQL commands to run
92         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='Y', locked='N' WHERE action='main' AND what='holiday' LIMIT 1";
93         break;
94
95 case "deactivate": // Do stuff when admin deactivates this extension
96         // SQL commands to run
97         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='Y', locked='Y' WHERE action='main' AND what='holiday' LIMIT 1";
98         break;
99
100 case "update": // Update an extension
101         switch ($EXT_VER)
102         {
103         case "0.0.2": // SQL queries for v0.0.2
104                 // Update notes (these will be set as task text!)
105                 $UPDATE_NOTES = "Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.";
106                 break;
107
108         case "0.0.3": // SQL queries for v0.0.3
109                 // Update notes (these will be set as task text!)
110                 $UPDATE_NOTES = "Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.";
111                 break;
112
113         case "0.0.4": // SQL queries for v0.0.4
114                 // Update notes (these will be set as task text!)
115                 $UPDATE_NOTES = "Problem mit Speicherung der Einstellungen beseitigt.";
116                 break;
117
118         case "0.0.5": // SQL queries for v0.0.5
119                 // Update notes (these will be set as task text!)
120                 $UPDATE_NOTES = "Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.";
121                 break;
122
123         case "0.0.6": // SQL queries for v0.0.6
124                 // Update notes (these will be set as task text!)
125                 $UPDATE_NOTES = "Seit <A href=\"".SERVER_URL."/patches/340-Gast_Mitgliedsmenue_Deaktivieren.zip\">Patch 340</A> &uuml;berfl&uuml;ssige HTML-Tags entfernt.";
126                 break;
127
128         case "0.0.7": // SQL queries for v0.0.7
129                 // Update notes (these will be set as task text!)
130                 $UPDATE_NOTES = "IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.";
131                 break;
132
133         case "0.0.8": // SQL queries for v0.0.8
134                 // Update notes (these will be set as task text!)
135                 $UPDATE_NOTES = "Link zum Mitgliedsprofil in Funktion <U>ADMIN_USER_PROFILE_LINK()</U> ausgelagert.";
136                 break;
137
138         case "0.0.9": // SQL queries for v0.0.9
139                 // Update notes (these will be set as task text!)
140                 $UPDATE_NOTES = "W&ouml;rter <STRONG>Mailtausch</STRONG>, <STRONG>Mailtausches</STRONG> und <STRONG>Mailtauscher</STRONG> sind austauschbar.";
141                 break;
142
143         case "0.1.0": // SQL queries for v0.2.1
144                 // Update notes (these will be set as task text!)
145                 $UPDATE_NOTES = "Sicherheitsupdate: SQL-Anweisungen gesch&uuml;tzt.";
146                 break;
147
148         case "0.1.1": // SQL queries for v0.1.1
149                 // Update notes (these will be set as task text!)
150                 $UPDATE_NOTES = "Abspeichern von Einstellungen repariert.";
151                 break;
152
153         case "0.1.2": // SQL queries for v0.1.2
154                 // Update notes (these will be set as task text!)
155                 $UPDATE_NOTES = "Abspeichern der Urlaubsanfrage korregiert.";
156                 break;
157
158         case "0.1.3": // SQL queries for v0.1.3
159                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD holiday_active enum('Y', 'N') not null default 'N'";
160                 $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_max_receive WHERE value='0' LIMIT 1";
161                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD holiday_lock bigint(20) not null default '".(60*60*24*2)."'";
162
163                 // Update notes (these will be set as task text!)
164                 $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!";
165                 break;
166
167         case "0.1.4": // SQL queries for v0.1.4
168                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD holiday_mode enum('DIRECT', 'RESET') not null default 'RESET'";
169
170                 // Update notes (these will be set as task text!)
171                 $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.";
172                 break;
173
174         case "0.1.5": // SQL queries for v0.1.5
175                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD holiday_mode enum('DIRECT', 'RESET') not null default 'RESET'";
176
177                 // Update notes (these will be set as task text!)
178                 $UPDATE_NOTES = "Sicherheitsupdate f&uuml;r die Include-Befehle.";
179                 break;
180
181         case "0.1.6": // SQL queries for v0.1.6
182                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD holiday_activated bigint(20) not null default '0'";
183
184                 // Update notes (these will be set as task text!)
185                 $UPDATE_NOTES = "Fehlende Tabellenspalte hinzugef&uuml;gt.";
186                 break;
187
188         case "0.1.7": // SQL queries for v0.1.7
189                 // Update notes (these will be set as task text!)
190                 $UPDATE_NOTES = "if-Anweisungen auf Funktion <STRONG>empty()</STRONG> umgestellt.";
191                 break;
192
193         case "0.1.8": // SQL queries for v0.1.8
194                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('member', '', 'list_holiday')";
195                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('member', '', 'del_holiday')";
196                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('config', '', 'config_holiday')";
197
198                 // Depends on sql_patches (or you have to execute these both SQL statements by phpMyAdmin
199                 $EXT_UPDATE_DEPENDS = "sql_patches";
200
201                 // Update notes (these will be set as task text!)
202                 $UPDATE_NOTES = "Erweiterung in's neue Men&uuml;system integriert.";
203                 break;
204
205         case "0.1.9": // SQL queries for v0.1.9
206                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET action='account', sort='2', title='In Urlaub' WHERE what='holiday' LIMIT 1";
207
208                 // Update notes (these will be set as task text!)
209                 $UPDATE_NOTES = "Mitgliedsmen&uuml; komplett umgebaut.";
210                 break;
211
212         case "0.2.0": // SQL queries for v0.2.0
213                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_admin_menu SET title = 'Urlaubsmanagement' WHERE action = 'holiday' AND (what='' OR what IS NULL) LIMIT 1";
214
215                 // Update notes (these will be set as task text!)
216                 $UPDATE_NOTES = "Mitgliedsmen&uuml; komplett umgebaut.";
217                 break;
218
219         case "0.2.1": // SQL queries for v0.2.1
220                 // Update notes (these will be set as task text!)
221                 $UPDATE_NOTES = "Fehlerhinweis bei deaktivierter Erweiterung verbessert.";
222                 break;
223         }
224         break;
225
226 default: // Do stuff when extension is loaded
227         $dummy = LOAD_CONFIG();
228         $_CONFIG = array_merge($_CONFIG, $dummy);
229         unset($dummy);
230
231         // Do we have a daily-reset-run?
232         if (((defined('__DAILY_RESET')) && ($_CONFIG['holiday_mode'] == "RESET")) || ($_CONFIG['holiday_mode'] == "DIRECT"))
233         {
234                 // Ok, let's check for finished holidays and unlock those accounts
235                 $INC_POOL[] = PATH."inc/reset/reset_holiday.php";
236         }
237         break;
238 }
239
240 // Language file prefix
241 $EXT_LANG_PREFIX = "holiday";
242
243 // Extension is always active?
244 $EXT_ALWAYS_ACTIVE = 'N';
245
246 //
247 ?>