]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-holiday.php
Fixed calls of addSelectionBox()
[mailer.git] / inc / modules / member / what-holiday.php
index d22688bea8629675837ddec0bdc865c6771770a1..713119e5b66c8a0f718283ed586d64433e939093 100644 (file)
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       die();
+       exit();
 } elseif (!isMember()) {
        redirectToIndexMemberOnlyModule();
 }
 
 // Add description as navigation point
-addMenuDescription('member', __FILE__);
+addYouAreHereLink('member', __FILE__);
 
 if ((!isExtensionActive('holiday')) && (!isAdmin())) {
-       loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('holiday'));
+       displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=holiday%}');
        return;
 } // END - if
 
@@ -78,7 +76,7 @@ ORDER BY
 LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
 
 if ((SQL_NUMROWS($result1) == 1) || (SQL_NUMROWS($result2) == 1)) {
-       // Mail order found!
+       // Mail order found
        $content = merge_array($content, SQL_FETCHARRAY($result1));
        $content = merge_array($content, SQL_FETCHARRAY($result2));
 
@@ -86,12 +84,12 @@ if ((SQL_NUMROWS($result1) == 1) || (SQL_NUMROWS($result2) == 1)) {
        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!
-               unsetPostRequestParameter('ok');
-               unsetPostRequestParameter('stop');
+               unsetPostRequestElement('ok');
+               unsetPostRequestElement('stop');
 
-               if (($content['timestamp'] + getConfig('holiday_lock')) > time()) {
+               if (($content['timestamp'] + getHolidayLock()) > time()) {
                        // Mail found in pool
                        $stamp = $content['timestamp'];
                } else {
@@ -100,7 +98,7 @@ if ((SQL_NUMROWS($result1) == 1) || (SQL_NUMROWS($result2) == 1)) {
                }
 
                // Display message and exit here
-               loadTemplate('admin_settings_saved', false, getMaskedMessage('HOLIDAY_MEMBER_ORDER', generateDateTime($stamp, 1)));
+               displayMessage('{%message,MEMBER_HOLIDAY_ORDER', generateDateTime($stamp, '1') . '%}');
                return;
        }
 } // END - if
@@ -111,41 +109,47 @@ SQL_FREERESULT($result2);
 
 if (isFormSent()) {
        // Check holiday request...
-       $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')  );
+       $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')  );
 
        // 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 > (getOneDay() * getConfig('holiday_max'))) || ($START < time()) || ($content['holiday_end'] < time())) {
                // Time test failed
-               unsetPostRequestParameter('ok');
+               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'], postRequestParameter('comments')), __FILE__, __LINE__);
+                       array(
+                               getMemberId(),
+                               $START,
+                               $content['holiday_end'],
+                               postRequestElement('comments')
+                       ), __FILE__, __LINE__);
 
                // Activate holiday system
                SQL_QUERY_ESC("UPDATE
        `{?_MYSQL_PREFIX?}_user_data`
 SET
-       `holiday_active`='N', `holiday_activated`=UNIX_TIMESTAMP()
+       `holiday_active`='N',
+       `holiday_activated`=UNIX_TIMESTAMP()
 WHERE
        `userid`=%s
 LIMIT 1",
                        array(getMemberId()), __FILE__, __LINE__);
 
                // Prepare constants
-               $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'));
+               $content['start_day']   = bigintval(postRequestElement('start_day'));
+               $content['start_month'] = $GLOBALS['month_descr'][postRequestElement('start_month')];
+               $content['start_year']  = bigintval(postRequestElement('start_year'));
+               $content['end_day']     = bigintval(postRequestElement('end_day'));
+               $content['end_month']   = $GLOBALS['month_descr'][postRequestElement('end_month')];
+               $content['end_year']    = bigintval(postRequestElement('end_year'));
+               $content['comments']    = postRequestElement('comments');
 
                // Send mail to member
                $message = loadEmailTemplate('member_holiday_request', $content, getMemberId());
-               sendEmail(getMemberId(), '{--HOLIDAY_MEMBER_SUBJECT--}', $message);
+               sendEmail(getMemberId(), '{--MEMBER_HOLIDAY_SUBJECT--}', $message);
 
                // Send mail to all admins
                sendAdminNotification('{--ADMIN_HOLIDAY_SUBJECT--}', 'admin_holiday_request', $content, getMemberId());
@@ -154,30 +158,32 @@ LIMIT 1",
                createNewTask('{--ADMIN_HOLIDAY_SUBJECT--}', $message, 'HOLIDAY_REQUEST', getMemberId());
 
                // Display message
-               loadTemplate('admin_settings_saved', false, '{--HOLIDAY_IS_ACTIVATED_NOW--}');
+               displayMessage('{--MEMBER_HOLIDAY_IS_ACTIVATED_NOW--}');
        }
 } // END - if
 
 // Holiday shall be ended now
