X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-send_bonus.php;h=6cc0db906eada15d923d2cc1f4349b4bfe04baae;hp=0cf3502a62b027d02198e6fc2fec687a4b689b55;hb=57227d33e870ec5cd271209c4a978a52b45c2dd6;hpb=963e55ca1ea79e255f235e359cde9f7862191dc5 diff --git a/inc/modules/admin/what-send_bonus.php b/inc/modules/admin/what-send_bonus.php index 0cf3502a62..6cc0db906e 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=%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); +if (!isExtensionActive('order')) { + loadTemplate('admin_settings_saved', false, 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__); - } +// Set empty mode to "select" +if (!isGetRequestParameterSet('mode')) setGetRequestParameter('mode', "select"); - // 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".$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); - - 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"; + // Get all available users + $content['all'] = translateComma(getTotalReceivers(getRequestParameter('mode'))); + + // Prepare option lines + $content['options_lines'] = generateCategoryOptionsList(getRequestParameter('mode')); + + // 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 - if - // Load template - LOAD_TEMPLATE($template); - } - else - { - // No cateogries are defined yet - OUTPUT_HTML("".MEMBER_NO_CATS.""); - } + // Load template + loadTemplate($template, false, $content); } -// +// [EOF] ?>