]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-holiday.php
Added update_year.sh (still not fully flexible) and updated all years with it.
[mailer.git] / inc / modules / member / what-holiday.php
index fc92311e16b29b20164f84ee6ddb31e793187d3f..703d9cbd5f2ded389d97e2fc4ddabbc9deaee57c 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -37,7 +37,7 @@
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       die();
+       exit();
 } elseif (!isMember()) {
        redirectToIndexMemberOnlyModule();
 }
@@ -54,7 +54,7 @@ if ((!isExtensionActive('holiday')) && (!isAdmin())) {
 $content = array();
 
 // Check for running mail orders in pool
-$result1 = SQL_QUERY_ESC("SELECT
+$result1 = sqlQueryEscaped("SELECT
        `timestamp`
 FROM
        `{?_MYSQL_PREFIX?}_pool`
@@ -65,7 +65,7 @@ ORDER BY
 LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
 
 // Check for sent mail orders in stats
-$result2 = SQL_QUERY_ESC("SELECT
+$result2 = sqlQueryEscaped("SELECT
        `timestamp_ordered`
 FROM
        `{?_MYSQL_PREFIX?}_user_stats`
@@ -75,21 +75,21 @@ ORDER BY
        `timestamp_ordered` DESC
 LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
 
-if ((SQL_NUMROWS($result1) == 1) || (SQL_NUMROWS($result2) == 1)) {
+if ((sqlNumRows($result1) == 1) || (sqlNumRows($result2) == 1)) {
        // Mail order found
-       $content = merge_array($content, SQL_FETCHARRAY($result1));
-       $content = merge_array($content, SQL_FETCHARRAY($result2));
+       $content = merge_array($content, sqlFetchArray($result1));
+       $content = merge_array($content, sqlFetchArray($result2));
 
        // Fix missing entries
        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())) {
+       if ((($content['timestamp'] + getHolidayLock()) > time()) || (($content['timestamp_ordered'] + getHolidayLock()) > time())) {
                // Mail order is to close away!
                unsetPostRequestElement('ok');
                unsetPostRequestElement('stop');
 
-               if (($content['timestamp'] + getConfig('holiday_lock')) > time()) {
+               if (($content['timestamp'] + getHolidayLock()) > time()) {
                        // Mail found in pool
                        $stamp = $content['timestamp'];
                } else {
@@ -104,26 +104,31 @@ if ((SQL_NUMROWS($result1) == 1) || (SQL_NUMROWS($result2) == 1)) {
 } // END - if
 
 // Free memory
-SQL_FREERESULT($result1);
-SQL_FREERESULT($result2);
+sqlFreeResult($result1);
+sqlFreeResult($result2);
 
 if (isFormSent()) {
        // Check holiday request...
-       $START = mktime(0, 0, 0, postRequestElement('start_month'), postRequestElement('start_day'), postRequestElement('start_year'));
-       $content['holiday_end']   = mktime(0, 0, 0, postRequestElement('end_month')  , postRequestElement('end_day')  , postRequestElement('end_year')  );
+       $content['holiday_start'] = mktime(0, 0, 0, postRequestElement('start_mo'), postRequestElement('start_da'), postRequestElement('start_ye'));
+       $content['holiday_end']   = mktime(0, 0, 0, postRequestElement('end_mo')  , postRequestElement('end_da')  , postRequestElement('end_ye')  );
 
        // Test both values
-       $TEST = $content['holiday_end'] - $START;
-       if (($TEST < 0) || ($TEST > (getOneDay() * getConfig('holiday_max'))) || ($START < time()) || ($content['holiday_end'] < time())) {
+       $TEST = $content['holiday_end'] - $content['holiday_start'];
+       if (($TEST < 0) || ($TEST > (getOneDay() * getConfig('holiday_max'))) || ($content['holiday_start'] < time()) || ($content['holiday_end'] < time())) {
                // Time test failed
                unsetPostRequestElement('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(getMemberId(), $START, $content['holiday_end'], postRequestElement('comments')), __FILE__, __LINE__);
+               sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_holidays` (`userid`, `holiday_start`, `holiday_end`, `comments`) VALUES ('%s','%s','%s','%s')",
+                       array(
+                               getMemberId(),
+                               $content['holiday_start'],
+                               $content['holiday_end'],
+                               postRequestElement('comments')
+                       ), __FILE__, __LINE__);
 
                // Activate holiday system
-               SQL_QUERY_ESC("UPDATE
+               sqlQueryEscaped("UPDATE
        `{?_MYSQL_PREFIX?}_user_data`
 SET
        `holiday_active`='N',
@@ -160,38 +165,41 @@ LIMIT 1",
 // Holiday shall be ended now
 if (isPostRequestElementSet('stop')) {
        // Okay, end the holiday here...
-       $result = SQL_QUERY_ESC("SELECT
-       `holiday_active`,`holiday_activated`
+       $result = sqlQueryEscaped("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) {
+       // Is there an entry?
+       if (sqlNumRows($result) == 1) {
                // Merge arrays
-               $content = merge_array($content, SQL_FETCHARRAY($result));
+               $content = merge_array($content, sqlFetchArray($result));
 
-               if (($content['holiday_active'] == 'Y') && (($content['holiday_activated'] + getConfig('holiday_lock')) < time())) {
+               if (($content['holiday_active'] == 'Y') && (($content['holiday_activated'] + getHolidayLock()) < time())) {
                        // Load data
-                       $result2 = SQL_QUERY_ESC("SELECT
-       `holiday_start`,`holiday_end`
+                       $result2 = sqlQueryEscaped("SELECT
+       `holiday_start`,
+       `holiday_end`
 FROM
        `{?_MYSQL_PREFIX?}_user_holidays`
 WHERE
        `userid`=%s
 LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
-                       if (SQL_NUMROWS($result2) == 1) {
+                       if (sqlNumRows($result2) == 1) {
                                // Data was found so merge it
-                               $content = merge_array($content, SQL_FETCHARRAY($result2));
+                               $content = merge_array($content, sqlFetchArray($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`
+                               sqlQueryEscaped("UPDATE
+       `{?_MYSQL_PREFIX?}_user_data`
 SET
        `holiday_active`='N',
        `holiday_activated`=0
@@ -201,7 +209,7 @@ LIMIT 1",
                                        array(getMemberId()), __FILE__, __LINE__);
 
                                // Remove entry
-                               SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM
+                               sqlQueryEscaped("DELETE LOW_PRIORITY FROM
        `{?_MYSQL_PREFIX?}_user_holidays`
 WHERE
        `userid`=%s
@@ -219,7 +227,7 @@ LIMIT 1",
                        }
 
                        // Free result
-                       SQL_FREERESULT($result2);
+                       sqlFreeResult($result2);
                } elseif ($content['holiday_active'] == 'Y') {
                        // To fast!
                        displayMessage('{--MEMBER_HOLIDAY_LOCKED--}');
@@ -230,38 +238,40 @@ LIMIT 1",
        }
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 } // END - if
 
 // If something is wrong or link in menu is just clicked display form
 if ((!isFormSent()) && (!isPostRequestElementSet('stop'))) {
        // Check if user is in holiday...
-       $result = SQL_QUERY_ESC("SELECT
-       `holiday_active`,`holiday_activated`
+       $result = sqlQueryEscaped("SELECT
+       `holiday_active`,
+       `holiday_activated`
 FROM
        `{?_MYSQL_PREFIX?}_user_data`
 WHERE
        `userid`=%s
 LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
-       $content = SQL_FETCHARRAY($result);
-       SQL_FREERESULT($result);
+       $content = sqlFetchArray($result);
+       sqlFreeResult($result);
 
        // Check for lock
-       if (($content['holiday_activated'] + getConfig('holiday_lock')) < time()) {
+       if (($content['holiday_activated'] + getHolidayLock()) < time()) {
                // User can deactivate his holiday request
                switch ($content['holiday_active']) {
                        case 'Y': // Display deactivation form
                                // Load starting and ending date
-                               $result = SQL_QUERY_ESC("SELECT
-       `holiday_start`,`holiday_end`
+                               $result = sqlQueryEscaped("SELECT
+       `holiday_start`,
+       `holiday_end`
 FROM
        `{?_MYSQL_PREFIX?}_user_holidays`
 WHERE
        `userid`=%s
 LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
-                               if (SQL_NUMROWS($result) == 1) {
+                               if (sqlNumRows($result) == 1) {
                                        // Data was found so merge it
-                                       $content = merge_array($content, SQL_FETCHARRAY($result));
+                                       $content = merge_array($content, sqlFetchArray($result));
 
                                        // Prepare it for the template
                                        $content['start'] = generateDateTime($content['holiday_start'] , 3);
@@ -269,13 +279,13 @@ LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
                                        $content['lock']  = generateDateTime($content['holiday_activated'], 1);
 
                                        // Load template
-                                       loadTemplate('member_holiday_deactivate', false, $content);
+                                       loadTemplate('member_holiday_deactivate', FALSE, $content);
                                } else {
                                        // Free memory
-                                       SQL_FREERESULT($result);
+                                       sqlFreeResult($result);
 
                                        // Remove entry and reload URL
-                                       SQL_QUERY_ESC("UPDATE
+                                       sqlQueryEscaped("UPDATE
        `{?_MYSQL_PREFIX?}_user_data`
 SET
        `holiday_active`='N'
@@ -288,7 +298,7 @@ LIMIT 1",
                                }
 
                                // Free result
-                               SQL_FREERESULT($result);
+                               sqlFreeResult($result);
                                break;
 
                        case 'N': // Display activation form
@@ -297,17 +307,17 @@ LIMIT 1",
                                $endingStamp   = $startingStamp + (getOneDay() * getConfig('holiday_max'));
 
                                // Starting day
-                               $content['start_day']   = addSelectionBox('day'  , getDay($startingStamp)  , 'start');
-                               $content['start_month'] = addSelectionBox('month', getMonth($startingStamp), 'start');
-                               $content['start_year']  = addSelectionBox('year' , getYear($startingStamp) , 'start');
+                               $content['start_day']   = addSelectionBox('da', getDay($startingStamp)  , 'start');
+                               $content['start_month'] = addSelectionBox('mo', getMonth($startingStamp), 'start');
+                               $content['start_year']  = addSelectionBox('ye', getYear($startingStamp) , 'start');
 
                                // Ending day
-                               $content['end_day']   = addSelectionBox('day'  , getDay($endingStamp)  , 'end');
-                               $content['end_month'] = addSelectionBox('month', getMonth($endingStamp), 'end');
-                               $content['end_year']  = addSelectionBox('year' , getYear($endingStamp) , 'end');
+                               $content['end_day']   = addSelectionBox('da', getDay($endingStamp)  , 'end');
+                               $content['end_month'] = addSelectionBox('mo', getMonth($endingStamp), 'end');
+                               $content['end_year']  = addSelectionBox('ye', getYear($endingStamp) , 'end');
 
                                // Output form
-                               loadTemplate('member_holiday_form', false, $content);
+                               loadTemplate('member_holiday_form', FALSE, $content);
                                break;
                } // END - switch
        } else {