-if (isPostRequestParameterSet('stop')) {
+if (isPostRequestElementSet('stop')) {
        // Okay, end the holiday here...
        $result = SQL_QUERY_ESC("SELECT
-       `holiday_active`, `holiday_activated`
+       `holiday_active`,
+       `holiday_activated`
 FROM
        `{?_MYSQL_PREFIX?}_user_data`
 WHERE
        `userid`=%s
 LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
 
-       // Do we have an entry?
+       // Is there 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())) {
+               if (($content['holiday_active'] == 'Y') && (($content['holiday_activated'] + getHolidayLock()) < time())) {
                        // Load data
                        $result2 = SQL_QUERY_ESC("SELECT
-       `holiday_start`, `holiday_end`
+       `holiday_start`,
+       `holiday_end`
 FROM
        `{?_MYSQL_PREFIX?}_user_holidays`
 WHERE
@@ -192,7 +198,8 @@ LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
                                $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
@@ -210,24 +217,24 @@ LIMIT 1",
                                        array(getMemberId()), __FILE__, __LINE__);
 
                                // Send email to admin
-                               sendAdminNotification('{--ADMIN_HOLIDAY_DEAC_SUBJECT--}', 'admin_holiday_deactivated', $content, getMemberId());
+                               sendAdminNotification('{--ADMIN_HOLIDAY_DEACTIVATED_SUBJECT--}', 'admin_holiday_deactivated', $content, getMemberId());
 
                                // Display message to user
-                               loadTemplate('admin_settings_saved', false, '{--HOLIDAY_MEMBER_DEACTIVATED_NOW--}');
+                               displayMessage('{--MEMBER_HOLIDAY_DEACTIVATED_NOW--}');
                        } else {
                                // Display message to user
-                               loadTemplate('admin_settings_saved', false, '{--HOLIDAY_MEMBER_CANNOT_DEACTIVATE--}');
+                               displayMessage('{--MEMBER_HOLIDAY_CANNOT_DEACTIVATE--}');
                        }
 
                        // Free result
                        SQL_FREERESULT($result2);
                } elseif ($content['holiday_active'] == 'Y') {
                        // To fast!
-                       loadTemplate('admin_settings_saved', false, '{--HOLIDAY_MEMBER_LOCKED--}');
+                       displayMessage('{--MEMBER_HOLIDAY_LOCKED--}');
                }
        } else {
                // User not found
-               loadTemplate('admin_settings_saved', false, getMaskedMessage('HOLIDAY_MEMBER_NOT_STOPPED_404', getMemberId()));
+               displayMessage('{--MEMBER_HOLIDAY_NOT_STOPPED_404--}');
        }
 
        // Free result
@@ -235,10 +242,11 @@ LIMIT 1",
 } // END - if
 
 // If something is wrong or link in menu is just clicked display form
-if ((!isFormSent()) && (!isPostRequestParameterSet('stop'))) {
+if ((!isFormSent()) && (!isPostRequestElementSet('stop'))) {
        // Check if user is in holiday...
        $result = SQL_QUERY_ESC("SELECT
-       `holiday_active`, `holiday_activated`
+       `holiday_active`,
+       `holiday_activated`
 FROM
        `{?_MYSQL_PREFIX?}_user_data`
 WHERE
@@ -248,14 +256,14 @@ LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
        SQL_FREERESULT($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'])
-               {
+               switch ($content['holiday_active']) {
                        case 'Y': // Display deactivation form
                                // Load starting and ending date
                                $result = SQL_QUERY_ESC("SELECT
-       `holiday_start`, `holiday_end`
+       `holiday_start`,
+       `holiday_end`
 FROM
        `{?_MYSQL_PREFIX?}_user_holidays`
 WHERE
@@ -271,7 +279,7 @@ 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);
@@ -283,7 +291,8 @@ SET
        `holiday_active`='N'
 WHERE
        `userid`=%s
-LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
+LIMIT 1",
+                                               array(getMemberId()), __FILE__, __LINE__);
                                        redirectToUrl('modules.php?module=login&amp;what=holiday');
                                        return;
                                }
@@ -294,26 +303,26 @@ LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
 
                        case 'N': // Display activation form
                                // Cache timestamps
-                               $startingStamp = time() + getConfig('ONE_DAY');
-                               $endingStamp   = $startingStamp + (getConfig('ONE_DAY') * getConfig('holiday_max');
+                               $startingStamp = time() + getOneDay();
+                               $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 {
                // To fast!
-               loadTemplate('admin_settings_saved', false, '{--HOLIDAY_MEMBER_LOCKED--}');
+               displayMessage('{--MEMBER_HOLIDAY_LOCKED--}');
        }
 } // END - if