57cf3e78031cc55574d9e0c9ea887f5822e294e7
[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 - 2013 by Mailer Developer Team                   *
20  * For more information visit: http://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.3');
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', '0.2.2', '0.2.3'));
48
49 switch (getExtensionMode()) {
50         case 'setup': // 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 PRIMARY KEY (`id`),
60 INDEX (`userid`)",
61                         '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', 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
87                 // Unregister filter
88                 unregisterFilter(__FILE__, __LINE__, 'user_exclusion_sql', 'HOLIDAY_USER_EXCLUSION_SQL', TRUE, isExtensionDryRun());
89                 unregisterFilter(__FILE__, __LINE__, 'pre_mail_recipient_check', 'CHECK_USER_HOLIDAY', TRUE, isExtensionDryRun());
90                 unregisterFilter(__FILE__, __LINE__, 'pre_category_mail_order_check', 'PRE_USERID_HOLIDAY_CHECK', TRUE, isExtensionDryRun());
91                 break;
92
93         case 'activate': // Do stuff when admin activates this extension
94                 // SQL commands to run
95                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='holiday' LIMIT 1");
96                 break;
97
98         case 'deactivate': // Do stuff when admin deactivates this extension
99                 // SQL commands to run
100                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N',`locked`='Y' WHERE `what`='holiday' LIMIT 1");
101                 break;
102
103         case 'update': // Update an extension
104                 break;
105
106         case 'modify': // When the extension got modified
107                 break;
108
109         case 'test': // For testing purposes
110                 break;
111
112         case 'init': // Do stuff when extension is initialized
113                 break;
114
115         default: // Unknown extension mode
116                 reportBug(__FILE__, __LINE__, sprintf('Unknown extension mode %s in extension %s detected.', getExtensionMode(), getCurrentExtensionName()));
117                 break;
118 } // END - switch
119
120 // [EOF]
121 ?>