X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fmember%2Fwhat-holiday.php;h=bfcffff743d30f0ef1765d3bee6c933e18b68651;hp=973f158538a29faf6215086f219c631bce996c04;hb=04b69ac9f33369cbf654396c4a42cb1fff710ff4;hpb=9afd6ec5878544a7982c50ed9c0dd7de37606d5b diff --git a/inc/modules/member/what-holiday.php b/inc/modules/member/what-holiday.php index 973f158538..bfcffff743 100644 --- a/inc/modules/member/what-holiday.php +++ b/inc/modules/member/what-holiday.php @@ -1,7 +1,7 @@ time()) || (($content['timestamp_ordered'] + getConfig('holiday_lock')) > time())) { // Mail order is to close away! - unsetPostRequestElement('ok'); - unsetPostRequestElement('stop'); + unsetPostRequestParameter('ok'); + unsetPostRequestParameter('stop'); if (($content['timestamp'] + getConfig('holiday_lock')) > time()) { // Mail found in pool @@ -99,7 +100,7 @@ if ((SQL_NUMROWS($result1) == 1) || (SQL_NUMROWS($result2) == 1)) { } // Display message and exit here - loadTemplate('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 @@ -110,18 +111,18 @@ SQL_FREERESULT($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') ); + $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())) { // Time test failed - unsetPostRequestElement('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(getMemberId(), $START, $content['holiday_end'], postRequestElement('comments')), __FILE__, __LINE__); + array(getMemberId(), $START, $content['holiday_end'], postRequestParameter('comments')), __FILE__, __LINE__); // Activate holiday system SQL_QUERY_ESC("UPDATE @@ -134,13 +135,13 @@ LIMIT 1", array(getMemberId()), __FILE__, __LINE__); // Prepare constants - $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'] = secureString(postRequestElement('comments')); + $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 = loadEmailTemplate('member_holiday_request', $content, getMemberId()); @@ -153,12 +154,12 @@ LIMIT 1", createNewTask('{--HOLIDAY_ADMIN_SUBJECT--}', $message, 'HOLIDAY_REQUEST', getMemberId()); // Display message - loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_IS_ACTIVATED_NOW')); + loadTemplate('admin_settings_saved', false, '{--HOLIDAY_IS_ACTIVATED_NOW--}'); } } // END - if // Holiday shall be ended now -if (isPostRequestElementSet('stop')) { +if (isPostRequestParameterSet('stop')) { // Okay, end the holiday here... $result = SQL_QUERY_ESC("SELECT `holiday_active`, `holiday_activated` @@ -167,62 +168,74 @@ FROM WHERE `userid`=%s LIMIT 1", array(getMemberId()), __FILE__, __LINE__); - $content = merge_array($content, SQL_FETCHARRAY($result)); - SQL_FREERESULT($result); - if (($content['holiday_active'] == 'Y') && (($content['holiday_activated'] + getConfig('holiday_lock')) < time())) { - // Load data - $result = SQL_QUERY_ESC("SELECT + // Do we have 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())) { + // Load data + $result2 = SQL_QUERY_ESC("SELECT `holiday_start`, `holiday_end` FROM `{?_MYSQL_PREFIX?}_user_holidays` WHERE `userid`=%s LIMIT 1", array(getMemberId()), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) { - // Data was found - $content = merge_array($content, SQL_FETCHARRAY($result)); - SQL_FREERESULT($result); + if (SQL_NUMROWS($result2) == 1) { + // Data was found so merge it + $content = merge_array($content, SQL_FETCHARRAY($result2)); - // Prepare it for the template - $content['start'] = generateDateTime($content['holiday_start'], 3); - $content['end'] = generateDateTime($content['holiday_end'] , 3); + // 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` + // Deactivate it now + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `holiday_active`='N', `holiday_activated`=0 WHERE `userid`=%s LIMIT 1", - array(getMemberId()), __FILE__, __LINE__); + array(getMemberId()), __FILE__, __LINE__); - // Remove entry - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM + // Remove entry + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_holidays` WHERE `userid`=%s LIMIT 1", - array(getMemberId()), __FILE__, __LINE__); - - // Send email to admin - sendAdminNotification(getMessage('HOLIDAY_ADMIN_DEAC_SUBJ'), 'admin_holiday_deactivated', $content, getMemberId()); - - // Display message to user - loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_DEACTIVATED_NOW')); - } else { - // Display message to user - loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_CANNOT_DEACTIVATE')); + array(getMemberId()), __FILE__, __LINE__); + + // Send email to admin + sendAdminNotification(getMessage('HOLIDAY_ADMIN_DEAC_SUBJ'), 'admin_holiday_deactivated', $content, getMemberId()); + + // Display message to user + loadTemplate('admin_settings_saved', false, '{--HOLIDAY_MEMBER_DEACTIVATED_NOW--}'); + } else { + // Display message to user + loadTemplate('admin_settings_saved', false, '{--HOLIDAY_MEMBER_CANNOT_DEACTIVATE--}'); + } + + // Free result + SQL_FREERESULT($result2); + } elseif ($content['holiday_active'] == 'Y') { + // To fast! + loadTemplate('admin_settings_saved', false, '{--HOLIDAY_MEMBER_LOCKED--}'); } - } elseif ($content['holiday_active'] == 'Y') { - // To fast! - loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_LOCKED')); + } else { + // User not found + loadTemplate('admin_settings_saved', false, getMaskedMessage('HOLIDAY_MEMBER_NOT_STOPPED_404', getMemberId())); } + + // Free result + SQL_FREERESULT($result); } // END - if // If something is wrong or link in menu is just clicked display form -if ((!isFormSent()) && (!isPostRequestElementSet('stop'))) { +if ((!isFormSent()) && (!isPostRequestParameterSet('stop'))) { // Check if user is in holiday... $result = SQL_QUERY_ESC("SELECT `holiday_active`, `holiday_activated` @@ -249,9 +262,8 @@ WHERE `userid`=%s LIMIT 1", array(getMemberId()), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { - // Data was found + // Data was found so merge it $content = merge_array($content, SQL_FETCHARRAY($result)); - SQL_FREERESULT($result); // Prepare it for the template $content['start'] = generateDateTime($content['holiday_start'] , 3); @@ -275,6 +287,9 @@ LIMIT 1", array(getMemberId()), __FILE__, __LINE__); redirectToUrl('modules.php?module=login&what=holiday'); return; } + + // Free result + SQL_FREERESULT($result); break; case 'N': // Display activation form @@ -299,7 +314,7 @@ LIMIT 1", array(getMemberId()), __FILE__, __LINE__); } } else { // To fast! - loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_MEMBER_LOCKED')); + loadTemplate('admin_settings_saved', false, '{--HOLIDAY_MEMBER_LOCKED--}'); } } // END - if