Naming convention applied, ext-network menu resorted:
[mailer.git] / inc / modules / admin / what-list_unconfirmed.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/09/2004 *
4  * ===================                          Last change: 10/31/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_unconfirmed.php                        *
8  * -------------------------------------------------------------------- *
9  * Short description : List unconfirmed mail links                      *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Unbest. Mail-Links auflisten                     *
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')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 if (!isExtensionActive('mailid')) {
49         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('mailid'));
50         return;
51 } // END - if
52
53 // Don't load the admin_list_unconfirmed template by default
54 $listed = false;
55
56 // List confirmation links from normal or bonus mails
57 if (isGetRequestParameterSet('mid')) {
58         // SQL query for mail data
59         $sql = sprintf("SELECT
60         s.`id`, p.`sender`, p.`subject`, p.`text`, p.`url`, p.`timestamp`, s.`max_rec`
61 FROM
62         `{?_MYSQL_PREFIX?}_pool` AS p
63 LEFT JOIN
64         `{?_MYSQL_PREFIX?}_user_stats` AS s
65 ON
66         p.id=s.pool_id
67 WHERE
68         p.`id`=%s
69 LIMIT 1",
70                 array(bigintval(getRequestParameter('mid')))
71         );
72
73         // Column, type and id for member's mail
74         $col = 'stats_id'; $type = 'NORMAL'; $ID = '-1';
75
76         // Load admin_list_unconfirmed template
77         $listed = true; $DATA = getRequestParameter('mid'); $LINK = 'mailid';
78 } elseif ((isGetRequestParameterSet('bid')) && (isExtensionActive('bonus'))) {
79         // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}');
80
81         // SQL query for mail data (both ids are required for compatiblity to above normal mail
82         $sql = sprintf("SELECT
83         `id`, `id` AS `sender`, `subject`, `text`, `url`, `timestamp`, `mails_sent` AS `max_rec`
84 FROM
85         `{?_MYSQL_PREFIX?}_bonus`
86 WHERE
87         `id`=%s
88 LIMIT 1",
89                 array(bigintval(getRequestParameter('bid')))
90         );
91
92         // Column, type and id for member's mail
93         $col = 'bonus_id'; $type = 'BONUS'; $ID = getRequestParameter('bid');
94
95         // Load admin_list_unconfirmed template
96         $listed = true; $DATA = $ID; $LINK = 'bonusid';
97 } else {
98         // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus
99         loadTemplate('admin_settings_saved', false, '{--ADMIN_CALL_NOT_DIRECTLY--}');
100 }
101
102 // Shall I display links or not?
103 if ($listed === true) {
104         // Load mail data
105         $result_master = SQL_QUERY($sql, __FILE__, __LINE__);
106
107         // Do we have an entry?
108         if (SQL_NUMROWS($result_master) == 1) {
109                 // Mail order / bonus mail found!
110                 $poolData = SQL_FETCHARRAY($result_master);
111
112                 // Transfer data to constants for the template
113                 if (($poolData['id'] > 0) && ($ID == '-1')) $ID = $poolData['id'];
114                 if ($col == 'bonus_id') $poolData['sender'] = '0';
115
116                 // Load unconfirmed mail links. Hmmm, this select query is pretty cool
117                 // but it does only show unconfirmed mail links from existing user
118                 // accounts. So if you have delete one you did not see those links
119                 $result = SQL_QUERY_ESC("SELECT
120         l.`userid`, u.`status`, u.`surname`, u.`family`, u.`gender`, u.`email`
121 FROM
122         `{?_MYSQL_PREFIX?}_user_links` AS `l`
123 LEFT JOIN
124         `{?_MYSQL_PREFIX?}_user_data` AS `u`
125 ON
126         l.`userid`=u.`userid`
127 WHERE
128         l.`%s`=%s
129 ORDER BY
130         l.`userid` ASC
131 LIMIT %s",
132                         array(
133                                 $col,
134                                 $ID,
135                                 bigintval($poolData['max_rec'])
136                         ),__FILE__, __LINE__);
137
138                 // Do we have entries?
139                 if (SQL_NUMROWS($result) > 0) {
140                         // At least one link left to confirm
141                         $OUT = '';
142                         while ($content = SQL_FETCHARRAY($result)) {
143                                 // User data found? We can take any field of u.
144                                 if (!is_null($content['status'])) {
145                                         // Prepare data for the row template
146                                         $content = array(
147                                                 'userid' => $content['userid'],
148                                                 'link'   => $LINK,
149                                                 'id'     => $ID,
150                                                 'email'  => '<a href="' . generateEmailLink($content['email'], 'user_data') . '">' . translateGender($content['gender']) . ' ' . $content['surname'] . ' ' . $content['family'] . '</a>',
151                                                 'status' => $content['status'],
152                                         );
153
154                                         // Load row template and switch colors
155                                         $OUT .= loadTemplate('admin_list_unconfirmed_row', true, $content);
156                                 } else {
157                                         // No user data found
158                                         $OUT .= loadTemplate('admin_list_unconfirmed_row_404', true, $content);
159                                 }
160                         } // END - while
161
162                         // Render it in our new listing
163                         $OUT = loadTemplate('admin_list_unconfirmed_list', true, $OUT);
164                 } else {
165                         // All links are confirmed... strange, you shall normally not get a link to this place in this scenario... hmmm.
166                         $OUT = loadTemplate('admin_settings_saved', true, '{--ADMIN_UNCONFIRMED_NO_LINK_LEFT--}');
167                 }
168
169                 // Prepare content
170                 $content['unconfirmed'] = SQL_NUMROWS($result);
171                 $content['timestamp']   = generateDateTime($poolData['timestamp'], 2);
172                 $content['rows']        = $OUT;
173
174                 // Free memory
175                 SQL_FREERESULT($result);
176
177                 // Load final template
178                 loadTemplate('admin_list_unconfirmed', false, $content);
179         } elseif (getRequestParameter('mid') > 0) {
180                 // Data in pool or in user_stats not found, so let's find out where data is missing
181                 if (countSumTotalData(bigintval($ID), 'pool', 'id', 'id', true) == 1) {
182                         // pool table
183                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_UNCONFIRMED_POOL_MISSING', $ID));
184                 } elseif (countSumTotalData(bigintval($ID), 'user_stats', 'id', 'pool_id', true) == 1) {
185                         // user_stats table
186                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_UNCONFIRMED_STATS_MISSING', $ID));
187                 } else {
188                         // both or link is invalid
189                         loadTemplate('admin_settings_saved', false, '{--ADMIN_UNCONFIRMED_INVALID_LINK--}');
190                 }
191         } elseif (isGetRequestParameterSet('bid')) {
192                 // Data in bonus table not found
193                 loadTemplate('admin_settings_saved', false, '{--ADMIN_UNCONFIRMED_INVALID_LINK--}');
194         }
195
196         // Free result
197         SQL_FREERESULT($result_master);
198 } // END - if
199
200 // [EOF]
201 ?>