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 : Unbestaetigte Mails *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://www.mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
41 } elseif (!isMember()) {
42 redirectToIndexMemberOnlyModule();
45 // Add description as navigation point
46 addYouAreHereLink('member', __FILE__);
48 // Shall we display a mail?
49 if ((isGetRequestParameterSet('bonusid')) && (isExtensionActive('bonus'))) {
50 // Display bonus mail by loading it's full data
51 $result_data = SQL_QUERY_ESC("SELECT
52 `id`, `subject`, `timestamp`, `cat_id`, `points`, `text`, `is_notify`, `data_type`, `time`, `url`
54 `{?_MYSQL_PREFIX?}_bonus`
58 array(bigintval(getRequestParameter('bonusid'))), __FILE__, __LINE__);
61 $content = SQL_FETCHARRAY($result_data);
63 // Translate some data
64 $content['timestamp'] = generateDateTime($content['timestamp'], 2);
65 $content['userid'] = getMemberId();
66 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_BONUS_CONFIRMED_UNKNOWN', $content['id']);
68 // Is ext-user installed?
69 if (isExtensionInstalled('user')) {
70 // Get timestamp from insert
71 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_BONUS_CONFIRMED_ON',
72 generateDateTime(getTimestampFromUserStats('bonusid', $content['id']), 2)
76 // Display it depending on mail (data) type
77 loadTemplate('member_mail_bonus_'.strtolower($content['data_type']), false, $content);
80 SQL_FREERESULT($result_data);
81 } elseif (isGetRequestParameterSet('mailid')) {
82 // Display regular member mail by loading its full data
83 $result_data = SQL_QUERY_ESC("SELECT
84 s.id, s.subject, p.text, s.timestamp_ordered AS `timestamp`,
85 s.cat_id, pay.price AS `points`, p.sender, pay.time, p.data_type
87 `{?_MYSQL_PREFIX?}_user_stats` AS s
89 `{?_MYSQL_PREFIX?}_pool` AS p
93 `{?_MYSQL_PREFIX?}_payments` AS pay
99 array(bigintval(getRequestParameter('mailid'))), __FILE__, __LINE__);
102 $content = SQL_FETCHARRAY($result_data);
104 // Translate some data
105 $content['timestamp'] = generateDateTime($content['timestamp'], 2);
106 $content['userid'] = getMemberId();
107 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_NORMAL_CONFIRMED_UNKNOWN', $content['id']);
109 // Is ext-user installed?
110 if (isExtensionInstalled('user')) {
111 // Get timestamp from insert
112 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_NORMAL_CONFIRMED_ON',
113 generateDateTime(getTimestampFromUserStats('mailid', $content['id']), 2)
117 // Display it depending on mail (data) type
118 loadTemplate('member_mail_normal_' . strtolower($content['data_type']), false, $content);
121 SQL_FREERESULT($result_data);
124 if (isExtensionActive('bonus')) {
126 $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",
127 array(getMemberId()), __FILE__, __LINE__);
129 // Don't load bonus id if ext-bonus is not installed
130 $result = SQL_QUERY_ESC("SELECT `stats_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `stats_id` DESC",
131 array(getMemberId()), __FILE__, __LINE__);
134 // Mails left for confirmation?
135 if (!SQL_HASZERONUMS($result)) {
136 // Please confirm these mails!
137 $sum = '0'; $OUT = '';
142 // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
143 while ($row = SQL_FETCHARRAY($result)) {
144 // Load data from stats table...
146 $result_data = false;
147 $message = '{--MEMBER_GENERAL_MAIL_PROBLEM--}';
148 $data = $row['stats_id'] . '/' . $row['bonus_id'] . '/' . $row['link_type'];
149 switch ($row['link_type']) {
151 $result_data = SQL_QUERY_ESC("SELECT
152 s.subject, s.timestamp_ordered, s.cat_id, s.payment_id, p.sender
154 `{?_MYSQL_PREFIX?}_user_stats` AS s
156 `{?_MYSQL_PREFIX?}_pool` AS p
162 array(bigintval($row['stats_id'])), __FILE__, __LINE__);
163 $row['link_type'] = 'mailid';
164 $data = $row['stats_id'];
165 $message = '{--NORMAL_MAIL_PROBLEM--}';
169 $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp`, `cat_id`, `points`, 0 FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
170 array(bigintval($row['bonus_id'])), __FILE__, __LINE__);
171 $row['link_type'] = 'bonusid';
172 $data = $row['bonus_id'];
173 $message = '{--BONUS_MAIL_PROBLEM--}';
176 default: // Unknown type detected!
177 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown mail type %s detected.", $row['link_type']));
181 // Data found to this mail?
182 if ((SQL_NUMROWS($result_data) == 1) && (($row['link_type'] == 'mailid') || ($row['link_type'] == 'bonusid'))) {
184 list($subject, $timestamp, $cat, $pay, $sender) = SQL_FETCHROW($result_data);
186 // Subject line found?
187 if (empty($subject)) {
189 $subject = '{--DEFAULT_SUBJECT_LINE--}';
193 if ((isValidUserId($sender)) && ($row['link_type'] == 'mailid')) {
195 $sender = bigintval($sender);
196 } elseif ($row['link_type'] == 'bonusid') {
198 $sender = '{--USERNAME_ADMIN_SHORT--}';
201 $sender = '{--EMAIL_STATUS_DELETED--}';
204 // Prepare data for template
206 'data' => bigintval($data),
207 // @TODO This 'userid' cannot be saved because of encapsulated EL code
208 'userid' => getMemberId(),
209 'link_type' => $row['link_type'],
210 'subject' => $subject,
212 'timestamp' => generateDateTime($timestamp, 2),
217 if (getConfig('show_points_unconfirmed') == 'Y') {
218 $OUT .= loadTemplate('member_unconfirmed_row', true, $content);
220 $OUT .= loadTemplate('member_unconfirmed_row_nopoints', true, $content);
226 // Prepare data for template
229 'message' => $message,
232 // Display points or not?
233 if (getConfig('show_points_unconfirmed') == 'Y') {
234 $OUT .= loadTemplate('member_unconfirmed_404', true, $content);
236 $OUT .= loadTemplate('member_unconfirmed_404_nopoints', true, $content);
241 SQL_FREERESULT($result_data);
245 SQL_FREERESULT($result);
247 // Remember total points
248 $content['total_points'] = $sum;
250 // Remember all generated rows in constant for the template
251 $content['rows'] = $OUT;
253 // Load main template
254 if (getConfig('show_points_unconfirmed') == 'Y') {
255 loadTemplate('member_unconfirmed_table', false, $content);
257 loadTemplate('member_unconfirmed_table_nopoints', false, $content);
260 // No mails left to confirm... :)
261 displayMessage('{--MEMBER_NO_MAILS_TO_CONFIRM--}');