2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/19/2003 *
4 * =================== Last change: 07/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-unconfirmed.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Unconfirmed mails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Unbestätigte Mails *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
43 } elseif (!isMember()) {
44 redirectToIndexMemberOnlyModule();
47 // Add description as navigation point
48 addMenuDescription('member', __FILE__);
50 // Shall we display a mail?
51 if ((isGetRequestParameterSet('bonusid')) && (isExtensionActive('bonus'))) {
52 // Display bonus mail by loading it's full data
53 $result_data = SQL_QUERY_ESC("SELECT
54 `id`, `subject`, `timestamp`, `cat_id`, `points`, `text`, `is_notify`, `data_type`, `time`, `url`
56 `{?_MYSQL_PREFIX?}_bonus`
60 array(bigintval(getRequestParameter('bonusid'))), __FILE__, __LINE__);
63 $content = SQL_FETCHARRAY($result_data);
65 // Translate some data
66 $content['timestamp'] = generateDateTime($content['timestamp'], 2);
67 $content['category'] = getCategory($content['cat_id']);
68 $content['points'] = translateComma($content['points']);
69 $content['is_notify'] = translateYesNo($content['is_notify']);
70 $content['sender'] = getMessage('USERNAME_ADMIN_SHORT');
71 $content['time'] = createFancyTime($content['time']);
72 $content['userid'] = getMemberId();
73 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_BONUS_CONFIRMED_UNKNOWN', $content['id']);
75 // Is ext-user installed?
76 if (isExtensionInstalled('user')) {
77 // Get timestamp from insert
78 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_BONUS_CONFIRMED_ON',
79 generateDateTime(getTimestampFromUserStats('bonusid', $content['id']), 2)
83 // Display it depending on mail (data) type
84 loadTemplate('member_mail_bonus_'.strtolower($content['data_type']), false, $content);
87 SQL_FREERESULT($result_data);
88 } elseif (isGetRequestParameterSet(('mailid'))) {
89 // Display regular member mail by loading its full data
90 $result_data = SQL_QUERY_ESC("SELECT
91 s.id, s.subject, p.text, s.timestamp_ordered AS `timestamp`, s.cat_id, pay.price AS points, p.sender, pay.time, p.data_type
93 `{?_MYSQL_PREFIX?}_user_stats` AS s
95 `{?_MYSQL_PREFIX?}_pool` AS p
99 `{?_MYSQL_PREFIX?}_payments` AS pay
105 array(bigintval(getRequestParameter('mailid'))), __FILE__, __LINE__);
108 $content = SQL_FETCHARRAY($result_data);
110 // Translate some data
111 $content['timestamp'] = generateDateTime($content['timestamp'], 2);
112 $content['category'] = getCategory($content['cat_id']);
113 $content['points'] = translateComma($content['points']);
114 $content['time'] = createFancyTime($content['time']);
115 $content['userid'] = getMemberId();
116 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_NORMAL_CONFIRMED_UNKNOWN', $content['id']);
118 // Is ext-user installed?
119 if (isExtensionInstalled('user')) {
120 // Get timestamp from insert
121 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_NORMAL_CONFIRMED_ON',
122 generateDateTime(getTimestampFromUserStats('mailid', $content['id']), 2)
126 // Display it depending on mail (data) type
127 loadTemplate('member_mail_normal_'.strtolower($content['data_type']), false, $content);
130 SQL_FREERESULT($result_data);
133 if (isExtensionActive('bonus')) {
135 $result = SQL_QUERY_ESC("SELECT `stats_id`, `bonus_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `bonus_id` DESC, stats_id DESC",
136 array(getMemberId()), __FILE__, __LINE__);
138 // Don't load bonus id
139 $result = SQL_QUERY_ESC("SELECT `stats_id`, `stats_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `stats_id` DESC",
140 array(getMemberId()), __FILE__, __LINE__);
143 // Mails left for confirmation?
144 if (SQL_NUMROWS($result) > 0) {
145 // Please confirm these mails!
146 $sum = '0'; $OUT = ''; $SW = 2;
151 // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
152 while (list($id, $id2, $type) = SQL_FETCHROW($result)) {
153 // Load data from stats table...
155 $result_data = false;
156 $PROBLEM = getMessage('MEMBER_GENERAL_MAIL_PROBLEM');
157 $DATA = $id . '/' . $id2 . '/' . $type;
160 $result_data = SQL_QUERY_ESC("SELECT
161 s.subject, s.timestamp_ordered, s.cat_id, s.payment_id, p.sender
163 `{?_MYSQL_PREFIX?}_user_stats` AS s
165 `{?_MYSQL_PREFIX?}_pool` AS p
171 array(bigintval($id)), __FILE__, __LINE__);
174 $PROBLEM = getMessage('NORMAL_MAIL_PROBLEM');
178 $result_data = SQL_QUERY_ESC("SELECT subject, timestamp, cat_id, points, 0 FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
179 array(bigintval($id2)), __FILE__, __LINE__);
182 $PROBLEM = getMessage('BONUS_MAIL_PROBLEM');
185 default: // Unknown type detected!
186 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown mail type %s detected.", $type));
190 // Data found to this mail?
191 if ((SQL_NUMROWS($result_data) == 1) && (($type == 'mailid') || ($type == 'bonusid'))) {
193 list($subject, $timestamp, $cat, $pay, $sender) = SQL_FETCHROW($result_data);
195 // Subject line found?
196 if (empty($subject)) {
198 $subject = getMessage('DEFAULT_SUBJECT_LINE');
202 if (($sender > 0) && ($type == 'mailid')) {
204 $sender = bigintval($sender);
205 } elseif ($type == 'bonusid') {
207 $sender = getMessage('USERNAME_ADMIN_SHORT');
210 $sender = getMessage('EMAIL_STATUS_DELETED');
213 // Prepare data for template
216 'userid' => getMemberId(),
217 'data' => bigintval($DATA),
219 'subject' => $subject,
221 'timestamp' => generateDateTime($timestamp, 2),
222 'cat' => getCategory($cat),
223 'points' => translateComma($pay),
227 if (getConfig('show_points_unconfirmed') == 'Y') {
228 $OUT .= loadTemplate('member_unconfirmed_row', true, $content);
230 $OUT .= loadTemplate('member_unconfirmed_row_nopoints', true, $content);
236 // Prepare data for template
243 // Display points or not?
244 if (getConfig('show_points_unconfirmed') == 'Y') {
245 $OUT .= loadTemplate('member_unconfirmed_404', true, $content);
247 $OUT .= loadTemplate('member_unconfirmed_404_nopoints', true, $content);
252 SQL_FREERESULT($result_data);
259 SQL_FREERESULT($result);
261 // Remember total points
262 $content['total_points'] = translateComma($sum);
264 // Remember all generated rows in constant for the template
265 $content['rows'] = $OUT;
267 // Load main template
268 if (getConfig('show_points_unconfirmed') == 'Y') {
269 loadTemplate('member_unconfirmed_table', false, $content);
271 loadTemplate('member_unconfirmed_table_nopoints', false, $content);
274 // No mails left to confirm... :)
275 loadTemplate('admin_settings_saved', false, getMessage('MEMBER_NO_MAILS_TO_CONFIRM'));