Copyright updated
[mailer.git] / 0.2.1 / inc / libs / holiday_functions.php
1 <?php\r
2 /************************************************************************\r
3  * MXChange v0.2.1                                    Start: 07/31/2003 *\r
4  * ===============                              Last change: 08/02/2003 *\r
5  *                                                                      *\r
6  * -------------------------------------------------------------------- *\r
7  * File              : holiday_functions.php                            *\r
8  * -------------------------------------------------------------------- *\r
9  * Short description : Functions for the admins extension               *\r
10  * -------------------------------------------------------------------- *\r
11  * Kurzbeschreibung  : Funktionen fuer die admins-Erweiterung           *\r
12  * -------------------------------------------------------------------- *\r
13  *                                                                      *\r
14  * -------------------------------------------------------------------- *\r
15  * Copyright (c) 2003 - 2008 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 function HOLIDAY_STOP_HOLIDAYS()\r
42 {\r
43         // Let's find some expired holiday requests...\r
44         $result_stop = SQL_QUERY("SELECT userid, holiday_start, holiday_end, comments\r
45 FROM "._MYSQL_PREFIX."_user_holidays\r
46 WHERE holiday_end <= ".time()."\r
47 ORDER BY userid", __FILE__, __LINE__);\r
48         if (SQL_NUMROWS($result_stop) > 0)\r
49         {\r
50                 // We foud at least one\r
51                 $admin = "";\r
52                 while (list($uid, $start, $end, $comments) = SQL_FETCHROW($result_stop))\r
53                 {\r
54                         // Stop holiday\r
55                         $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_holidays WHERE userid=%d LIMIT 1",\r
56                          array(bigintval($uid)), __FILE__, __LINE__);\r
57 \r
58                         // Unlock account\r
59                         $result_del = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data\r
60 SET holiday_active='N', holiday_activated='0'\r
61 WHERE userid=%d LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__);\r
62 \r
63                         // Prepare array\r
64                         $content = array(\r
65                                 'holiday_end'      => MAKE_DATETIME($end  , "3"),\r
66                                 'holiday_start'    => MAKE_DATETIME($start, "3"),\r
67                                 'holiday_comments' => $comments\r
68                         );\r
69 \r
70                         // Send mail to user\r
71                         $msg = LOAD_EMAIL_TEMPLATE("member_holiday_unlock", $content, $uid);\r
72                         SEND_EMAIL($uid, HOLIDAY_MEMBER_UNLOCK_SUBJ, $msg);\r
73 \r
74                         // Remember userid for admin\r
75                         $admin .= $uid."\n";\r
76                 }\r
77 \r
78                 // Send mail to admins\r
79                 if (GET_EXT_VERSION("admins") >= "0.4.1")\r
80                 {\r
81                         // Use new system\r
82                         SEND_ADMIN_EMAILS_PRO(HOLIDAY_ADMIN_UNLOCK_SUBJ, "admin_holiday_unlock", $admin, "0");\r
83                 }\r
84                  else\r
85                 {\r
86                         // Use old system\r
87                         $msg = LOAD_EMAIL_TEMPLATE("admin_holiday_unlock", $admin, "0");\r
88                         SEND_ADMIN_EMAILS(HOLIDAY_ADMIN_UNLOCK_SUBJ, $msg);\r
89                 }\r
90         }\r
91 \r
92         // Free memory\r
93         SQL_FREERESULT($result_stop);\r
94 }\r
95 \r
96 //\r
97 ?>\r