2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 01/28/2004 *
4 * =================== Last change: 12/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-list_links.php *
8 * -------------------------------------------------------------------- *
9 * Short description : List unconfirmed mails of a member *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Unbestätigte Mails eines Mitgliedes auflisten *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://www.mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
46 if (!isExtensionActive('mailid')) {
47 displayMessage(generateExtensionInactiveNotInstalledMessage('mailid'));
51 if (isGetRequestParameterSet('userid')) {
52 // Check if the user already exists
53 if (fetchUserData(getRequestParameter('userid'))) {
54 // Grab user's all unconfirmed mails
55 // @TODO Try to rewrite this to a filter
56 if (isExtensionActive('bonus')) {
58 $result = SQL_QUERY_ESC("SELECT `stats_id`, `bonus_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `id` ASC",
59 array(bigintval(getRequestParameter('userid'))), __FILE__, __LINE__);
61 // Load stats id (2nd will be ignored later! But it is needed for the same fetchrow command)
62 $result = SQL_QUERY_ESC("SELECT `stats_id`, `stats_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `id` ASC",
63 array(bigintval(getRequestParameter('userid'))), __FILE__, __LINE__);
66 // Do we have some entries?
67 if (!SQL_HASZERONUMS($result)) {
68 // Some unconfirmed mails left
69 if (getRequestParameter('delete') == "all") {
70 // Delete all unconfirmed mails by this user
71 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s LIMIT %s",
72 array(bigintval(getRequestParameter('userid')), SQL_NUMROWS($result)), __FILE__, __LINE__);
74 // Prepare mail and send it away
75 $message = loadEmailTemplate('admin-del_links', SQL_NUMROWS($result), bigintval(getRequestParameter('userid')));
76 sendEmail(getUserData('email'), '{--ADMIN_DELETE_LINK_SUBJECT--}', $message);
79 displayMessage('{--ADMIN_LINKS_DELETED--}');
84 // List all unconfirmed mails
85 // @TODO Find a way to rewrite this. See some lines above for different queries
86 while (list($id, $id2, $type) = SQL_FETCHROW($result)) {
87 // Initializes all variables
90 $PROBLEM = '{--ADMIN_GENERAL_MAIL_PROBLEM--}';
93 // Load data from stats table...
94 // @TODO Rewrite this to includes/filter
97 $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp_ordered` AS `timestamp`, `cat_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
98 array(bigintval($id)), __FILE__, __LINE__);
99 $type = 'mailid'; $DATA = $id; $PROBLEM = '{--NORMAL_MAIL_PROBLEM--}';
100 $LINK = '<a href="{%url=mailid.php?userid=' . getRequestParameter('userid') . '&mailid=' . $id . '%}" target="_blank">' . $id . '</a>';
104 $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp`, `cat_id` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
105 array(bigintval($id2)), __FILE__, __LINE__);
106 $type = 'bonusid'; $DATA = $id2; $PROBLEM = '{--BONUS_MAIL_PROBLEM--}';
107 $LINK = '<a href="{%url=mailid.php?userid=' . getRequestParameter('userid') . '&bonusid=' . $id2 . '%}" target="_blank">' . $id2 . '</a>';
110 default: // Problem in application detected!
112 logDebugMessage(__FILE__, __LINE__, sprintf("Invalid email type %s detected.", $type));
116 // Do we have an entry?
117 if (SQL_NUMROWS($result_data) == 1) {
119 $content = SQL_FETCHARRAY($result_data);
122 if (empty($content['subject'])) $content['subject'] = '{--DEFAULT_SUBJECT_LINE--}';
124 // Prepare data for the row template
127 'subject' => $content['subject'],
128 'timestamp' => generateDateTime($content['timestamp'], 0),
129 'cat_id' => $content['cat_id'],
133 $OUT .= loadTemplate('admin_list_links_row', true, $content);
135 // Load template for error
136 $OUT .= loadTemplate('admin_list_links_problem', true,
138 'problem' => $PROBLEM,
145 SQL_FREERESULT($result_data);
148 // Remember list in constant for the template
149 $content['surname'] = getUserData('surname');
150 $content['family'] = getUserData('family');
151 $content['email'] = '<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">' . getUserData('email') . '</a>';
152 $content['rows'] = $OUT;
153 $content['nums'] = SQL_NUMROWS($result);
154 $content['userid'] = bigintval(getRequestParameter('userid'));
157 SQL_FREERESULT($result);
159 // Load final template
160 loadTemplate('admin_list_links', false, $content);
163 // No mails left to confirm
164 displayMessage(getMaskedMessage('ADMIN_MEMBER_LINKS', bigintval(getRequestParameter('userid'))));
168 displayMessage(getMaskedMessage('ADMIN_MEMBER_404', bigintval(getRequestParameter('userid'))));
171 // Output selection form with all confirmed user accounts listed
172 addMemberSelectionBox();