<?php
/************************************************************************
- * MXChange v0.2.1 Start: 07/24/2004 *
- * ================ Last change: 07/31/2004 *
+ * Mailer v0.2.1-FINAL Start: 07/24/2004 *
+ * =================== Last change: 07/31/2004 *
* *
* -------------------------------------------------------------------- *
* File : what-holiday.php *
* Needs to be in all Files and every File needs "svn propset *
* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
// Some security stuff...
if (!defined('__SECURITY')) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
- require($INC);
-} elseif (!IS_MEMBER()) {
- redirectToUrl('modules.php?module=index');
-} elseif ((!EXT_IS_ACTIVE('holiday')) && (!IS_ADMIN())) {
- addFatalMessage(__FILE__, __LINE__, generateExtensionInactiveNotInstalledMessage('holiday'));
- return;
+ die();
+} elseif (!isMember()) {
+ redirectToIndexMemberOnlyModule();
}
+// Add description as navigation point
+addMenuDescription('member', __FILE__);
+
+if ((!isExtensionActive('holiday')) && (!isAdmin())) {
+ loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('holiday'));
+ return;
+} // END - if
+
// Init content array
$content = array();
-// Add description as navigation point
-ADD_DESCR('member', __FILE__);
-
// Check for running mail orders in pool
$result1 = SQL_QUERY_ESC("SELECT
`timestamp`
FROM
- `{!_MYSQL_PREFIX!}_pool`
+ `{?_MYSQL_PREFIX?}_pool`
WHERE
`sender`=%s
ORDER BY
`timestamp` DESC
-LIMIT 1", array(getUserId()), __FILE__, __LINE__);
+LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
// Check for sent mail orders in stats
$result2 = SQL_QUERY_ESC("SELECT
`timestamp_ordered`
FROM
- `{!_MYSQL_PREFIX!}_user_stats`
+ `{?_MYSQL_PREFIX?}_user_stats`
WHERE
`userid`=%s
ORDER BY
`timestamp_ordered` DESC
-LIMIT 1", array(getUserId()), __FILE__, __LINE__);
+LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
if ((SQL_NUMROWS($result1) == 1) || (SQL_NUMROWS($result2) == 1)) {
// Mail order found!
$content = merge_array($content, SQL_FETCHARRAY($result2));
// Fix missing entries
- if (empty($content['timestamp'])) $content['timestamp'] = 0;
- if (empty($content['timestamp_ordered'])) $content['timestamp_ordered'] = 0;
+ if (empty($content['timestamp'])) $content['timestamp'] = '0';
+ if (empty($content['timestamp_ordered'])) $content['timestamp_ordered'] = '0';
if ((($content['timestamp'] + getConfig('holiday_lock')) > time()) || (($content['timestamp_ordered'] + getConfig('holiday_lock')) > time())) {
// Mail order is to close away!
- REQUEST_UNSET_POST('ok');
- REQUEST_UNSET_POST('stop');
+ unsetPostRequestParameter('ok');
+ unsetPostRequestParameter('stop');
if (($content['timestamp'] + getConfig('holiday_lock')) > time()) {
// Mail found in pool
}
// Display message and exit here
- LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('HOLIDAY_MEMBER_ORDER'), generateDateTime($stamp, '1')));
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('HOLIDAY_MEMBER_ORDER', generateDateTime($stamp, 1)));
return;
}
} // END - if
if (isFormSent()) {
// Check holiday request...
- $START = mktime(0, 0, 0, REQUEST_POST('start_month'), REQUEST_POST('start_day'), REQUEST_POST('start_year'));
- $content['holiday_end'] = mktime(0, 0, 0, REQUEST_POST('end_month') , REQUEST_POST('end_day') , REQUEST_POST('end_year') );
+ $START = mktime(0, 0, 0, postRequestParameter('start_month'), postRequestParameter('start_day'), postRequestParameter('start_year'));
+ $content['holiday_end'] = mktime(0, 0, 0, postRequestParameter('end_month') , postRequestParameter('end_day') , postRequestParameter('end_year') );
// Test both values
$TEST = $content['holiday_end'] - $START;
- if (($TEST < 0) || ($TEST > (getConfig('one_day') * getConfig('holiday_max'))) || ($START < time()) || ($content['holiday_end'] < time())) {
+ if (($TEST < 0) || ($TEST > (getConfig('ONE_DAY') * getConfig('holiday_max'))) || ($START < time()) || ($content['holiday_end'] < time())) {
// Time test failed
- REQUEST_UNSET_POST('ok');
+ unsetPostRequestParameter('ok');
} else {
// Everything went okay so let's store his request and send mails
- SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_holidays` (`userid`, `holiday_start`, `holiday_end`, `comments`) VALUES ('%s','%s','%s','%s')",
- array(getUserId(), $START, $content['holiday_end'], REQUEST_POST('comments')), __FILE__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_holidays` (`userid`, `holiday_start`, `holiday_end`, `comments`) VALUES ('%s','%s','%s','%s')",
+ array(getMemberId(), $START, $content['holiday_end'], postRequestParameter('comments')), __FILE__, __LINE__);
// Activate holiday system
SQL_QUERY_ESC("UPDATE
- `{!_MYSQL_PREFIX!}_user_data`
+ `{?_MYSQL_PREFIX?}_user_data`
SET
`holiday_active`='N', `holiday_activated`=UNIX_TIMESTAMP()
WHERE
`userid`=%s
LIMIT 1",
- array(getUserId()), __FILE__, __LINE__);
+ array(getMemberId()), __FILE__, __LINE__);
// Prepare constants
- define('_START_DAY' , REQUEST_POST('start_day'));
- define('_START_MONTH', $GLOBALS['month_descr'][REQUEST_POST('start_month')]);
- define('_START_YEAR' , REQUEST_POST('start_year'));
- define('_END_DAY' , REQUEST_POST('end_day'));
- define('_END_MONTH' , $GLOBALS['month_descr'][REQUEST_POST('end_month')]);
- define('_END_YEAR' , REQUEST_POST('end_year'));
+ $content['start_day'] = bigintval(postRequestParameter('start_day'));
+ $content['start_month'] = $GLOBALS['month_descr'][postRequestParameter('start_month')];
+ $content['start_year'] = bigintval(postRequestParameter('start_year'));
+ $content['end_day'] = bigintval(postRequestParameter('end_day'));
+ $content['end_month'] = $GLOBALS['month_descr'][postRequestParameter('end_month')];
+ $content['end_year'] = bigintval(postRequestParameter('end_year'));
+ $content['comments'] = secureString(postRequestParameter('comments'));
// Send mail to member
- $message = LOAD_EMAIL_TEMPLATE('member_holiday_request', REQUEST_POST('comments'), getUserId());
- sendEmail(getUserId(), getMessage('HOLIDAY_MEMBER_SUBJECT'), $message);
+ $message = loadEmailTemplate('member_holiday_request', $content, getMemberId());
+ sendEmail(getMemberId(), getMessage('HOLIDAY_MEMBER_SUBJECT'), $message);
// Send mail to all admins
- sendAdminNotification(getMessage('HOLIDAY_ADMIN_SUBJECT'), 'admin_holiday_request', REQUEST_POST('comments'), getUserId());
+ sendAdminNotification(getMessage('HOLIDAY_ADMIN_SUBJECT'), 'admin_holiday_request', $content, getMemberId());
// Create task
- createNewTask('{--HOLIDAY_ADMIN_SUBJECT--}', $message, 'HOLIDAY_REQUEST', getUserId());
+ createNewTask('{--HOLIDAY_ADMIN_SUBJECT--}', $message, 'HOLIDAY_REQUEST', getMemberId());
// Display message
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('HOLIDAY_IS_ACTIVATED_NOW'));
+ loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_IS_ACTIVATED_NOW'));
}
} // END - if
// Holiday shall be ended now
-if (REQUEST_ISSET_POST('stop')) {
+if (isPostRequestParameterSet('stop')) {
// Okay, end the holiday here...
$result = SQL_QUERY_ESC("SELECT
`holiday_active`, `holiday_activated`
FROM
- `{!_MYSQL_PREFIX!}_user_data`
+ `{?_MYSQL_PREFIX?}_user_data`
WHERE
`userid`=%s
-LIMIT 1", array(getUserId()), __FILE__, __LINE__);
+LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
$content = merge_array($content, SQL_FETCHARRAY($result));
SQL_FREERESULT($result);
$result = SQL_QUERY_ESC("SELECT
`holiday_start`, `holiday_end`
FROM
- `{!_MYSQL_PREFIX!}_user_holidays`
+ `{?_MYSQL_PREFIX?}_user_holidays`
WHERE
`userid`=%s
-LIMIT 1", array(getUserId()), __FILE__, __LINE__);
+LIMIT 1", array(getMemberId()), __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
- define('__HOLIDAY_START', generateDateTime($content['holiday_start'], '3'));
- define('__HOLIDAY_END' , generateDateTime($content['holiday_end'] , '3'));
+ $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`
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data`
SET
`holiday_active`='N',
`holiday_activated`=0
WHERE
`userid`=%s
-LIMIT 1", array(getUserId()), __FILE__, __LINE__);
+LIMIT 1",
+ array(getMemberId()), __FILE__, __LINE__);
// Remove entry
SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM
- `{!_MYSQL_PREFIX!}_user_holidays`
+ `{?_MYSQL_PREFIX?}_user_holidays`
WHERE
`userid`=%s
-LIMIT 1", array(getUserId()), __FILE__, __LINE__);
+LIMIT 1",
+ array(getMemberId()), __FILE__, __LINE__);
// Send email to admin
- sendAdminNotification(getMessage('HOLIDAY_ADMIN_DEAC_SUBJ'), 'admin_holiday_deactivated', array(), getUserId());
+ sendAdminNotification(getMessage('HOLIDAY_ADMIN_DEAC_SUBJ'), 'admin_holiday_deactivated', $content, getMemberId());
// Display message to user
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_DEACTIVATED_NOW'));
+ loadTemplate('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'));
+ loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_CANNOT_DEACTIVATE'));
}
} elseif ($content['holiday_active'] == 'Y') {
// To fast!
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_LOCKED'));
+ loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_LOCKED'));
}
} // END - if
// If something is wrong or link in menu is just clicked display form
-if ((!isFormSent()) && (!REQUEST_ISSET_POST('stop'))) {
+if ((!isFormSent()) && (!isPostRequestParameterSet('stop'))) {
// Check if user is in holiday...
$result = SQL_QUERY_ESC("SELECT
`holiday_active`, `holiday_activated`
FROM
- `{!_MYSQL_PREFIX!}_user_data`
+ `{?_MYSQL_PREFIX?}_user_data`
WHERE
`userid`=%s
-LIMIT 1", array(getUserId()), __FILE__, __LINE__);
+LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
$content = SQL_FETCHARRAY($result);
SQL_FREERESULT($result);
$result = SQL_QUERY_ESC("SELECT
`holiday_start`, `holiday_end`
FROM
- `{!_MYSQL_PREFIX!}_user_holidays`
+ `{?_MYSQL_PREFIX?}_user_holidays`
WHERE
`userid`=%s
-LIMIT 1", array(getUserId()), __FILE__, __LINE__);
+LIMIT 1", array(getMemberId()), __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
- define('__HOLIDAY_START', generateDateTime($content['holiday_start'] , '3'));
- define('__HOLIDAY_END' , generateDateTime($content['holiday_end'] , '3'));
- define('__HOLIDAY_LOCK' , generateDateTime($content['holiday_activated'], '1'));
+ $content['start'] = generateDateTime($content['holiday_start'] , 3);
+ $content['end'] = generateDateTime($content['holiday_end'] , 3);
+ $content['lock'] = generateDateTime($content['holiday_activated'], 1);
// Load template
- LOAD_TEMPLATE('member_holiday_deactivate');
+ 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`
+ `{?_MYSQL_PREFIX?}_user_data`
SET
`holiday_active`='N'
WHERE
`userid`=%s
-LIMIT 1", array(getUserId()), __FILE__, __LINE__);
+LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
redirectToUrl('modules.php?module=login&what=holiday');
return;
}
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'));
+ $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')));
+ $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'));
+ $content['end_day'] = addSelectionBox('day' , $D, 'end');
+ $content['end_month'] = addSelectionBox('month', $M, 'end');
+ $content['end_year'] = addSelectionBox('year' , $Y, 'end');
// Output form
- LOAD_TEMPLATE('member_holiday_form');
+ loadTemplate('member_holiday_form', false, $content);
break;
}
} else {
// To fast!
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_LOCKED'));
+ loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_LOCKED'));
}
} // END - if