X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-send_bonus.php;h=0d4a1f6058e16173ed5cbeceaf7e5fc117946aef;hb=2142149f3f72f1a2476f95a87937c044d63bbaf2;hp=0cf3502a62b027d02198e6fc2fec687a4b689b55;hpb=b73c135350d7ed266c0cac680105707139bd892d;p=mailer.git
diff --git a/inc/modules/admin/what-send_bonus.php b/inc/modules/admin/what-send_bonus.php
index 0cf3502a62..0d4a1f6058 100644
--- a/inc/modules/admin/what-send_bonus.php
+++ b/inc/modules/admin/what-send_bonus.php
@@ -41,185 +41,34 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
}
// Add description as navigation point
-ADD_DESCR("admin", basename(__FILE__));
+ADD_DESCR("admin", __FILE__);
-$whereStatement = " WHERE visible='Y'";
-if (is_admin()) $whereStatement = "";
-$EXT_HTML = EXT_IS_ACTIVE("html_mail");
+// Set empty mode to "select"
if (empty($_GET['mode'])) $_GET['mode'] = "select";
-if (isset($_POST['ok']))
-{
- // Check if category and number of receivers is okay
- $CAT_TABS = "%s"; $CAT_WHERE = ""; $cat = "";
- if ($_POST['cat'] > 0)
- {
- // Select category
- $CAT_TABS = "LEFT JOIN "._MYSQL_PREFIX."_user_cats AS c ON d.userid=c.userid";
- $cat = bigintval($_POST['cat']);
- $CAT_WHERE = " AND c.cat_id=%s";
- }
- if (GET_EXT_VERSION("holiday") >= "0.1.3")
- {
- // Add something for the holiday extension
- $CAT_WHERE .= " AND d.holiday_active='N'";
- }
-
- if (($EXT_HTML) && ($_GET['mode'] == "html"))
- {
- // Only include HTML receivers
- $result = SQL_QUERY_ESC("SELECT d.userid FROM "._MYSQL_PREFIX."_user_data AS d ".$CAT_TABS." WHERE d.status='CONFIRMED' AND d.html='Y'".$CAT_WHERE." ORDER BY d.%s %s LIMIT %s",
- array($cat, $_CONFIG['order_select'], $_CONFIG['order_mode'], bigintval($_POST['receiver'])), __FILE__, __LINE__);
- }
- else
- {
- // Include all
- $result = SQL_QUERY_ESC("SELECT d.userid FROM "._MYSQL_PREFIX."_user_data AS d ".$CAT_TABS." WHERE d.status='CONFIRMED'".$CAT_WHERE." ORDER BY d.%s %s LIMIT %s",
- array($cat, $_CONFIG['order_select'], $_CONFIG['order_mode'], bigintval($_POST['receiver'])), __FILE__, __LINE__);
- }
- if ((SQL_NUMROWS($result) == $_POST['receiver']) && ($_POST['receiver'] > 0))
- {
- $RECEIVER = "";
- while (list($REC) = SQL_FETCHROW($result))
- {
- // Add receiver when not empty
- if (!empty($REC)) $RECEIVER .= ";".$REC;
- }
-
- // Free memory
- SQL_FREERESULT($result);
- $RECEIVER = substr($RECEIVER, 1);
-
- // Gettings points is oka, so we can add $USED later from
- if ($EXT_HTML)
- {
- $HTML = "N";
- if ($_GET['mode'] == "html") $HTML = "Y";
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_bonus
-(subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent, html_msg)
-VALUES ('%s', '%s', '%s', '%s', '%s', 'NEW', UNIX_TIMESTAMP(), '%s', '%s', '%s', '%s', '%s')",
- array(
- $_POST['subject'],
- addslashes($_POST['text']),
- $RECEIVER,
- $_POST['points'],
- $_POST['seconds'],
- $_POST['url'],
- $cat,
- SELECTION_COUNT(explode(";", $RECEIVER)),
- bigintval($_POST['receiver']),
- $HTML
-), __FILE__, __LINE__);
- }
- else
- {
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_bonus
-(subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent)
-VALUES ('%s', '%s', '%s', '%s', '%s', 'NEW', UNIX_TIMESTAMP(), '%s', '%s', '%s', '%s')",
- array(
- $_POST['subject'],
- addslashes($_POST['text']),
- $RECEIVER,
- $_POST['points'],
- $_POST['seconds'],
- $_POST['url'],
- $cat,
- SELECTION_COUNT(explode(";", $RECEIVER)),
- bigintval($_POST['receiver']),
-), __FILE__, __LINE__);
- }
-
- // Mail inserted into bonus pool
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_SEND);
- }
- else
- {
- // More entered than can be reached!
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_MORE_SELECTED);
- }
- if (!empty($URL))
- {
- // Redirect to requested URL
- LOAD_URL($URL);
- }
+if (isset($_POST['ok'])) {
+ // Deliver bonus mail
+ ADD_NEW_BONUS_MAIL($_POST, $_GET['mode']);
} else {
- $result = SQL_QUERY("SELECT id, cat FROM "._MYSQL_PREFIX."_cats".$whereStatement." ORDER BY sort", __FILE__, __LINE__);
- if (SQL_NUMROWS($result) > 0)
- {
- $MORE = "";
- if ($_GET['mode'] == "html") $MORE = " AND html='Y'";
- if (GET_EXT_VERSION("holiday") >= "0.1.3")
- {
- // Add something for the holiday extension
- $MORE .= " AND holiday_active='N'";
- }
-
- $result_all = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' AND receive_mails > 0".$MORE, __FILE__, __LINE__);
- define('__ALL_VALUE', SQL_NUMROWS($result_all));
- // Initialize array...
- $CATS = array(
- 'id' => array(),
- 'name' => array(),
- 'uids' => array()
- );
- // ... and begin loading stuff
- while (list($id, $cat) = SQL_FETCHROW($result))
- {
- $CATS['id'][] = $id;
- $CATS['name'][] = $cat;
- $result_uids = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_cats WHERE cat_id=%s",
- array(bigintval($id)), __FILE__, __LINE__);
- $uid_cnt = 0;
- while (list($ucat) = SQL_FETCHROW($result_uids))
- {
- $result_ver = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data
-WHERE userid=%s AND status='CONFIRMED' AND receive_mails > 0".$MORE." LIMIT 1",
- array(bigintval($ucat)), __FILE__, __LINE__);
- $uid_cnt += SQL_NUMROWS($result_ver);
-
- // Free memory
- SQL_FREERESULT($result_ver);
- }
-
- // Free memory
- SQL_FREERESULT($result_uids);
- $CATS['uids'][] = $uid_cnt;
- }
-
- // Free memory
- SQL_FREERESULT($result);
+ // Get all available users
+ define('__ALL_VALUE', TRANSLATE_COMMA(GET_TOTAL_RECEIVERS($_GET['mode'])));
- if (!empty($MSG))
- {
- // We got system message so we drop it out to the user
- LOAD_TEMPLATE("admin_settings_saved", false, $MSG);
- }
- if ($EXT_HTML)
- {
- // If HTML extension is active
- define('__HTML_SELECT', LOAD_TEMPLATE("admin_send_bonus_html", true));
- }
- else
- {
- // And if not
- define('__HTML_SELECT', "");
- }
+ // Prepare option lines
+ define('__OPTION_LINES', ADD_CATEGORY_OPTIONS($_GET['mode']));
- // Generate options
- $OUT = "";
- foreach ($CATS['id'] as $key => $value)
- {
- if (strlen($CATS['name'][$key]) > 20) $CATS['name'][$key] = substr($CATS['name'][$key], 0, 17)."...";
- $OUT .= " \n";
- }
- define('__OPTION_LINES', $OUT);
+ // Store send mode
+ define('__MODE', SQL_ESCAPE($_GET['mode']));
- // Store send mode
- define('__MODE', $_GET['mode']);
+ if (EXT_IS_ACTIVE("html_mail")) {
+ // If HTML extension is active
+ define('__HTML_SELECT', LOAD_TEMPLATE("admin_send_bonus_html", true));
+ } else {
+ // And if not
+ define('__HTML_SELECT', "");
+ }
- // Select template
- switch($_GET['mode'])
- {
+ // Select template
+ switch($_GET['mode']) {
case "html": // HTML mails
case "normal": // Normal mails
$template = "admin_send_bonus_form";
@@ -228,16 +77,10 @@ WHERE userid=%s AND status='CONFIRMED' AND receive_mails > 0".$MORE." LIMIT 1",
case "select": // Selection
$template = "admin_send_bonus_select";
break;
- }
-
- // Load template
- LOAD_TEMPLATE($template);
- }
- else
- {
- // No cateogries are defined yet
- OUTPUT_HTML("".MEMBER_NO_CATS."");
}
+
+ // Load template
+ LOAD_TEMPLATE($template);
}
//