X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-edit_sponsor.php;h=455d3c7fa6d727b5283671bfe514e70a0e6404ce;hb=b748f2cc85e5f019b76ea0fbbeb03a35b8fc304b;hp=6b3dedbdbed280a457ad0b534d87faa0b51b09ea;hpb=4111c233803817fc7c28d56cf3914f6478fa5c82;p=mailer.git
diff --git a/inc/modules/admin/what-edit_sponsor.php b/inc/modules/admin/what-edit_sponsor.php
index 6b3dedbdbe..455d3c7fa6 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(REVERT_COMMA($_POST['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($_GET['id'])), __FILE__, __LINE__);
-
- // Remember points /reason for the template
- define('__POINTS' , TRANSLATE_COMMA($POINTS));
- define('__REASON' , $_POST['reason']);
-
- // Send email
- $msg = LOAD_EMAIL_TEMPLATE("sponsor_add_points", $_POST['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($_POST['points']) > 0) {
- // Replace german decimal comma with computer's decimal dot
- $POINTS = strval(REVERT_COMMA($_POST['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($_GET['id'])), __FILE__, __LINE__);
-
- // Remember points /reason for the template
- define('__POINTS' , TRANSLATE_COMMA($POINTS));
- define('__REASON' , $_POST['reason']);
-
- // Send email
- $msg = LOAD_EMAIL_TEMPLATE("sponsor_sub_points", $_POST['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 (($_POST['pass1'] != $_POST['pass2']) || ((empty($_POST['pass1'])) && (empty($_POST['pass1'])))) {
- // Remove passwords
- unset($_POST['pass1']);
- unset($_POST['pass2']);
- $PASS = false;
- }
-
- // Convert time selection
- $DATA = array(); $id = "warning_interval_ye"; $skip = false;
- CONVERT_SELECTIONS_TO_TIMESTAMP($_POST, $DATA, $id, $skip);
-
- // Save the sponsor
- SPONSOR_HANDLE_SPONSOR($_POST);
-
- // Convert some data for the email template
- $_POST['gender'] = TRANSLATE_GENDER($_POST['gender']);
- $_POST['warning_interval'] = CREATE_FANCY_TIME($_POST['warning_interval']);
- if (!$PASS) $_POST['pass1'] = SPONSOR_PASS_UNCHANGED;
-
- // Load email template and send the mail away
- $msg = LOAD_EMAIL_TEMPLATE("admin_sponsor_edit", $_POST, false);
- SEND_EMAIL($_POST['email'], SPONSOR_ADMIN_EDIT_SUBJECT, $msg);
- break;
-
- default: // Unknown mode
- DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown mode %s detected.", $_GET['mode']));
- $MSG = ADMIN_INVALID_MODE_1.SQL_ESCAPE($_GET['mode']).ADMIN_INVALID_MODE_2;
- break;
- }
-
- if (!empty($MSG)) {
+ switch (getRequestElement('do')) {
+ case 'add_points': // Add points
+ if (bigintval(postRequestElement('points')) > 0) {
+ // Replace german decimal comma with computer's decimal dot
+ $points = bigintval(convertCommaToDot(postRequestElement('points')));
+
+ // Add points to account
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `points_amount`=`points_amount`+%s WHERE `id`=%s LIMIT 1",
+ array(
+ $points,
+ bigintval(getRequestElement('id'))
+ ), __FILE__, __LINE__
+ );
+
+ // Remember points /reason for the template
+ $content['points'] = $points;
+ $content['reason'] = postRequestElement('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(postRequestElement('points')) > 0) {
+ // Replace german decimal comma with computer's decimal dot
+ $points = bigintval(convertCommaToDot(postRequestElement('points')));
+
+ // Add points to account
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `points_used`=`points_used`+%s WHERE `id`=%s LIMIT 1",
+ array($points, bigintval(getRequestElement('id'))), __FILE__, __LINE__);
+
+ // Remember points /reason for the template
+ $content['points'] = $points;
+ $content['reason'] = postRequestElement('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 ((postRequestElement('password1') != postRequestElement('password2')) || ((!isPostRequestElementSet('password1')) && (!isPostRequestElementSet('password1')))) {
+ // Remove passwords
+ unsetPostRequestElement('password1');
+ unsetPostRequestElement('password2');
+ $PASS = FALSE;
+ } // END - if
+
+ // Convert time selection
+ convertSelectionsToEpocheTimeInPostData('warning_interval_ye');
+
+ // Save the sponsor
+ handleSponsorRequest(postRequestArray());
+
+ // Convert some data for the email template
+ postRequestElement('sex' , '{%pipe,translateSex=' . postRequestElement('sex') . '%}');
+ postRequestElement('warning_interval', '{%pipe,createFancyTime=' . postRequestElement('warning_interval') . '%}');
+
+ if ($PASS === FALSE) setPostRequestElement('password1', '{--SPONSOR_PASS_UNCHANGED--}');
+
+ // Load email template and send the mail away
+ $message = loadEmailTemplate('admin_sponsor_edit', postRequestArray(), FALSE);
+ sendEmail(postRequestElement('email'), '{--ADMIN_SPONSOR_EDIT_SUBJECT--}', $message);
+ break;
+
+ default: // Unknown mode
+ logDebugMessage(__FILE__, __LINE__, sprintf('Unknown mode %s detected.', getRequestElement('do')));
+ $message = '{%message,ADMIN_SPONSOR_INVALID_MODE=' . getRequestElement('do') . '%}';
+ break;
+ } // END - switch
+
+ if (!empty($message)) {
// Output message
- LOAD_TEMPLATE("admin_settings_saved", false, $MSG);
+ displayMessage($message);
} // END - if
- } elseif (FILE_READABLE(sprintf("%stemplates/%s/html/admin/%s.tpl", PATH, GET_LANGUAGE(), $TPL))) {
+ } elseif (isFileReadable(sprintf('%s/admin/%s.tpl', getTemplateBasePath('html'), $TPL))) {
// Create mailto link
- define('__SPONSOR_VALUE', "".__SURNAME." ".__FAMILY."");
+ $content['contact'] = '' . $content['surname'] . ' ' . $content['family'] . '';
// Load mode template
- LOAD_TEMPLATE($TPL);
+ loadTemplate($TPL, FALSE, $content);
} else {
- // Template not found!
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_TPL_404_1.SQL_ESCAPE($_GET['mode']).ADMIN_TPL_404_2);
+ // Template not found
+ displayMessage('{%message,ADMIN_SPONSOR_MODUS_TPL_404', getRequestElement('do') . '%}');
}
} else {
- // Sponsor not found!
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_SPONSOR_404_1.bigintval($_GET['id']).ADMIN_SPONSOR_404_2);
+ // Sponsor not found
+ displayMessage('{%message,ADMIN_SPONSOR_404=' . bigintval(getRequestElement('id')) . '%}');
}
+
+ // Free result
+ sqlFreeResult($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]
?>