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 - 2012 by Mailer Developer Team *
20 * For more information visit: http://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 (isGetRequestElementSet('userid')) {
52 // Check if the user already exists
53 if (fetchUserData(getRequestElement('userid'))) {
54 // Default is ext-bonus is not installed
55 $rowName = 'stats_id';
57 // Is ext-bonus installed?
58 if (isExtensionActive('bonus')) {
60 $linkDataName = 'bonus_id';
63 // Load user links data
64 $result = SQL_QUERY_ESC("SELECT `userid`, `stats_id`, `%s`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `id` ASC",
67 bigintval(getRequestElement('userid'))
68 ), __FILE__, __LINE__);
70 // Do we have some entries?
71 if (!SQL_HASZERONUMS($result)) {
72 // Some unconfirmed mails left
73 if (getRequestElement('delete') == '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(getRequestElement('userid')), SQL_NUMROWS($result)), __FILE__, __LINE__);
78 // Prepare mail and send it away
79 $message = loadEmailTemplate('member_delete_links', SQL_NUMROWS($result), bigintval(getRequestElement('userid')));
80 sendEmail(getUserData('userid'), '{--ADMIN_DELETE_LINK_SUBJECT--}', $message);
83 displayMessage('{--ADMIN_LINKS_DELETED--}');
88 // List all unconfirmed mails
89 while ($linkData = SQL_FETCHARRAY($result)) {
90 // Initializes all other elements
91 $linkData['mail_id'] = '';
92 $linkData['problem'] = '{--ADMIN_GENERAL_MAIL_PROBLEM--}';
95 // Load data from stats table...
96 // @TODO Rewrite this to includes/filter
97 switch ($linkData['link_type']) {
99 $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp_ordered` AS `timestamp`, `cat_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
100 array(bigintval($linkData['stats_id'])), __FILE__, __LINE__);
101 $linkData['link_type'] = 'mailid';
102 $linkData['mail_id'] = $linkData['stats_id'];
103 $linkData['problem'] = '{--NORMAL_MAIL_PROBLEM--}';
107 $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp`, `cat_id` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
108 array(bigintval($linkData['bonus_id'])), __FILE__, __LINE__);
109 $linkData['link_type'] = 'bonusid';
110 $linkData['mail_id'] = $linkData['bonus_id'];
111 $linkData['problem'] = '{--BONUS_MAIL_PROBLEM--}';
114 default: // Problem in application detected!
115 reportBug(__FILE__, __LINE__, sprintf("Invalid email type %s detected.", $linkData['link_type']));
119 // Do we have an entry?
120 if (SQL_NUMROWS($result_data) == 1) {
122 $mailData = merge_array($linkData, SQL_FETCHARRAY($result_data));
125 if (empty($mailData['subject'])) {
126 // The subject line is empty so we use the default
127 $mailData['subject'] = '{--DEFAULT_SUBJECT_LINE--}';
130 // Prepare data for the row template
131 $mailData['timestamp'] = generateDateTime($mailData['timestamp'], 0);
134 $OUT .= loadTemplate('admin_list_links_row', true, $mailData);
136 // Load template for error
137 $OUT .= loadTemplate('admin_list_links_problem', true, $linkData);
141 SQL_FREERESULT($result_data);
144 // Remember list in constant for the template
146 'email' => '<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">' . getUserData('email') . '</a>',
148 'nums' => SQL_NUMROWS($result),
149 'userid' => bigintval(getRequestElement('userid')),
153 SQL_FREERESULT($result);
155 // Load final template
156 loadTemplate('admin_list_links', false, $content);
159 // No mails left to confirm
160 displayMessage('{%message,ADMIN_NO_UNCONFIRMED_MAILS_LEFT=' . bigintval(getRequestElement('userid')) . '%}');
164 displayMessage('{%message,ADMIN_MEMBER_404=' . bigintval(getRequestElement('userid')) . '%}');
167 // Output selection form with all confirmed user accounts listed
168 addMemberSelectionBox();