X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-edit_sponsor.php;h=d0699a3f321f23de776937a5a7eb58e56de6c30b;hb=97702d59eb179b54690f9ccc18df66cd981ab0df;hp=005abac287b3bd772d6a1d1fbce952b3af5937a6;hpb=9beb33ae0c3194b05d172508768a833b1b69af2f;p=mailer.git diff --git a/inc/modules/admin/what-edit_sponsor.php b/inc/modules/admin/what-edit_sponsor.php index 005abac287..d0699a3f32 100644 --- a/inc/modules/admin/what-edit_sponsor.php +++ b/inc/modules/admin/what-edit_sponsor.php @@ -1,7 +1,7 @@ 0) - { - // Replace german decimal comma with computer's decimal dot - $POINTS = strval(str_replace(",", ".", $HTTP_POST_VARS['points'])); - - // Add points to account - $result_add = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_sponsor_data SET points_amount=points_amount+%s WHERE id='%s' LIMIT 1", - array($POINTS, bigintval($HTTP_GET_VARS['id'])), __FILE__, __LINE__); - - // Remember points /reason for the template - define('__POINTS' , TRANSLATE_COMMA($POINTS)); - define('__REASON' , $HTTP_POST_VARS['reason']); - - // Send email - $msg = LOAD_EMAIL_TEMPLATE("sponsor_add_points", $HTTP_POST_VARS['reason'], true); - SEND_EMAIL(__EMAIL, SPONSOR_ADMIN_ADD_POINTS, $msg); - $MSG = ADMIN_SPONSOR_POINTS_ADDED; - } - else - { - // No points entered to add! - $MSG = ADMIN_SPONSPOR_NO_POINTS_TO_ADD; - } - break; - - case "sub_points": // Subtract points - if (strval($HTTP_POST_VARS['points']) > 0) - { - // Replace german decimal comma with computer's decimal dot - $POINTS = strval(str_replace(",", ".", $HTTP_POST_VARS['points'])); - - // Add points to account - $result_add = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_sponsor_data SET points_used=points_used+%s WHERE id='%s' LIMIT 1", - array($POINTS, bigintval($HTTP_GET_VARS['id'])), __FILE__, __LINE__); - - // Remember points /reason for the template - define('__POINTS' , TRANSLATE_COMMA($POINTS)); - define('__REASON' , $HTTP_POST_VARS['reason']); - - // Send email - $msg = LOAD_EMAIL_TEMPLATE("sponsor_sub_points", $HTTP_POST_VARS['reason'], true); - SEND_EMAIL(__EMAIL, SPONSOR_ADMIN_SUB_POINTS, $msg); - $MSG = ADMIN_SPONSOR_POINTS_SUBTRACTED; - } - else - { - // No points entered to add! - $MSG = ADMIN_SPONSPOR_NO_POINTS_TO_SUBTRACT; - } - break; - - case "edit": // Edit sponsor account - $PASS = true; - if (($HTTP_POST_VARS['pass1'] != $HTTP_POST_VARS['pass2']) || ((empty($HTTP_POST_VARS['pass1'])) && (empty($HTTP_POST_VARS['pass1'])))) - { - // Remove passwords - unset($HTTP_POST_VARS['pass1']); - unset($HTTP_POST_VARS['pass2']); - $PASS = false; - } - SPONSOR_HANDLE_SPONSOR($HTTP_POST_VARS); - - // Convert some data for the email template - $HTTP_POST_VARS['salut'] = TRANSLATE_SEX($HTTP_POST_VARS['salut']); - $HTTP_POST_VARS['warning_interval'] = CREATE_FANCY_TIME($HTTP_POST_VARS['warning_interval']); - if (!$PASS) $HTTP_POST_VARS['pass1'] = SPONSOR_PASS_UNCHANGED; - - // Load email template and send the mail away - $msg = LOAD_EMAIL_TEMPLATE("admin_sponsor_edit", $HTTP_POST_VARS, false); - SEND_EMAIL($HTTP_POST_VARS['email'], SPONSOR_ADMIN_EDIT_SUBJECT, $msg); - break; - - default: // Unknown mode - $MSG = ADMIN_INVALID_MODE_1.$HTTP_GET_VARS['mode'].ADMIN_INVALID_MODE_2; - break; + switch (getRequestParameter('mode')) { + case 'add_points': // Add points + if (bigintval(postRequestParameter('points')) > 0) { + // Replace german decimal comma with computer's decimal dot + $points = bigintval(convertCommaToDot(postRequestParameter('points'))); + + // Add points to account + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `points_amount`=`points_amount`+%s WHERE `id`=%s LIMIT 1", + array($points, bigintval(getRequestParameter('id'))), __FILE__, __LINE__); + + // Remember points /reason for the template + $content['points'] = $points; + $content['reason'] = postRequestParameter('reason'); + + // Send email + $message = loadEmailTemplate('sponsor_add_points', $content); + sendEmail($content['email'], '{--ADMIN_SPONSOR_ADD_POINTS_SUBJECT--}', $message); + $message = '{--ADMIN_SPONSOR_POINTS_ADDED--}'; + } else { + // No points entered to add! + $message = '{--ADMIN_SPONSOR_NO_POINTS_TO_ADD--}'; + } + break; + + case 'sub_points': // Subtract points + if (bigintval(postRequestParameter('points')) > 0) { + // Replace german decimal comma with computer's decimal dot + $points = bigintval(convertCommaToDot(postRequestParameter('points'))); + + // Add points to account + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `points_used`=`points_used`+%s WHERE `id`=%s LIMIT 1", + array($points, bigintval(getRequestParameter('id'))), __FILE__, __LINE__); + + // Remember points /reason for the template + $content['points'] = $points; + $content['reason'] = postRequestParameter('reason'); + + // Send email + $message = loadEmailTemplate('sponsor_sub_points', $content); + sendEmail($content['email'], '{--ADMIN_SPONSOR_SUB_POINTS_SUBJECT--}', $message); + $message = '{--ADMIN_SPONSOR_POINTS_SUBTRACTED--}'; + } else { + // No points entered to add! + $message = '{--ADMIN_SPONSOR_NO_POINTS_TO_SUBTRACT--}'; + } + break; + + case 'edit': // Edit sponsor account + $PASS = true; + if ((postRequestParameter('pass1') != postRequestParameter('pass2')) || ((!isPostRequestParameterSet('pass1')) && (!isPostRequestParameterSet('pass1')))) { + // Remove passwords + unsetPostRequestParameter('pass1'); + unsetPostRequestParameter('pass2'); + $PASS = false; + } // END - if + + // Convert time selection + $content = array(); $id = 'warning_interval_ye'; $skip = false; + convertSelectionsToEpocheTime(postRequestArray(), $content, $id, $skip); + + // Save the sponsor + handleSponsorRequest(postRequestArray()); + + // Convert some data for the email template + postRequestParameter('gender' , '{%pipe,translateGender=' . postRequestParameter('gender') . '%}'); + postRequestParameter('warning_interval', '{%pipe,createFancyTime=' . postRequestParameter('warning_interval') . '%}'); + + if ($PASS === false) setPostRequestParameter('pass1', '{--SPONSOR_PASS_UNCHANGED--}'); + + // Load email template and send the mail away + $message = loadEmailTemplate('admin_sponsor_edit', postRequestArray(), false); + sendEmail(postRequestParameter('email'), '{--ADMIN_SPONSOR_EDIT_SUBJECT--}', $message); + break; + + default: // Unknown mode + logDebugMessage(__FILE__, __LINE__, sprintf("Unknown mode %s detected.", getRequestParameter('mode'))); + $message = '{%message,ADMIN_SPONSOR_INVALID_MODE=' . getRequestParameter('mode') . '%}'; + break; } - if (!empty($MSG)) - { + if (!empty($message)) { // Output message - LOAD_TEMPLATE("admin_settings_saved", false, $MSG); - } - } - elseif (file_exists(PATH."templates/".GET_LANGUAGE()."/html/admin/".$TPL.".tpl")) - { + displayMessage($message); + } // END - if + } elseif (isFileReadable(sprintf("%stemplates/%s/html/admin/%s.tpl", getPath(), getLanguage(), $TPL))) { // Create mailto link - define('__SPONSOR_VALUE', "".__SURNAME." ".__FAMILY.""); + $content['contact'] = '' . $content['surname'] . ' ' . $content['family'] . ''; // Load mode template - LOAD_TEMPLATE($TPL); - } - else - { - // Template not found! - LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_TPL_404_1.$HTTP_GET_VARS['mode'].ADMIN_TPL_404_2); + loadTemplate($TPL, false, $content); + } else { + // Template not found + displayMessage('{%message,ADMIN_SPONSOR_MODUS_TPL_404', getRequestParameter('mode') . '%}'); } + } else { + // Sponsor not found + displayMessage('{%message,ADMIN_SPONSOR_404=' . bigintval(getRequestParameter('id')) . '%}'); } - else - { - // Sponsor not found! - LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_SPONSOR_404_1.$HTTP_GET_VARS['id'].ADMIN_SPONSOR_404_2); - } -} - else -{ + + // Free result + SQL_FREERESULT($result_main); +} else { // Not called by what-list_sponsor.php - LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_CALL_NOT_DIRECTLY); + displayMessage('{--ADMIN_CALL_NOT_DIRECTLY--}'); } -// +// [EOF] ?>