2 /************************************************************************
3 * MXChange v0.2.1 Start: 07/24/2004 *
4 * ================ Last change: 08/09/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-del_holiday.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Remove holiday requests *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Urlaubsschaltungen entfernen *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 - 2008 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
45 // Add description as navigation point
46 ADD_DESCR('admin', __FILE__);
48 // Check for selected holidays
50 if (REQUEST_ISSET_POST('sel')) $SUM = countPostSelection();
52 // Shall I delete selected holidays???
55 // Delete multiple holiday requests (for list_holiday)
57 foreach (REQUEST_POST('sel') as $id => $sel)
60 $result = SQL_QUERY_ESC("SELECT userid, holiday_start, holiday_end
61 FROM `{!_MYSQL_PREFIX!}_user_holidays`
62 WHERE `id`=%s LIMIT 1", array(bigintval($id)), __FILE__, __LINE__);
63 if (SQL_NUMROWS($result) == 1)
65 // Load data and free memory
66 list($uid, $start, $end) = SQL_FETCHROW($result);
67 SQL_FREERESULT($result);
69 // Update user's account
70 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data`
71 SET `holiday_active`='N', holiday_activated='0'
72 WHERE userid=%s LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__);
75 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_holidays`
76 WHERE `id`=%s LIMIT 1", array(bigintval($id)), __FILE__, __LINE__);
78 // Prepare loaded data for the
80 'start' => generateDateTime($start, '3'),
81 'end' => generateDateTime($end , '3')
85 $message = LOAD_EMAIL_TEMPLATE("member_holiday_removed", $content, $uid);
86 sendEmail($uid, getMessage('HOLIDAY_ADMIN_REMOVED_SUBJ'), $message);
90 LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('HOLIDAY_ADMIN_MULTI_DEL'), $cnt));
91 } elseif (REQUEST_ISSET_GET('uid')) {
92 // Set default message
93 $message = getMessage('HOLIDAY_ADMIN_SINGLE_404');
96 $result_load = SQL_QUERY_ESC("SELECT
97 `holiday_start` AS start, `holiday_end` AS end
99 `{!_MYSQL_PREFIX!}_user_holidays`
103 array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
104 if (SQL_NUMROWS($result_load) == 1) {
106 $content = SQL_FETCHARRAY($result_load);
108 // Delete one holiday request (for task)
109 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM
110 `{!_MYSQL_PREFIX!}_user_holidays`
113 LIMIT 1", array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
115 // Send email to user
116 $message = LOAD_EMAIL_TEMPLATE('member_holiday_removed', $content, REQUEST_GET('uid'));
117 sendEmail(REQUEST_GET('uid'), getMessage('HOLIDAY_ADMIN_REMOVED_SUBJ'), $message);
120 $message = getMessage('HOLIDAY_ADMIN_SINGLE_DELETED');
124 SQL_FREERESULT($result_load);
127 LOAD_TEMPLATE('admin_settings_saved', false, $message);
129 // Please call me over other scripts... ;)
130 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('HOLIDAY_NO_DIRECT_CALL'));