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 * 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['userid'] = getMemberId();
68 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_BONUS_CONFIRMED_UNKNOWN', $content['id']);
70 // Is ext-user installed?
71 if (isExtensionInstalled('user')) {
72 // Get timestamp from insert
73 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_BONUS_CONFIRMED_ON',
74 generateDateTime(getTimestampFromUserStats('bonusid', $content['id']), 2)
78 // Display it depending on mail (data) type
79 loadTemplate('member_mail_bonus_'.strtolower($content['data_type']), false, $content);
82 SQL_FREERESULT($result_data);
83 } elseif (isGetRequestParameterSet('mailid')) {
84 // Display regular member mail by loading its full data
85 $result_data = SQL_QUERY_ESC("SELECT
86 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
88 `{?_MYSQL_PREFIX?}_user_stats` AS s
90 `{?_MYSQL_PREFIX?}_pool` AS p
94 `{?_MYSQL_PREFIX?}_payments` AS pay
100 array(bigintval(getRequestParameter('mailid'))), __FILE__, __LINE__);
103 $content = SQL_FETCHARRAY($result_data);
105 // Translate some data
106 $content['timestamp'] = generateDateTime($content['timestamp'], 2);
107 $content['userid'] = getMemberId();
108 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_NORMAL_CONFIRMED_UNKNOWN', $content['id']);
110 // Is ext-user installed?
111 if (isExtensionInstalled('user')) {
112 // Get timestamp from insert
113 $content['user_status'] = getMaskedMessage('MEMBER_MAIL_NORMAL_CONFIRMED_ON',
114 generateDateTime(getTimestampFromUserStats('mailid', $content['id']), 2)
118 // Display it depending on mail (data) type
119 loadTemplate('member_mail_normal_' . strtolower($content['data_type']), false, $content);
122 SQL_FREERESULT($result_data);
125 if (isExtensionActive('bonus')) {
127 $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",
128 array(getMemberId()), __FILE__, __LINE__);
130 // Don't load bonus id if ext-bonus is not installed
131 $result = SQL_QUERY_ESC("SELECT `stats_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `stats_id` DESC",
132 array(getMemberId()), __FILE__, __LINE__);
135 // Mails left for confirmation?
136 if (!SQL_HASZERONUMS($result)) {
137 // Please confirm these mails!
138 $sum = '0'; $OUT = '';
143 // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
144 while ($row = SQL_FETCHARRAY($result)) {
145 // Load data from stats table...
147 $result_data = false;
148 $message = '{--MEMBER_GENERAL_MAIL_PROBLEM--}';
149 $data = $row['stats_id'] . '/' . $row['bonus_id'] . '/' . $row['link_type'];
150 switch ($row['link_type']) {
152 $result_data = SQL_QUERY_ESC("SELECT
153 s.subject, s.timestamp_ordered, s.cat_id, s.payment_id, p.sender
155 `{?_MYSQL_PREFIX?}_user_stats` AS s
157 `{?_MYSQL_PREFIX?}_pool` AS p
163 array(bigintval($row['stats_id'])), __FILE__, __LINE__);
164 $row['link_type'] = 'mailid';
165 $data = $row['stats_id'];
166 $message = '{--NORMAL_MAIL_PROBLEM--}';
170 $result_data = SQL_QUERY_ESC("SELECT subject, timestamp, cat_id, points, 0 FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
171 array(bigintval($row['bonus_id'])), __FILE__, __LINE__);
172 $row['link_type'] = 'bonusid';
173 $data = $row['bonus_id'];
174 $message = '{--BONUS_MAIL_PROBLEM--}';
177 default: // Unknown type detected!
178 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown mail type %s detected.", $row['link_type']));
182 // Data found to this mail?
183 if ((SQL_NUMROWS($result_data) == 1) && (($row['link_type'] == 'mailid') || ($row['link_type'] == 'bonusid'))) {
185 list($subject, $timestamp, $cat, $pay, $sender) = SQL_FETCHROW($result_data);
187 // Subject line found?
188 if (empty($subject)) {
190 $subject = '{--DEFAULT_SUBJECT_LINE--}';
194 if ((isValidUserId($sender)) && ($row['link_type'] == 'mailid')) {
196 $sender = bigintval($sender);
197 } elseif ($row['link_type'] == 'bonusid') {
199 $sender = '{--USERNAME_ADMIN_SHORT--}';
202 $sender = '{--EMAIL_STATUS_DELETED--}';
205 // Prepare data for template
207 'data' => bigintval($data),
208 // @TODO This 'userid' cannot be saved because of encapsulated EL code
209 'userid' => getMemberId(),
210 'link_type' => $row['link_type'],
211 'subject' => $subject,
213 'timestamp' => generateDateTime($timestamp, 2),
218 if (getConfig('show_points_unconfirmed') == 'Y') {
219 $OUT .= loadTemplate('member_unconfirmed_row', true, $content);
221 $OUT .= loadTemplate('member_unconfirmed_row_nopoints', true, $content);
227 // Prepare data for template
230 'message' => $message,
233 // Display points or not?
234 if (getConfig('show_points_unconfirmed') == 'Y') {
235 $OUT .= loadTemplate('member_unconfirmed_404', true, $content);
237 $OUT .= loadTemplate('member_unconfirmed_404_nopoints', true, $content);
242 SQL_FREERESULT($result_data);
246 SQL_FREERESULT($result);
248 // Remember total points
249 $content['total_points'] = $sum;
251 // Remember all generated rows in constant for the template
252 $content['rows'] = $OUT;
254 // Load main template
255 if (getConfig('show_points_unconfirmed') == 'Y') {
256 loadTemplate('member_unconfirmed_table', false, $content);
258 loadTemplate('member_unconfirmed_table_nopoints', false, $content);
261 // No mails left to confirm... :)
262 loadTemplate('admin_settings_saved', false, '{--MEMBER_NO_MAILS_TO_CONFIRM--}');