X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-send_bonus.php;h=2f083fdf1055d1d93fa7e1b8a62092b979062aa6;hb=cc59ea1cce3e0fafc2cc6c9e36142698cf2b58ef;hp=fccbb061a5ca54451862af2a113e6cd5b4525947;hpb=d0ab0382dd73638f0bc13a1a3d6f117ec11a203e;p=mailer.git
diff --git a/inc/modules/admin/what-send_bonus.php b/inc/modules/admin/what-send_bonus.php
index fccbb061a5..2f083fdf10 100644
--- a/inc/modules/admin/what-send_bonus.php
+++ b/inc/modules/admin/what-send_bonus.php
@@ -1,7 +1,7 @@
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=%d";
- }
- 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);
+if (!isExtensionActive('order')) {
+ displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=order%}');
+ return;
+} // END - if
- // 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__);
- }
+// 'mode' is not set by default
+if (!isGetRequestParameterSet('mode')) {
+ // Set empty mode to "select"
+ setGetRequestParameter('mode', 'select');
+} // END - if
- // 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 (isFormSent()) {
+ // Deliver bonus mail
+ addNewBonusMail(postRequestArray(), getRequestParameter('mode'));
} else {
- $result = SQL_QUERY("SELECT id, cat FROM "._MYSQL_PREFIX."_cats".$WHERE." 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=%d",
- 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=%d 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);
-
- 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', "");
- }
-
- // 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', $_GET['mode']);
-
- // Select template
- switch($_GET['mode'])
- {
- case "html": // HTML mails
- case "normal": // Normal mails
- $template = "admin_send_bonus_form";
+ // Store send mode
+ $content['mode'] = getRequestParameter('mode');
+
+ $content['html_select'] = '';
+ if (isExtensionActive('html_mail')) {
+ // If HTML extension is active
+ $content['html_select'] = loadTemplate('admin_send_bonus_html', true);
+ } // END - if
+
+ // Select template
+ switch(getRequestParameter('mode')) {
+ case 'html': // HTML mails
+ case 'normal': // Normal mails
+ $template = 'admin_send_bonus_form';
break;
- case "select": // Selection
- $template = "admin_send_bonus_select";
+ case 'select': // Selection
+ $template = 'admin_send_bonus_select';
break;
- }
+ } // END - switch
- // Load template
- LOAD_TEMPLATE($template);
- }
- else
- {
- // No cateogries are defined yet
- OUTPUT_HTML ("".MEMBER_NO_CATS."");
- }
+ // Load template
+ loadTemplate($template, false, $content);
}
-//
+// [EOF]
?>