} elseif (!IS_MEMBER()) {
LOAD_URL("modules.php?module=index");
} elseif ((!EXT_IS_ACTIVE("holiday")) && (!IS_ADMIN())) {
- ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "holiday");
+ addFatalMessage(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "holiday");
return;
}
// Add description as navigation point
-ADD_DESCR("member", basename(__FILE__));
+ADD_DESCR("member", __FILE__);
// Check for running mail orders in pool
-$result1 = SQL_QUERY_ESC("SELECT timestamp FROM "._MYSQL_PREFIX."_pool
+$result1 = SQL_QUERY_ESC("SELECT timestamp FROM `{!_MYSQL_PREFIX!}_pool`
WHERE sender=%s ORDER BY timestamp DESC LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
// Check for sent mail orders in stats
-$result2 = SQL_QUERY_ESC("SELECT timestamp_ordered FROM "._MYSQL_PREFIX."_user_stats
+$result2 = SQL_QUERY_ESC("SELECT timestamp_ordered FROM `{!_MYSQL_PREFIX!}_user_stats`
WHERE userid=%s ORDER BY timestamp_ordered DESC LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
if ((SQL_NUMROWS($result1) == 1) || (SQL_NUMROWS($result2) == 1))
if (empty($stamp1)) $stamp1 = 0;
if (empty($stamp2)) $stamp2 = 0;
- if ((($stamp1 + $_CONFIG['holiday_lock']) > time()) || (($stamp2 + $_CONFIG['holiday_lock']) > time()))
+ if ((($stamp1 + getConfig('holiday_lock')) > time()) || (($stamp2 + getConfig('holiday_lock')) > time()))
{
// Mail order is to close away!
unset($_POST['ok']);
unset($_POST['stop']);
- if (($stamp1 + $_CONFIG['holiday_lock']) > time())
+ if (($stamp1 + getConfig('holiday_lock')) > time())
{
// Mail found in pool
$stamp = $stamp1;
// Test both values
$TEST = $END - $START;
- if (($TEST < 0) || ($TEST > (ONE_DAY * $_CONFIG['holiday_max'])) || ($START < time()) || ($END < time()))
+ if (($TEST < 0) || ($TEST > (getConfig('one_day') * getConfig('holiday_max'))) || ($START < time()) || ($END < time()))
{
// Time test failed
unset($_POST['ok']);
else
{
// Everything went okay so let's store his request and send mails
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_holidays (userid, holiday_start, holiday_end, comments) VALUES ('%s','%s','%s','%s')",
+ SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_holidays` (userid, holiday_start, holiday_end, comments) VALUES ('%s','%s','%s','%s')",
array($GLOBALS['userid'], $START, $END, $_POST['comments']), __FILE__, __LINE__);
// Activate holiday system
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data`
SET holiday_active='N', holiday_activated=UNIX_TIMESTAMP()
WHERE userid=%s LIMIT 1",
array($GLOBALS['userid']), __FILE__, __LINE__);
SEND_ADMIN_NOTIFICATION(HOLIDAY_ADMIN_SUBJECT, "admin_holiday_request", $_POST['comments'], $GLOBALS['userid']);
// Create task
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_task_system (userid, assigned_admin, status, task_type, subject, text, task_created) VALUES ('%s','0','NEW','HOLIDAY_REQUEST','%s','%s', UNIX_TIMESTAMP())",
- array($GLOBALS['userid'], HOLIDAY_ADMIN_SUBJECT, addslashes($msg)), __FILE__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (userid, assigned_admin, status, task_type, subject, text, task_created) VALUES ('%s','0','NEW','HOLIDAY_REQUEST','%s','%s', UNIX_TIMESTAMP())",
+ array($GLOBALS['userid'], HOLIDAY_ADMIN_SUBJECT, $msg), __FILE__, __LINE__);
// Display message
LOAD_TEMPLATE("admin_settings_saved", false, HOLIDAY_IS_ACTIVATED_NOW);
if (isset($_POST['stop']))
{
// Okay, end the holiday here...
- $result = SQL_QUERY_ESC("SELECT holiday_active, holiday_activated FROM "._MYSQL_PREFIX."_user_data
+ $result = SQL_QUERY_ESC("SELECT holiday_active, holiday_activated FROM `{!_MYSQL_PREFIX!}_user_data`
WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
list($active, $locked) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
- if (($active == "Y") && (($locked + $_CONFIG['holiday_lock']) < time()))
+ if (($active == "Y") && (($locked + getConfig('holiday_lock')) < time()))
{
// Load data
- $result = SQL_QUERY_ESC("SELECT holiday_start, holiday_end FROM "._MYSQL_PREFIX."_user_holidays
+ $result = SQL_QUERY_ESC("SELECT holiday_start, holiday_end FROM `{!_MYSQL_PREFIX!}_user_holidays`
WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1)
{
define('__HOLIDAY_END' , MAKE_DATETIME($end , "3"));
// Deactivate it now
- $result = 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($GLOBALS['userid']), __FILE__, __LINE__);
// Remove entry
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_holidays
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_holidays`
WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
// Send email to admin
if ((!isset($_POST['ok'])) && (!isset($_POST['stop'])))
{
// Check if user is in holiday...
- $result = SQL_QUERY_ESC("SELECT holiday_active, holiday_activated FROM "._MYSQL_PREFIX."_user_data
+ $result = SQL_QUERY_ESC("SELECT holiday_active, holiday_activated FROM `{!_MYSQL_PREFIX!}_user_data`
WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
list($active, $locked) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
// Check for lock
- if (($locked + $_CONFIG['holiday_lock']) < time())
+ if (($locked + getConfig('holiday_lock')) < time())
{
// User can deactivate his holiday request
switch ($active)
{
- case 'Y': // Display deactivation form
+ case "Y": // Display deactivation form
// Load starting and ending date
- $result = SQL_QUERY_ESC("SELECT holiday_start, holiday_end FROM "._MYSQL_PREFIX."_user_holidays
+ $result = SQL_QUERY_ESC("SELECT holiday_start, holiday_end FROM `{!_MYSQL_PREFIX!}_user_holidays`
WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1)
{
SQL_FREERESULT($result);
// Remove entry and reload URL
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data`
SET holiday_active='N'
WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
LOAD_URL("modules.php?module=login&what=holiday");
}
break;
- case 'N': // Display activation form
+ case "N": // Display activation form
// Starting day
- define('_START_DAY' , ADD_SELECTION("day" , date("d", (time() + ONE_DAY)), "start"));
- define('_START_MONTH', ADD_SELECTION("month", date("m", (time() + ONE_DAY)), "start"));
- define('_START_YEAR' , ADD_SELECTION("year" , date('Y', (time() + ONE_DAY)), "start"));
+ 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() + ONE_DAY + (ONE_DAY * $_CONFIG['holiday_max']));
- $M = date("m", time() + ONE_DAY + (ONE_DAY * $_CONFIG['holiday_max']));
- $Y = date('Y', time() + ONE_DAY + (ONE_DAY * $_CONFIG['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_YEAR' , ADD_SELECTION("year" , $Y, "end"));
// Copy value from configuration
- define('__HOLIDAY_MAX', $_CONFIG['holiday_max']);
+ define('__HOLIDAY_MAX', getConfig('holiday_max'));
// Output form
LOAD_TEMPLATE("member_holiday_form");