]> git.mxchange.org Git - mailer.git/blob - inc/modules/member/what-unconfirmed.php
6f9e35d92cae3d9076f7fc578bbe65ac2768a157
[mailer.git] / inc / modules / member / what-unconfirmed.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 } elseif (!isMember()) {
43         redirectToIndexMemberOnlyModule();
44 } elseif ((!isExtensionActive('mailid')) && (!isAdmin())) {
45         redirectToUrl('modules.php?module=login');
46 }
47
48 // Add description as navigation point
49 addMenuDescription('member', __FILE__);
50
51 // Shall we display a mail?
52 if ((isGetRequestElementSet(('bonusid'))) && (isExtensionActive('bonus'))) {
53         // Display bonus mail by loading it's full data
54         $result_data = SQL_QUERY_ESC("SELECT id, subject, timestamp, cat_id, points, text, is_notify, data_type, time, url
55 FROM `{?_MYSQL_PREFIX?}_bonus`
56 WHERE `id`=%s LIMIT 1",
57         array(bigintval(getRequestElement('bonusid'))), __FILE__, __LINE__);
58
59         // Load data
60         $content = SQL_FETCHARRAY($result_data);
61
62         // Translate some data
63         $content['timestamp'] = generateDateTime($content['timestamp'], '2');
64         $content['category']  = getCategory($content['cat_id']);
65         $content['points']    = translateComma($content['points']);
66         $content['is_notify'] = translateYesNo($content['is_notify']);
67         $content['sender']    = getMessage('_ADMIN_SHORT');
68         $content['time']      = createFancyTime($content['time']);
69         $content['userid']    = getUserId();
70
71         // Get timestamp from insert
72         $content['user_status'] = sprintf(getMessage('MEMBER_MAIL_BONUS_CONFIRMED_ON'),
73         generateDateTime(getTimestampFromUserStats('bonusid', $content['id']), '2')
74         );
75
76         // Display it depending on mail (data) type
77         loadTemplate('member_mail_bonus_'.strtolower($content['data_type']), false, $content);
78
79         // Free result
80         SQL_FREERESULT($result_data);
81 } elseif (isGetRequestElementSet(('mailid'))) {
82         // Display regular member mail by loading its full data
83         $result_data = SQL_QUERY_ESC("SELECT 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
84 FROM `{?_MYSQL_PREFIX?}_user_stats` AS s
85 LEFT JOIN `{?_MYSQL_PREFIX?}_pool` AS p
86 ON s.pool_id=p.id
87 LEFT JOIN `{?_MYSQL_PREFIX?}_payments` AS pay
88 ON p.payment_id=pay.id
89 WHERE s.id=%s LIMIT 1",
90         array(bigintval(getRequestElement('mailid'))), __FILE__, __LINE__);
91
92         // Load data
93         $content = SQL_FETCHARRAY($result_data);
94
95         // Translate some data
96         $content['timestamp'] = generateDateTime($content['timestamp'], '2');
97         $content['category']  = getCategory($content['cat_id']);
98         $content['points']    = translateComma($content['points']);
99         $content['time']      = createFancyTime($content['time']);
100         $content['userid']    = getUserId();
101
102         // Get timestamp from insert
103         $content['user_status'] = sprintf(getMessage('MEMBER_MAIL_NORMAL_CONFIRMED_ON'),
104         generateDateTime(getTimestampFromUserStats('mailid', $content['id']), '2')
105         );
106
107         // Display it depending on mail (data) type
108         loadTemplate('member_mail_normal_'.strtolower($content['data_type']), false, $content);
109
110         // Free result
111         SQL_FREERESULT($result_data);
112 }
113
114 if (isExtensionActive('bonus')) {
115         // Load bonus ID
116         $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",
117         array(getUserId()), __FILE__, __LINE__);
118 } else {
119         // Don't load bonus ID
120         $result = SQL_QUERY_ESC("SELECT stats_id, stats_id, link_type FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY stats_id DESC",
121         array(getUserId()), __FILE__, __LINE__);
122 }
123
124 // Mails left for confirmation?
125 if (SQL_NUMROWS($result) > 0) {
126         // Please confirm these mails!
127         $sum = 0; $OUT = ''; $SW = 2;
128
129         // Init content
130         $content = array();
131
132         // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
133         while (list($id, $id2, $type) = SQL_FETCHROW($result)) {
134                 // Load data from stats table...
135                 $cat = ''; $result_data = false;
136                 switch ($type)
137                 {
138                         case 'NORMAL':
139                                 $result_data = SQL_QUERY_ESC("SELECT s.subject, s.timestamp_ordered, s.cat_id, s.payment_id, p.sender
140 FROM `{?_MYSQL_PREFIX?}_user_stats` AS s
141 LEFT JOIN `{?_MYSQL_PREFIX?}_pool` AS p
142 ON s.pool_id=p.id
143 WHERE s.id=%s
144 LIMIT 1",
145                                 array(bigintval($id)), __FILE__, __LINE__);
146                                 $type = 'mailid'; $DATA = $id; $PROBLEM = getMessage('NORMAL_MAIL_PROBLEM');
147                                 break;
148
149                         case 'BONUS':
150                                 $result_data = SQL_QUERY_ESC("SELECT subject, timestamp, cat_id, points, 0 FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
151                          array(bigintval($id2)), __FILE__, __LINE__);
152                          $type = 'bonusid'; $DATA = $id2; $PROBLEM = getMessage('BONUS_MAIL_PROBLEM');
153                          break;
154
155                         default: // Unknown type detected!
156                                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown mail type %s detected.", $type));
157                                 break;
158                 }
159
160                 // Data found to this mail?
161                 if ((SQL_NUMROWS($result_data) == 1) && (($type == 'mailid') || ($type == 'bonusid'))) {
162                         // Mail was found!
163                         list($subject, $timestamp, $cat, $pay, $sender) = SQL_FETCHROW($result_data);
164
165                         // Subject line found?
166                         if (empty($subject)) {
167                                 // No subject line!
168                                 $subject = getMessage('DEFAULT_SUBJECT_LINE');
169                         } // END - if
170
171                         // Prepare sender id
172                         if (($sender > 0) && ($type == 'mailid')) {
173                                 // Sender id
174                                 $sender = bigintval($sender);
175                         } elseif ($type == 'bonusid') {
176                                 // Is admin
177                                 $sender = getMessage('_ADMIN_SHORT');
178                         } else {
179                                 // Deleted
180                                 $sender = getMessage('EMAIL_STATUS_DELETED');
181                         }
182
183                         // Prepare data for template
184                         $content = array(
185                                 'sw'      => $SW,
186                                 'userid'     => getUserId(),
187                                 'data'    => bigintval($DATA),
188                                 'type'    => $type,
189                                 'subject' => $subject,
190                                 'sender'  => $sender,
191                                 'stamp'   => generateDateTime($timestamp, '2'),
192                                 'cat'     => getCategory($cat),
193                                 'points'  => translateComma($pay),
194                         );
195
196                         // Load row template
197                         if (getConfig('show_points_unconfirmed') == 'Y') {
198                                 $OUT .= loadTemplate('member_unconfirmed_row', true, $content);
199                         } else {
200                                 $OUT .= loadTemplate('member_unconfirmed_row_nopoints', true, $content);
201                         }
202
203                         // Count points
204                         $sum += $pay;
205                 } else {
206                         // Prepare data for template
207                         $content = array(
208                                 'sw'    => $SW,
209                                 'data'  => $DATA,
210                                 'probl' => $PROBLEM,
211                         );
212
213                         // Display points or not?
214                         if (getConfig('show_points_unconfirmed') == 'Y') {
215                                 $OUT .= loadTemplate('member_unconfirmed_404', true, $content);
216                         } else {
217                                 $OUT .= loadTemplate('member_unconfirmed_404_nopoints', true, $content);
218                         }
219                 }
220
221                 // Free result
222                 SQL_FREERESULT($result_data);
223
224                 // Switch color
225                 $SW = 3 - $SW;
226         } // END - while
227
228         // Free memory
229         SQL_FREERESULT($result);
230
231         // Remember total points
232         $content['total_points'] = translateComma($sum);
233
234         // Remember all generated rows in constant for the template
235         $content['rows'] = $OUT;
236
237         // Load main template
238         if (getConfig('show_points_unconfirmed') == 'Y') {
239                 loadTemplate('member_unconfirmed_table', false, $content);
240         } else {
241                 loadTemplate('member_unconfirmed_table_nopoints', false, $content);
242         }
243 } else {
244         // No mails left to confirm... :)
245         loadTemplate('admin_settings_saved', false, getMessage('MEMBER_NO_MAILS_TO_CONFIRM'));
246 }
247
248 // [EOF]
249 ?>