- $result = SQL_QUERY_ESC("SELECT `holiday_active`, `holiday_activated` FROM `{!_MYSQL_PREFIX!}_user_data`
-WHERE `userid`=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
- list($active, $locked) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
-
- if (($active == 'Y') && (($locked + getConfig('holiday_lock')) < time())) {
- // Load data
- $result = SQL_QUERY_ESC("SELECT `holiday_start`, `holiday_end` FROM `{!_MYSQL_PREFIX!}_user_holidays`
-WHERE `userid`=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
- // Data was found
- list($start, $end) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
-
- // Prepare it for the template
- define('__HOLIDAY_START', generateDateTime($start, '3'));
- define('__HOLIDAY_END' , generateDateTime($end , '3'));
-
- // Deactivate it now
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data`
-SET `holiday_active`='N', holiday_activated='0'
-WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
-
- // Remove entry
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_holidays`
-WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
-
- // Send email to admin
- sendAdminNotification(getMessage('HOLIDAY_ADMIN_DEAC_SUBJ'), 'admin_holiday_deactivated', array(), getUserId());
-
- // Display message to user
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_DEACTIVATED_NOW'));
- } else {
- // Display message to user
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_CANNOT_DEACTIVATE'));
+ $result = SQL_QUERY_ESC("SELECT
+ `holiday_active`,`holiday_activated`
+FROM
+ `{?_MYSQL_PREFIX?}_user_data`
+WHERE
+ `userid`=%s
+LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
+
+ // Do we have an entry?
+ if (SQL_NUMROWS($result) == 1) {
+ // Merge arrays
+ $content = merge_array($content, SQL_FETCHARRAY($result));
+
+ if (($content['holiday_active'] == 'Y') && (($content['holiday_activated'] + getConfig('holiday_lock')) < time())) {
+ // Load data
+ $result2 = SQL_QUERY_ESC("SELECT
+ `holiday_start`,`holiday_end`
+FROM
+ `{?_MYSQL_PREFIX?}_user_holidays`
+WHERE
+ `userid`=%s
+LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
+ if (SQL_NUMROWS($result2) == 1) {
+ // Data was found so merge it
+ $content = merge_array($content, SQL_FETCHARRAY($result2));
+
+ // Prepare it for the template
+ $content['start'] = generateDateTime($content['holiday_start'], 3);
+ $content['end'] = generateDateTime($content['holiday_end'] , 3);
+
+ // Deactivate it now
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data`
+SET
+ `holiday_active`='N',
+ `holiday_activated`=0
+WHERE
+ `userid`=%s
+LIMIT 1",
+ array(getMemberId()), __FILE__, __LINE__);
+
+ // Remove entry
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM
+ `{?_MYSQL_PREFIX?}_user_holidays`
+WHERE
+ `userid`=%s
+LIMIT 1",
+ array(getMemberId()), __FILE__, __LINE__);
+
+ // Send email to admin
+ sendAdminNotification('{--ADMIN_HOLIDAY_DEACTIVATED_SUBJECT--}', 'admin_holiday_deactivated', $content, getMemberId());
+
+ // Display message to user
+ displayMessage('{--MEMBER_HOLIDAY_DEACTIVATED_NOW--}');
+ } else {
+ // Display message to user
+ displayMessage('{--MEMBER_HOLIDAY_CANNOT_DEACTIVATE--}');
+ }
+
+ // Free result
+ SQL_FREERESULT($result2);
+ } elseif ($content['holiday_active'] == 'Y') {
+ // To fast!
+ displayMessage('{--MEMBER_HOLIDAY_LOCKED--}');