- $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 .= " <OPTION value=\"".$value."\">".$CATS['name'][$key]." (".$CATS['uids'][$key]." ".USER_IN_CAT.")</OPTION>\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'] = getRequestElement('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(getRequestElement('mode')) {
+ case 'html': // HTML mails
+ case 'normal': // Normal mails
+ $template = 'admin_send_bonus_form';