]> git.mxchange.org Git - mailer.git/blob - inc/modules/member/what-unconfirmed.php
8e7874f111e6f498c2922ef9e10231f7d993f85c
[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  : Unbestaetigte 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['userid']      = getMemberId();
68         $content['user_status'] = getMaskedMessage('MEMBER_MAIL_BONUS_CONFIRMED_UNKNOWN', $content['id']);
69
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)
75                 );
76         } // END - if
77
78         // Display it depending on mail (data) type
79         loadTemplate('member_mail_bonus_'.strtolower($content['data_type']), false, $content);
80
81         // Free result
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
87 FROM
88         `{?_MYSQL_PREFIX?}_user_stats` AS s
89 LEFT JOIN
90         `{?_MYSQL_PREFIX?}_pool` AS p
91 ON
92         s.pool_id=p.id
93 LEFT JOIN
94         `{?_MYSQL_PREFIX?}_payments` AS pay
95 ON
96         p.payment_id=pay.id
97 WHERE
98         s.id=%s
99 LIMIT 1",
100                 array(bigintval(getRequestParameter('mailid'))), __FILE__, __LINE__);
101
102         // Load data
103         $content = SQL_FETCHARRAY($result_data);
104
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']);
109
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)
115                 );
116         } // END - if
117
118         // Display it depending on mail (data) type
119         loadTemplate('member_mail_normal_' . strtolower($content['data_type']), false, $content);
120
121         // Free result
122         SQL_FREERESULT($result_data);
123 }
124
125 if (isExtensionActive('bonus')) {
126         // Load bonus id
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__);
129 } else {
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__);
133 }
134
135 // Mails left for confirmation?
136 if (!SQL_HASZERONUMS($result)) {
137         // Please confirm these mails!
138         $sum = '0'; $OUT = '';
139
140         // Init content
141         $content = array();
142
143         // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
144         while ($row = SQL_FETCHARRAY($result)) {
145                 // Load data from stats table...
146                 $cat = '';
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']) {
151                         case 'NORMAL':
152                                 $result_data = SQL_QUERY_ESC("SELECT
153         s.subject, s.timestamp_ordered, s.cat_id, s.payment_id, p.sender
154 FROM
155         `{?_MYSQL_PREFIX?}_user_stats` AS s
156 LEFT JOIN
157         `{?_MYSQL_PREFIX?}_pool` AS p
158 ON
159         s.pool_id=p.id
160 WHERE
161         s.id=%s
162 LIMIT 1",
163                                         array(bigintval($row['stats_id'])), __FILE__, __LINE__);
164                                 $row['link_type'] = 'mailid';
165                                 $data = $row['stats_id'];
166                                 $message = '{--NORMAL_MAIL_PROBLEM--}';
167                                 break;
168
169                         case 'BONUS':
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--}';
175                                 break;
176
177                         default: // Unknown type detected!
178                                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown mail type %s detected.", $row['link_type']));
179                                 break;
180                 }
181
182                 // Data found to this mail?
183                 if ((SQL_NUMROWS($result_data) == 1) && (($row['link_type'] == 'mailid') || ($row['link_type'] == 'bonusid'))) {
184                         // Mail was found!
185                         list($subject, $timestamp, $cat, $pay, $sender) = SQL_FETCHROW($result_data);
186
187                         // Subject line found?
188                         if (empty($subject)) {
189                                 // No subject line!
190                                 $subject = '{--DEFAULT_SUBJECT_LINE--}';
191                         } // END - if
192
193                         // Prepare sender id
194                         if ((isValidUserId($sender)) && ($row['link_type'] == 'mailid')) {
195                                 // Sender id
196                                 $sender = bigintval($sender);
197                         } elseif ($row['link_type'] == 'bonusid') {
198                                 // Is admin
199                                 $sender = '{--USERNAME_ADMIN_SHORT--}';
200                         } else {
201                                 // Deleted
202                                 $sender = '{--EMAIL_STATUS_DELETED--}';
203                         }
204
205                         // Prepare data for template
206                         $content = array(
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,
212                                 'sender'    => $sender,
213                                 'timestamp' => generateDateTime($timestamp, 2),
214                                 'points'    => $pay,
215                         );
216
217                         // Load row template
218                         if (getConfig('show_points_unconfirmed') == 'Y') {
219                                 $OUT .= loadTemplate('member_unconfirmed_row', true, $content);
220                         } else {
221                                 $OUT .= loadTemplate('member_unconfirmed_row_nopoints', true, $content);
222                         }
223
224                         // Count points
225                         $sum += $pay;
226                 } else {
227                         // Prepare data for template
228                         $content = array(
229                                 'data'    => $data,
230                                 'message' => $message,
231                         );
232
233                         // Display points or not?
234                         if (getConfig('show_points_unconfirmed') == 'Y') {
235                                 $OUT .= loadTemplate('member_unconfirmed_404', true, $content);
236                         } else {
237                                 $OUT .= loadTemplate('member_unconfirmed_404_nopoints', true, $content);
238                         }
239                 }
240
241                 // Free result
242                 SQL_FREERESULT($result_data);
243         } // END - while
244
245         // Free memory
246         SQL_FREERESULT($result);
247
248         // Remember total points
249         $content['total_points'] = $sum;
250
251         // Remember all generated rows in constant for the template
252         $content['rows'] = $OUT;
253
254         // Load main template
255         if (getConfig('show_points_unconfirmed') == 'Y') {
256                 loadTemplate('member_unconfirmed_table', false, $content);
257         } else {
258                 loadTemplate('member_unconfirmed_table_nopoints', false, $content);
259         }
260 } else {
261         // No mails left to confirm... :)
262         loadTemplate('admin_settings_saved', false, '{--MEMBER_NO_MAILS_TO_CONFIRM--}');
263 }
264
265 // [EOF]
266 ?>