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 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
32 ************************************************************************/
34 // Some security stuff...
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Add description as navigation point
41 ADD_DESCR("admin", basename(__FILE__));
43 // Check for selected holidays
45 if (isset($_POST['sel'])) $SUM = SELECTION_COUNT($_POST['sel']);
47 // Shall I delete selected holidays???
50 // Delete multiple holiday requests (for list_holiday)
52 foreach ($_POST['sel'] as $id=>$sel)
55 $result = SQL_QUERY_ESC("SELECT userid, holiday_start, holiday_end
56 FROM "._MYSQL_PREFIX."_user_holidays
57 WHERE id=%d LIMIT 1", array(bigintval($id)), __FILE__, __LINE__);
58 if (SQL_NUMROWS($result) == 1)
60 // Load data and free memory
61 list($uid, $start, $end) = SQL_FETCHROW($result);
62 SQL_FREERESULT($result);
64 // Update user's account
65 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data
66 SET holiday_active='N', holiday_activated='0'
67 WHERE userid=%d LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__);
70 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_holidays
71 WHERE id=%d LIMIT 1", array(bigintval($id)), __FILE__, __LINE__);
73 // Prepare loaded data for the
75 'start' => MAKE_DATETIME($start, "3"),
76 'end' => MAKE_DATETIME($end , "3")
80 $msg = LOAD_EMAIL_TEMPLATE("member_holiday_removed", $content, $uid);
81 SEND_EMAIL($uid, HOLIDAY_ADMIN_REMOVED_SUBJ, $msg);
85 LOAD_TEMPLATE("admin_settings_saved", false, HOLIDAY_ADMIN_MULTI_DEL_1.$cnt.HOLIDAY_ADMIN_MULTI_DEL_2);
87 elseif (!empty($_GET['u_id']))
89 // Set default message
90 $MSG = HOLIDAY_ADMIN_SINGLE_404;
93 $result_load = SQL_QUERY_ESC("SELECT holiday_start AS start, holiday_end AS end
94 FROM "._MYSQL_PREFIX."_user_holidays
95 WHERE userid=%d LIMIT 1", array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
96 if (SQL_NUMROWS($result_load) == 1)
99 $content = SQL_FETCHARRAY($result_load);
105 // Delete one holiday request (for task)
106 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_holidays
107 WHERE userid=%d LIMIT 1", array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
109 // Send email to user
110 $msg = LOAD_EMAIL_TEMPLATE("member_holiday_removed", $content, $_GET['u_id']);
111 SEND_EMAIL($_GET['u_id'], HOLIDAY_ADMIN_REMOVED_SUBJ, $msg);
114 $MSG = HOLIDAY_ADMIN_SINGLE_DELETED;
118 SQL_FREERESULT($result_load);
121 LOAD_TEMPLATE("admin_settings_saved", false, $MSG);
125 // Please call me over other scripts... ;)
126 LOAD_TEMPLATE("admin_settings_saved", false, HOLIDAY_NO_DIRECT_CALL);