(no commit message)
[mailer.git] / 0.2.1 / inc / extensions / ext-holiday.php
1 <?php\r
2 /************************************************************************\r
3  * MXChange v0.2.1                                    Start: 06/17/2004 *\r
4  * ================                             Last change: 01/13/2006 *\r
5  *                                                                      *\r
6  * -------------------------------------------------------------------- *\r
7  * File              : ext-holiday.php                                  *\r
8  * -------------------------------------------------------------------- *\r
9  * Short description : Holiday requests from members                    *\r
10  * -------------------------------------------------------------------- *\r
11  * Kurzbeschreibung  : Ferienantraege von Mitgliedern                   *\r
12  * -------------------------------------------------------------------- *\r
13  *                                                                      *\r
14  * -------------------------------------------------------------------- *\r
15  * Copyright (c) 2003 - 2007 by Roland Haeder                           *\r
16  * For more information visit: http://www.mxchange.org                  *\r
17  *                                                                      *\r
18  * This program is free software; you can redistribute it and/or modify *\r
19  * it under the terms of the GNU General Public License as published by *\r
20  * the Free Software Foundation; either version 2 of the License, or    *\r
21  * (at your option) any later version.                                  *\r
22  *                                                                      *\r
23  * This program is distributed in the hope that it will be useful,      *\r
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
26  * GNU General Public License for more details.                         *\r
27  *                                                                      *\r
28  * You should have received a copy of the GNU General Public License    *\r
29  * along with this program; if not, write to the Free Software          *\r
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
31  * MA  02110-1301  USA                                                  *\r
32  ************************************************************************/\r
33 \r
34 // Some security stuff...\r
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])))\r
36 {\r
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";\r
38         require($INC);\r
39 }\r
40 \r
41 // Version number\r
42 $EXT_VERSION = "0.2.1";\r
43 \r
44 // Auto-set extension version\r
45 if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;\r
46 \r
47 // Version history array (add more with , "0.1" and so on)\r
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");\r
49 \r
50 switch ($EXT_LOAD_MODE)\r
51 {\r
52 case "register": // Do stuff when installtion is running (modules.php?module=admin&action=login is called)\r
53         // Create database\r
54         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_holidays";\r
55         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_user_holidays (\r
56 id bigint(20) not null auto_increment,\r
57 userid bigint(20) not null default '0',\r
58 holiday_start varchar(10) not null default '0',\r
59 holiday_end varchar(10) not null default '0',\r
60 comments longblob not null,\r
61 KEY (userid),\r
62 PRIMARY KEY(id)\r
63 ) TYPE=MyISAM";\r
64 \r
65         // Add default values to config\r
66         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD holiday_max bigint(20) not null default '30'";\r
67 \r
68         // Add member menu\r
69         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, sort, visible, locked) VALUES ('main', 'holiday', 'Urlaubsschaltung', '4', 'Y', 'Y')";\r
70 \r
71         // Add admin menus\r
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.')";\r
73         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, sort, descr) VALUES ('holiday', 'list_holiday', 'Auflisten', '1', 'Alle Urlaubsschaltungen auflisten.')";\r
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!')";\r
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.')";\r
76 \r
77         // Remove 0 max mails per day\r
78         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_max_receive WHERE value='0' LIMIT 1";\r
79         break;\r
80 \r
81 case "remove": // Do stuff when removing extension\r
82         // SQL commands to run\r
83         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_holidays";\r
84         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE what='holiday' LIMIT 1";\r
85         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE action='holiday' LIMIT 4";\r
86         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_max_receive WHERE value='0' LIMIT 1";\r
87         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_max_receive (value, comment) VALUES('0', 'Urlaub')";\r
88         break;\r
89 \r
90 case "activate": // Do stuff when admin activates this extension\r
91         // SQL commands to run\r
92         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='Y', locked='N' WHERE action='main' AND what='holiday' LIMIT 1";\r
93         break;\r
94 \r
95 case "deactivate": // Do stuff when admin deactivates this extension\r
96         // SQL commands to run\r
97         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='Y', locked='Y' WHERE action='main' AND what='holiday' LIMIT 1";\r
98         break;\r
99 \r
100 case "update": // Update an extension\r
101         switch ($EXT_VER)\r
102         {\r
103         case "0.0.2": // SQL queries for v0.0.2\r
104                 // Update notes (these will be set as task text!)\r
105                 $UPDATE_NOTES = "Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.";\r
106                 break;\r
107 \r
108         case "0.0.3": // SQL queries for v0.0.3\r
109                 // Update notes (these will be set as task text!)\r
110                 $UPDATE_NOTES = "Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.";\r
111                 break;\r
112 \r
113         case "0.0.4": // SQL queries for v0.0.4\r
114                 // Update notes (these will be set as task text!)\r
115                 $UPDATE_NOTES = "Problem mit Speicherung der Einstellungen beseitigt.";\r
116                 break;\r
117 \r
118         case "0.0.5": // SQL queries for v0.0.5\r
119                 // Update notes (these will be set as task text!)\r
120                 $UPDATE_NOTES = "Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.";\r
121                 break;\r
122 \r
123         case "0.0.6": // SQL queries for v0.0.6\r
124                 // Update notes (these will be set as task text!)\r
125                 $UPDATE_NOTES = "Seit <A href=\"".SERVER_URL."/patches/340-Gast_Mitgliedsmenue_Deaktivieren.zip\">Patch 340</A> &uuml;berfl&uuml;ssige HTML-Tags entfernt.";\r
126                 break;\r
127 \r
128         case "0.0.7": // SQL queries for v0.0.7\r
129                 // Update notes (these will be set as task text!)\r
130                 $UPDATE_NOTES = "IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.";\r
131                 break;\r
132 \r
133         case "0.0.8": // SQL queries for v0.0.8\r
134                 // Update notes (these will be set as task text!)\r
135                 $UPDATE_NOTES = "Link zum Mitgliedsprofil in Funktion <U>ADMIN_USER_PROFILE_LINK()</U> ausgelagert.";\r
136                 break;\r
137 \r
138         case "0.0.9": // SQL queries for v0.0.9\r
139                 // Update notes (these will be set as task text!)\r
140                 $UPDATE_NOTES = "W&ouml;rter <STRONG>Mailtausch</STRONG>, <STRONG>Mailtausches</STRONG> und <STRONG>Mailtauscher</STRONG> sind austauschbar.";\r
141                 break;\r
142 \r
143         case "0.1.0": // SQL queries for v0.1.0\r
144                 // Update notes (these will be set as task text!)\r
145                 $UPDATE_NOTES = "Sicherheitsupdate: SQL-Anweisungen gesch&uuml;tzt.";\r
146                 break;\r
147 \r
148         case "0.1.1": // SQL queries for v0.1.1\r
149                 // Update notes (these will be set as task text!)\r
150                 $UPDATE_NOTES = "Abspeichern von Einstellungen repariert.";\r
151                 break;\r
152 \r
153         case "0.1.2": // SQL queries for v0.1.2\r
154                 // Update notes (these will be set as task text!)\r
155                 $UPDATE_NOTES = "Abspeichern der Urlaubsanfrage korregiert.";\r
156                 break;\r
157 \r
158         case "0.1.3": // SQL queries for v0.1.3\r
159                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD holiday_active enum('Y', 'N') not null default 'N'";\r
160                 $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_max_receive WHERE value='0' LIMIT 1";\r
161                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD holiday_lock bigint(20) not null default '".(60*60*24*2)."'";\r
162 \r
163                 // Update notes (these will be set as task text!)\r
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!";\r
165                 break;\r
166 \r
167         case "0.1.4": // SQL queries for v0.1.4\r
168                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD holiday_mode enum('DIRECT', 'RESET') not null default 'RESET'";\r
169 \r
170                 // Update notes (these will be set as task text!)\r
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.";\r
172                 break;\r
173 \r
174         case "0.1.5": // SQL queries for v0.1.5\r
175                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD holiday_mode enum('DIRECT', 'RESET') not null default 'RESET'";\r
176 \r
177                 // Update notes (these will be set as task text!)\r
178                 $UPDATE_NOTES = "Sicherheitsupdate f&uuml;r die Include-Befehle.";\r
179                 break;\r
180 \r
181         case "0.1.6": // SQL queries for v0.1.6\r
182                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD holiday_activated bigint(20) not null default '0'";\r
183 \r
184                 // Update notes (these will be set as task text!)\r
185                 $UPDATE_NOTES = "Fehlende Tabellenspalte hinzugef&uuml;gt.";\r
186                 break;\r
187 \r
188         case "0.1.7": // SQL queries for v0.1.7\r
189                 // Update notes (these will be set as task text!)\r
190                 $UPDATE_NOTES = "if-Anweisungen auf Funktion <STRONG>empty()</STRONG> umgestellt.";\r
191                 break;\r
192 \r
193         case "0.1.8": // SQL queries for v0.1.8\r
194                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('member', '', 'list_holiday')";\r
195                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('member', '', 'del_holiday')";\r
196                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('config', '', 'config_holiday')";\r
197 \r
198                 // Depends on sql_patches (or you have to execute these both SQL statements by phpMyAdmin\r
199                 $EXT_UPDATE_DEPENDS = "sql_patches";\r
200 \r
201                 // Update notes (these will be set as task text!)\r
202                 $UPDATE_NOTES = "Erweiterung in's neue Men&uuml;system integriert.";\r
203                 break;\r
204 \r
205         case "0.1.9": // SQL queries for v0.1.9\r
206                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET action='account', sort='2', title='In Urlaub' WHERE what='holiday' LIMIT 1";\r
207 \r
208                 // Update notes (these will be set as task text!)\r
209                 $UPDATE_NOTES = "Mitgliedsmen&uuml; komplett umgebaut.";\r
210                 break;\r
211 \r
212         case "0.2.0": // SQL queries for v0.2.0\r
213                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_admin_menu SET title = 'Urlaubsmanagement' WHERE action = 'holiday' AND what='' LIMIT 1";\r
214 \r
215                 // Update notes (these will be set as task text!)\r
216                 $UPDATE_NOTES = "Mitgliedsmen&uuml; komplett umgebaut.";\r
217                 break;\r
218 \r
219         case "0.2.1": // SQL queries for v0.2.1\r
220                 // Update notes (these will be set as task text!)\r
221                 $UPDATE_NOTES = "Fehlerhinweis bei deaktivierter Erweiterung verbessert.";\r
222                 break;\r
223         }\r
224         break;\r
225 \r
226 default: // Do stuff when extension is loaded\r
227         $DUMMY = LOAD_CONFIG("0");\r
228         // Copy data to config array\r
229         $CONFIG['holiday_max']  = $DUMMY['holiday_max'];  // Maximum days for holiday\r
230         $CONFIG['holiday_lock'] = $DUMMY['holiday_lock']; // Lock deactivation in member area for X seconds\r
231         $CONFIG['holiday_mode'] = $DUMMY['holiday_mode']; // Mode for activating holiday\r
232         unset($DUMMY);\r
233 \r
234         // Do we have a daily-reset-run?\r
235         if (((defined('__DAILY_RESET')) && ($CONFIG['holiday_mode'] == "RESET")) || ($CONFIG['holiday_mode'] == "DIRECT"))\r
236         {\r
237                 // Ok, let's check for finished holidays and unlock those accounts\r
238                 $INC_POOL[] = PATH."inc/reset/reset_holiday.php";\r
239         }\r
240         break;\r
241 }\r
242 \r
243 // Language file prefix\r
244 $EXT_LANG_PREFIX = "holiday";\r
245 \r
246 // Extension is always active?\r
247 $EXT_ALWAYS_ACTIVE = "N";\r
248 \r
249 //\r
250 ?>\r