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('{%pipe,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('member_delete_links', SQL_NUMROWS($result), bigintval(getRequestParameter('userid')));
76 sendEmail(getUserData('userid'), '{--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
89 $PROBLEM = '{--ADMIN_GENERAL_MAIL_PROBLEM--}';
92 // Load data from stats table...
93 // @TODO Rewrite this to includes/filter
96 $result_data = SQL_QUERY_ESC("SELECT `subject`,`timestamp_ordered` AS `timestamp`,`cat_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
97 array(bigintval($id)), __FILE__, __LINE__);
98 $type = 'mailid'; $DATA = $id; $PROBLEM = '{--NORMAL_MAIL_PROBLEM--}';
99 $LINK = '<a href="{%url=mailid.php?userid=' . getRequestParameter('userid') . '&mailid=' . $id . '%}" target="_blank">' . $id . '</a>';
103 $result_data = SQL_QUERY_ESC("SELECT `subject`,`timestamp`,`cat_id` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
104 array(bigintval($id2)), __FILE__, __LINE__);
105 $type = 'bonusid'; $DATA = $id2; $PROBLEM = '{--BONUS_MAIL_PROBLEM--}';
106 $LINK = '<a href="{%url=mailid.php?userid=' . getRequestParameter('userid') . '&bonusid=' . $id2 . '%}" target="_blank">' . $id2 . '</a>';
109 default: // Problem in application detected!
111 logDebugMessage(__FILE__, __LINE__, sprintf("Invalid email type %s detected.", $type));
115 // Do we have an entry?
116 if (SQL_NUMROWS($result_data) == 1) {
118 $content = SQL_FETCHARRAY($result_data);
121 if (empty($content['subject'])) $content['subject'] = '{--DEFAULT_SUBJECT_LINE--}';
123 // Prepare data for the row template
126 'subject' => $content['subject'],
127 'timestamp' => generateDateTime($content['timestamp'], 0),
128 'cat_id' => $content['cat_id'],
132 $OUT .= loadTemplate('admin_list_links_row', true, $content);
134 // Load template for error
135 $OUT .= loadTemplate('admin_list_links_problem', true,
137 'problem' => $PROBLEM,
144 SQL_FREERESULT($result_data);
147 // Remember list in constant for the template
148 $content['email'] = '<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">' . getUserData('email') . '</a>';
149 $content['rows'] = $OUT;
150 $content['nums'] = SQL_NUMROWS($result);
151 $content['userid'] = bigintval(getRequestParameter('userid'));
154 SQL_FREERESULT($result);
156 // Load final template
157 loadTemplate('admin_list_links', false, $content);
160 // No mails left to confirm
161 displayMessage('{%message,ADMIN_NO_UNCONFIRMED_MAILS_LEFT=' . bigintval(getRequestParameter('userid')) . '%}');
165 displayMessage('{%message,ADMIN_MEMBER_404=' . bigintval(getRequestParameter('userid')) . '%}');
168 // Output selection form with all confirmed user accounts listed
169 addMemberSelectionBox();