- case "Y": // Display deactivation form
- // Load starting and ending date
- $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', MAKE_DATETIME($start , "3"));
- define('__HOLIDAY_END' , MAKE_DATETIME($end , "3"));
- define('__HOLIDAY_LOCK' , MAKE_DATETIME($locked, "1"));
-
- // Load template
- LOAD_TEMPLATE("member_holiday_deactivate");
- }
- else
- {
- // Free memory
- SQL_FREERESULT($result);
-
- // Remove entry and reload URL
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data`
-SET holiday_active='N'
-WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
- LOAD_URL("modules.php?module=login&what=holiday");
- return;
- }
- break;
-
- case "N": // Display activation form
- // Starting day
- define('_START_DAY' , ADD_SELECTION("day" , date("d", (time() + getConfig('one_day'))), "start"));
- define('_START_MONTH', ADD_SELECTION("month", date("m", (time() + getConfig('one_day'))), "start"));
- define('_START_YEAR' , ADD_SELECTION("year" , date('Y', (time() + getConfig('one_day'))), "start"));
-
- // Calcualte ending date
- $D = date("d", time() + getConfig('one_day') + (getConfig('one_day') * getConfig('holiday_max')));
- $M = date("m", time() + getConfig('one_day') + (getConfig('one_day') * getConfig('holiday_max')));
- $Y = date('Y', time() + getConfig('one_day') + (getConfig('one_day') * getConfig('holiday_max')));
-
- // Ending day
- define('_END_DAY' , ADD_SELECTION("day" , $D, "end"));
- define('_END_MONTH', ADD_SELECTION("month", $M, "end"));
- define('_END_YEAR' , ADD_SELECTION("year" , $Y, "end"));
-
- // Copy value from configuration
- define('__HOLIDAY_MAX', getConfig('holiday_max'));
-
- // Output form
- LOAD_TEMPLATE("member_holiday_form");
- break;
+ case 'Y': // Display deactivation form
+ // Load starting and ending date
+ $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
+ $content = merge_array($content, SQL_FETCHARRAY($result));
+ SQL_FREERESULT($result);
+
+ // Prepare it for the template
+ $content['start'] = generateDateTime($content['holiday_start'] , 3);
+ $content['end'] = generateDateTime($content['holiday_end'] , 3);
+ $content['lock'] = generateDateTime($content['holiday_activated'], 1);
+
+ // Load template
+ loadTemplate('member_holiday_deactivate', false, $content);
+ } else {
+ // Free memory
+ SQL_FREERESULT($result);
+
+ // Remove entry and reload URL
+ SQL_QUERY_ESC("UPDATE
+ `{?_MYSQL_PREFIX?}_user_data`
+SET
+ `holiday_active`='N'
+WHERE
+ `userid`=%s
+LIMIT 1", array(getUserId()), __FILE__, __LINE__);
+ redirectToUrl('modules.php?module=login&what=holiday');
+ return;
+ }
+ break;
+
+ case 'N': // Display activation form
+ // Starting day
+ $content['start_day'] = addSelectionBox('day' , date('d', (time() + getConfig('ONE_DAY'))), 'start');
+ $content['start_month'] = addSelectionBox('month', date('m', (time() + getConfig('ONE_DAY'))), 'start');
+ $content['start_year'] = addSelectionBox('year' , date('Y', (time() + getConfig('ONE_DAY'))), 'start');
+
+ // Calcualte ending date
+ $D = date('d', time() + getConfig('ONE_DAY') + (getConfig('ONE_DAY') * getConfig('holiday_max')));
+ $M = date('m', time() + getConfig('ONE_DAY') + (getConfig('ONE_DAY') * getConfig('holiday_max')));
+ $Y = date('Y', time() + getConfig('ONE_DAY') + (getConfig('ONE_DAY') * getConfig('holiday_max')));
+
+ // Ending day
+ $content['end_day'] = addSelectionBox('day' , $D, 'end');
+ $content['end_month'] = addSelectionBox('month', $M, 'end');
+ $content['end_year'] = addSelectionBox('year' , $Y, 'end');
+
+ // Output form
+ loadTemplate('member_holiday_form');
+ break;