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 * 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 *
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. *
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. *
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, *
38 ************************************************************************/
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
48 if (!isExtensionActive('mailid')) {
49 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('mailid'));
53 if (isGetRequestParameterSet('userid')) {
54 // Check if the user already exists
55 if (fetchUserData(getRequestParameter('userid'))) {
56 // Grab user's all unconfirmed mails
57 // @TODO Try to rewrite this to a filter
58 if (isExtensionActive('bonus')) {
60 $result = SQL_QUERY_ESC("SELECT `stats_id`, `bonus_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `id` ASC",
61 array(bigintval(getRequestParameter('userid'))), __FILE__, __LINE__);
63 // Load stats id (2nd will be ignored later! But it is needed for the same fetchrow command)
64 $result = SQL_QUERY_ESC("SELECT `stats_id`, `stats_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `id` ASC",
65 array(bigintval(getRequestParameter('userid'))), __FILE__, __LINE__);
68 // Get number of rows from the query
69 $nums = SQL_NUMROWS($result);
72 // Some unconfirmed mails left
73 if (getRequestParameter('del') == "all") {
74 // Delete all unconfirmed mails by this user
75 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s LIMIT %s",
76 array(bigintval(getRequestParameter('userid')), $nums), __FILE__, __LINE__);
78 // Prepare mail and send it away
79 $message = loadEmailTemplate('admin-del_links', $nums, bigintval(getRequestParameter('userid')));
80 sendEmail(getUserData('email'), '{--ADMIN_DELETE_LINK_SUBJECT--}', $message);
83 loadTemplate('admin_settings_saved', false, '{--ADMIN_LINKS_DELETED--}');
88 // List all unconfirmed mails
89 // @TODO Find a way to rewrite this. See some lines above for different queries
90 while (list($id, $id2, $type) = SQL_FETCHROW($result)) {
91 // Initializes some variables
94 $PROBLEM = '{--ADMIN_GENERAL_MAIL_PROBLEM--}';
95 $result_data = false; // Closes Bug #58
97 // Load data from stats table...
98 // @TODO Rewrite this to includes/filter
101 $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp_ordered` AS `timestamp`, `cat_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
102 array(bigintval($id)), __FILE__, __LINE__);
103 $type = 'mailid'; $DATA = $id; $PROBLEM = '{--NORMAL_MAIL_PROBLEM--}';
104 $LINK = '<a href="{%url=mailid.php?userid=' . getRequestParameter('userid') . '&mailid=' . $id . '%}" target="_blank">' . $id . '</a>';
108 $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp`, `cat_id` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
109 array(bigintval($id2)), __FILE__, __LINE__);
110 $type = 'bonusid'; $DATA = $id2; $PROBLEM = '{--BONUS_MAIL_PROBLEM--}';
111 $LINK = '<a href="{%url=mailid.php?userid=' . getRequestParameter('userid') . '&bonusid=' . $id2 . '%}" target="_blank">' . $id2 . '</a>';
114 default: // Problem in application detected!
116 logDebugMessage(__FILE__, __LINE__, sprintf("Invalid email type %s detected.", $type));
120 if (SQL_NUMROWS($result_data) == 1) {
122 $content = SQL_FETCHARRAY($result_data);
125 if (empty($content['subject'])) $content['subject'] = '{--DEFAULT_SUBJECT_LINE--}';
127 // Prepare data for the row template
130 'subject' => $content['subject'],
131 'timestamp' => generateDateTime($content['timestamp'], 0),
132 'cat_id' => $content['cat_id'],
136 $OUT .= loadTemplate('admin_list_links_row', true, $content);
138 // Load template for error
139 $OUT .= loadTemplate('admin_list_links_problem', true,
141 'problem' => $PROBLEM,
148 SQL_FREERESULT($result_data);
152 SQL_FREERESULT($result);
154 // Remember list in constant for the template
155 $content['surname'] = getUserData('surname');
156 $content['family'] = getUserData('family');
157 $content['email'] = '<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">' . getUserData('email') . '</a>';
158 $content['rows'] = $OUT;
159 $content['nums'] = $nums;
160 $content['userid'] = bigintval(getRequestParameter('userid'));
162 // Load final template
163 loadTemplate('admin_list_links', false, $content);
166 // No mails left to confirm
167 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_MEMBER_LINKS', bigintval(getRequestParameter('userid'))));
171 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_MEMBER_404', bigintval(getRequestParameter('userid'))));
174 // Output selection form with all confirmed user accounts listed
175 addMemberSelectionBox();