]> git.mxchange.org Git - mailer.git/blob - inc/modules/member/what-unconfirmed.php
d5a2b824d8c93acf9c8c70b30c59766c6286035c
[mailer.git] / inc / modules / member / what-unconfirmed.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/19/2003 *
4  * ===================                          Last change: 07/13/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-unconfirmed.php                             *
8  * -------------------------------------------------------------------- *
9  * Short description : Unconfirmed mails                                *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Unbest&auml;tigte Mails                              *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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                  *
23  *                                                                      *
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.                                  *
28  *                                                                      *
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.                         *
33  *                                                                      *
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,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         die();
43 } elseif (!isMember()) {
44         redirectToIndexMemberOnlyModule();
45 }
46
47 // Add description as navigation point
48 addMenuDescription('member', __FILE__);
49
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`
55 FROM
56         `{?_MYSQL_PREFIX?}_bonus`
57 WHERE
58         `id`=%s
59 LIMIT 1",
60                 array(bigintval(getRequestParameter('bonusid'))), __FILE__, __LINE__);
61
62         // Load data
63         $content = SQL_FETCHARRAY($result_data);
64
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']);
74
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)
80                 );
81         } // END - if
82
83         // Display it depending on mail (data) type
84         loadTemplate('member_mail_bonus_'.strtolower($content['data_type']), false, $content);
85
86         // Free result
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
92 FROM
93         `{?_MYSQL_PREFIX?}_user_stats` AS s
94 LEFT JOIN
95         `{?_MYSQL_PREFIX?}_pool` AS p
96 ON
97         s.pool_id=p.id
98 LEFT JOIN
99         `{?_MYSQL_PREFIX?}_payments` AS pay
100 ON
101         p.payment_id=pay.id
102 WHERE
103         s.id=%s
104 LIMIT 1",
105                 array(bigintval(getRequestParameter('mailid'))), __FILE__, __LINE__);
106
107         // Load data
108         $content = SQL_FETCHARRAY($result_data);
109
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']);
117
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)
123                 );
124         } // END - if
125
126         // Display it depending on mail (data) type
127         loadTemplate('member_mail_normal_'.strtolower($content['data_type']), false, $content);
128
129         // Free result
130         SQL_FREERESULT($result_data);
131 }
132
133 if (isExtensionActive('bonus')) {
134         // Load bonus id
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__);
137 } else {
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__);
141 }
142
143 // Mails left for confirmation?
144 if (SQL_NUMROWS($result) > 0) {
145         // Please confirm these mails!
146         $sum = '0'; $OUT = ''; $SW = 2;
147
148         // Init content
149         $content = array();
150
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...
154                 $cat = '';
155                 $result_data = false;
156                 $PROBLEM = getMessage('MEMBER_GENERAL_MAIL_PROBLEM');
157                 $DATA = $id . '/' . $id2 . '/' . $type;
158                 switch ($type) {
159                         case 'NORMAL':
160                                 $result_data = SQL_QUERY_ESC("SELECT
161         s.subject, s.timestamp_ordered, s.cat_id, s.payment_id, p.sender
162 FROM
163         `{?_MYSQL_PREFIX?}_user_stats` AS s
164 LEFT JOIN
165         `{?_MYSQL_PREFIX?}_pool` AS p
166 ON
167         s.pool_id=p.id
168 WHERE
169         s.id=%s
170 LIMIT 1",
171                                         array(bigintval($id)), __FILE__, __LINE__);
172                                 $type = 'mailid';
173                                 $DATA = $id;
174                                 $PROBLEM = getMessage('NORMAL_MAIL_PROBLEM');
175                                 break;
176
177                         case 'BONUS':
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__);
180                                 $type = 'bonusid';
181                                 $DATA = $id2;
182                                 $PROBLEM = getMessage('BONUS_MAIL_PROBLEM');
183                                 break;
184
185                         default: // Unknown type detected!
186                                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown mail type %s detected.", $type));
187                                 break;
188                 }
189
190                 // Data found to this mail?
191                 if ((SQL_NUMROWS($result_data) == 1) && (($type == 'mailid') || ($type == 'bonusid'))) {
192                         // Mail was found!
193                         list($subject, $timestamp, $cat, $pay, $sender) = SQL_FETCHROW($result_data);
194
195                         // Subject line found?
196                         if (empty($subject)) {
197                                 // No subject line!
198                                 $subject = getMessage('DEFAULT_SUBJECT_LINE');
199                         } // END - if
200
201                         // Prepare sender id
202                         if (($sender > 0) && ($type == 'mailid')) {
203                                 // Sender id
204                                 $sender = bigintval($sender);
205                         } elseif ($type == 'bonusid') {
206                                 // Is admin
207                                 $sender = getMessage('USERNAME_ADMIN_SHORT');
208                         } else {
209                                 // Deleted
210                                 $sender = getMessage('EMAIL_STATUS_DELETED');
211                         }
212
213                         // Prepare data for template
214                         $content = array(
215                                 'sw'        => $SW,
216                                 'userid'    => getMemberId(),
217                                 'data'      => bigintval($DATA),
218                                 'type'      => $type,
219                                 'subject'   => $subject,
220                                 'sender'    => $sender,
221                                 'timestamp' => generateDateTime($timestamp, 2),
222                                 'cat'       => getCategory($cat),
223                                 'points'    => translateComma($pay),
224                         );
225
226                         // Load row template
227                         if (getConfig('show_points_unconfirmed') == 'Y') {
228                                 $OUT .= loadTemplate('member_unconfirmed_row', true, $content);
229                         } else {
230                                 $OUT .= loadTemplate('member_unconfirmed_row_nopoints', true, $content);
231                         }
232
233                         // Count points
234                         $sum += $pay;
235                 } else {
236                         // Prepare data for template
237                         $content = array(
238                                 'sw'    => $SW,
239                                 'data'  => $DATA,
240                                 'probl' => $PROBLEM,
241                         );
242
243                         // Display points or not?
244                         if (getConfig('show_points_unconfirmed') == 'Y') {
245                                 $OUT .= loadTemplate('member_unconfirmed_404', true, $content);
246                         } else {
247                                 $OUT .= loadTemplate('member_unconfirmed_404_nopoints', true, $content);
248                         }
249                 }
250
251                 // Free result
252                 SQL_FREERESULT($result_data);
253
254                 // Switch color
255                 $SW = 3 - $SW;
256         } // END - while
257
258         // Free memory
259         SQL_FREERESULT($result);
260
261         // Remember total points
262         $content['total_points'] = translateComma($sum);
263
264         // Remember all generated rows in constant for the template
265         $content['rows'] = $OUT;
266
267         // Load main template
268         if (getConfig('show_points_unconfirmed') == 'Y') {
269                 loadTemplate('member_unconfirmed_table', false, $content);
270         } else {
271                 loadTemplate('member_unconfirmed_table_nopoints', false, $content);
272         }
273 } else {
274         // No mails left to confirm... :)
275         loadTemplate('admin_settings_saved', false, getMessage('MEMBER_NO_MAILS_TO_CONFIRM'));
276 }
277
278 // [EOF]
279 ?>