X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-del_holiday.php;h=0b567578343cf9e2a99cf5d9cca64bb28d77008f;hp=8fa89f5218ad4fcadf5d0c97517d6f06b867d641;hb=155492a5b96cec674846973a8524238b0365a848;hpb=d8148e3f1f3a6762b2e786dbe99ada269dcf2ea0 diff --git a/inc/modules/admin/what-del_holiday.php b/inc/modules/admin/what-del_holiday.php index 8fa89f5218..0b56757834 100644 --- a/inc/modules/admin/what-del_holiday.php +++ b/inc/modules/admin/what-del_holiday.php @@ -1,7 +1,7 @@ 0) -{ +if (ifPostContainsSelections()) { // Delete multiple holiday requests (for list_holiday) - $cnt = 0; - foreach (REQUEST_POST('sel') as $id => $sel) - { + $count = '0'; + foreach (postRequestElement('sel') as $id => $sel) { // Get the userid - $result = SQL_QUERY_ESC("SELECT userid, holiday_start, holiday_end -FROM `{!_MYSQL_PREFIX!}_user_holidays` -WHERE id=%s LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + $result = sqlQueryEscaped("SELECT + `userid`, + `holiday_start`, + `holiday_end` +FROM + `{?_MYSQL_PREFIX?}_user_holidays` +WHERE + `id`=%s +LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); + if (sqlNumRows($result) == 1) { // Load data and free memory - list($uid, $start, $end) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + $content = sqlFetchArray($result); // Update user's account - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` -SET holiday_active='N', holiday_activated='0' -WHERE userid=%s LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__); + sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` +SET + `holiday_active`='N', + `holiday_activated`=0 +WHERE + `userid`=%s +LIMIT 1", array(bigintval($content['userid'])), __FILE__, __LINE__); // Remove holiday - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_holidays` -WHERE id=%s LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); + sqlQueryEscaped("DELETE LOW_PRIORITY FROM + `{?_MYSQL_PREFIX?}_user_holidays` +WHERE + `id`=%s +LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); // Prepare loaded data for the - $content = array( - 'start' => MAKE_DATETIME($start, "3"), - 'end' => MAKE_DATETIME($end , "3") - ); + $content['holiday_start'] = generateDateTime($content['holiday_start'], '3'); + $content['holiday_end'] = generateDateTime($content['holiday_end'] , '3'); // Send email to user - $msg = LOAD_EMAIL_TEMPLATE("member_holiday_removed", $content, $uid); - SEND_EMAIL($uid, HOLIDAY_ADMIN_REMOVED_SUBJ, $msg); - $cnt++; - } - } - LOAD_TEMPLATE("admin_settings_saved", false, HOLIDAY_ADMIN_MULTI_DEL_1.$cnt.HOLIDAY_ADMIN_MULTI_DEL_2); -} - elseif (REQUEST_ISSET_GET(('uid'))) -{ + $message = loadEmailTemplate('member_holiday_removed', $content, $content['userid']); + sendEmail($content['userid'], '{--ADMIN_HOLIDAY_REMOVED_SUBJECT--}', $message); + $count++; + } // END - if + + // Free result + sqlFreeResult($result); + } // END - foreach + + // Display final message + displayMessage('{%message,ADMIN_HOLIDAY_MULTI_DELETE=' . $count . '%}'); +} elseif (isGetRequestElementSet('userid')) { // Set default message - $MSG = HOLIDAY_ADMIN_SINGLE_404; + $message = '{--ADMIN_HOLIDAY_SINGLE_404--}'; // Fetch data - $result_load = SQL_QUERY_ESC("SELECT holiday_start AS start, holiday_end AS end -FROM `{!_MYSQL_PREFIX!}_user_holidays` -WHERE userid=%s LIMIT 1", array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); - if (SQL_NUMROWS($result_load) == 1) - { + $result_load = sqlQueryEscaped("SELECT + `holiday_start` AS `start`, + `holiday_end` AS `end` +FROM + `{?_MYSQL_PREFIX?}_user_holidays` +WHERE + `userid`=%s +LIMIT 1", + array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__); + if (sqlNumRows($result_load) == 1) { // Load data - $content = SQL_FETCHARRAY($result_load); - - // Free some memory - unset($content[0]); - unset($content[1]); + $content = sqlFetchArray($result_load); // Delete one holiday request (for task) - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_holidays` -WHERE userid=%s LIMIT 1", array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); + sqlQueryEscaped("DELETE LOW_PRIORITY FROM + `{?_MYSQL_PREFIX?}_user_holidays` +WHERE + `userid`=%s +LIMIT 1", array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__); // Send email to user - $msg = LOAD_EMAIL_TEMPLATE("member_holiday_removed", $content, REQUEST_GET('uid')); - SEND_EMAIL(REQUEST_GET('uid'), HOLIDAY_ADMIN_REMOVED_SUBJ, $msg); + $message = loadEmailTemplate('member_holiday_removed', $content, getRequestElement('userid')); + sendEmail(getRequestElement('userid'), '{--ADMIN_HOLIDAY_REMOVED_SUBJECT--}', $message); // Set message - $MSG = HOLIDAY_ADMIN_SINGLE_DELETED; - } + $message = '{--ADMIN_HOLIDAY_SINGLE_DELETED--}'; + } // END - if // Free memory - SQL_FREERESULT($result_load); + sqlFreeResult($result_load); // Output message - LOAD_TEMPLATE("admin_settings_saved", false, $MSG); + displayMessage($message); +} else { + // Add member selection box + addMemberSelectionBox(); } - else -{ - // Please call me over other scripts... ;) - LOAD_TEMPLATE("admin_settings_saved", false, HOLIDAY_NO_DIRECT_CALL); -} -// + +// [EOF] ?>