Comments fixed, ext-network continued, fix for mod stats:
[mailer.git] / inc / modules / admin / what-del_holiday.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 07/24/2004 *
4  * ===================                          Last change: 08/09/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-del_holiday.php                             *
8  * -------------------------------------------------------------------- *
9  * Short description : Remove holiday requests                          *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Urlaubsschaltungen entfernen                     *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
41         die();
42 }
43
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
46
47 // Shall I delete selected holidays???
48 if (countPostSelection() > 0) {
49         // Delete multiple holiday requests (for list_holiday)
50         $cnt = '0';
51         foreach (postRequestElement('sel') as $id => $sel) {
52                 // Get the userid
53                 $result = SQL_QUERY_ESC("SELECT
54         `userid`, `holiday_start`, `holiday_end`
55 FROM
56         `{?_MYSQL_PREFIX?}_user_holidays`
57 WHERE
58         `id`=%s
59 LIMIT 1", array(bigintval($id)), __FILE__, __LINE__);
60                 if (SQL_NUMROWS($result) == 1) {
61                         // Load data and free memory
62                         list($userid, $start, $end) = SQL_FETCHROW($result);
63                         SQL_FREERESULT($result);
64
65                         // Update user's account
66                         SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data`
67 SET
68         `holiday_active`='N',
69         `holiday_activated`=0
70 WHERE
71         `userid`=%s
72 LIMIT 1", array(bigintval($userid)), __FILE__, __LINE__);
73
74                         // Remove holiday
75                         SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM
76         `{?_MYSQL_PREFIX?}_user_holidays`
77 WHERE
78         `id`=%s
79 LIMIT 1", array(bigintval($id)), __FILE__, __LINE__);
80
81                         // Prepare loaded data for the
82                         $content = array(
83                                 'start' => generateDateTime($start, 3),
84                                 'end'   => generateDateTime($end  , 3)
85                         );
86
87                         // Send email to user
88                         $message = loadEmailTemplate('member_holiday_removed', $content, $userid);
89                         sendEmail($userid, getMessage('HOLIDAY_ADMIN_REMOVED_SUBJ'), $message);
90                         $cnt++;
91                 }
92         }
93         loadTemplate('admin_settings_saved', false, sprintf(getMessage('HOLIDAY_ADMIN_MULTI_DEL'), $cnt));
94 } elseif (isGetRequestElementSet('userid')) {
95         // Set default message
96         $message = getMessage('HOLIDAY_ADMIN_SINGLE_404');
97
98         // Fetch data
99         $result_load = SQL_QUERY_ESC("SELECT
100         `holiday_start` AS start, `holiday_end` AS end
101 FROM
102         `{?_MYSQL_PREFIX?}_user_holidays`
103 WHERE
104         `userid`=%s
105 LIMIT 1",
106                 array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
107         if (SQL_NUMROWS($result_load) == 1) {
108                 // Load data
109                 $content = SQL_FETCHARRAY($result_load);
110
111                 // Delete one holiday request (for task)
112                 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM
113         `{?_MYSQL_PREFIX?}_user_holidays`
114 WHERE
115         `userid`=%s
116 LIMIT 1", array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
117
118                 // Send email to user
119                 $message = loadEmailTemplate('member_holiday_removed', $content, getRequestElement('userid'));
120                 sendEmail(getRequestElement('userid'), getMessage('HOLIDAY_ADMIN_REMOVED_SUBJ'), $message);
121
122                 // Set message
123                 $message = getMessage('HOLIDAY_ADMIN_SINGLE_DELETED');
124         }
125
126         // Free memory
127         SQL_FREERESULT($result_load);
128
129         // Output message
130         loadTemplate('admin_settings_saved', false, $message);
131 } else {
132         // Please call me over other scripts... ;)
133         loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_NO_DIRECT_CALL'));
134 }
135
136 // [EOF]
137 ?>