c6fdcea7a8b25a825398837c3fd918eb6e7dc3d1
[mailer.git] / inc / modules / admin / what-list_norefs.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 01/19/2006 *
4  * ================                             Last change: 01/19/2006 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_norefs.php                             *
8  * -------------------------------------------------------------------- *
9  * Short description : Show all members w/o a referal                   *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Alle Mitgliederaccounts ohne Werber auflisten    *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 } elseif ((!EXT_IS_ACTIVE("user")) || (GET_EXT_VERSION("user") == "")) {
39         // Not active!
40         ADD_FATAL(sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "user"));
41         return;
42 }
43
44 // Add description as navigation point
45 ADD_DESCR("admin", basename(__FILE__));
46
47 $MORE = ", userid"; $colspan = "4"; //                 27
48 if (EXT_IS_ACTIVE("nickname")) { $MORE = ", nickname"; }
49
50 if (empty($_GET['letter'])) { $_GET['letter'] = _ALL2;    }
51 if (empty($_GET['sortby'])) { $_GET['sortby'] = "userid"; }
52 if (empty($_GET['page']))   { $_GET['page']   = "1";      }
53
54 // Set base URL
55 $BASE = "[<A href=\"".URL."/modules.php?module=admin";
56
57 $whereStatement = " WHERE refid=0";
58 if (($_GET['letter'] != _ALL2) && ($_GET['letter'] != _OTHERS) && (!empty($_GET['letter']))) {
59         // List only persons w
60         $whereStatement = " WHERE refid=0 AND family LIKE '".$_GET['letter']."%'";
61 }
62
63 // Fix sorter
64 if ($_GET['sortby'] == "family_name") $_GET['sortby'] = "family";
65
66 // Construct query
67 $SQL = "SELECT userid, gender, surname, family, email, REMOTE_ADDR, refid, status, emails_sent, mails_confirmed, emails_received".$MORE."
68 FROM "._MYSQL_PREFIX."_user_data
69 ".$whereStatement."
70 ORDER BY ".SQL_ESCAPE($_GET['sortby']);
71
72 // Start master query
73 $result_master = SQL_QUERY($SQL, __FILE__, __LINE__);
74
75 // Calculate page count (0.5 fixes a bug with page count)
76 $PAGES = round(SQL_NUMROWS($result_master) / $_CONFIG['user_limit'] + 0.5);
77
78 if (empty($_GET['page']))   $_GET['page']   = "1";
79 if (empty($_GET['offset'])) $_GET['offset'] = $_CONFIG['user_limit'];
80
81 // Add limitation to SQL string and run him again
82 $SQL .= " LIMIT ".($_GET['offset'] * $_GET['page'] - $_GET['offset']).", ".$_GET['offset'];
83 $result = SQL_QUERY($SQL, __FILE__, __LINE__);
84
85 $result_user = SQL_QUERY("SELECT emails_sent FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED'", __FILE__, __LINE__);
86 $user_count = SQL_NUMROWS($result_user);
87 SQL_FREERESULT($result_user);
88
89 if (SQL_NUMROWS($result_master) > 0)
90 {
91         // We have some (new?) registrations!
92         define('__COLSPAN1'  , $colspan);
93         define('__COLSPAN2'  , ($colspan + 2));
94         define('__USER_CNT'  , $user_count);
95         define('__ALPHA_SORT', alpha($_GET['sortby'], $colspan, true));
96         define('__SORT_LINKS', SortLinks($_GET['letter'], $_GET['sortby'], $colspan, true));
97         define('__TITLE'     , ADMIN_LIST_NOREFS_ACCOUNTS);
98
99         if ($PAGES > 1) {
100                 // Add navigation
101                 define('__PAGE_NAV', ADD_PAGENAV($PAGES, $_CONFIG['user_limit'], true, $colspan, true));
102         } else {
103                 // No page navigation is required
104                 define('__PAGE_NAV', "");
105         }
106
107         // Column with nickname when nickname extension is present
108         if (EXT_IS_ACTIVE("nickname")) {
109                 // Nickname extension found
110                 define('__NICKNAME_TH', "  <TD class=\"admin_title bottom2\" align=\"center\">".NICKNAME."</TD>");
111         } else {
112                 // Not found
113                 define('__NICKNAME_TH', "");
114         }
115
116         $SW = 2; $OUT = "";
117         while (list($uid, $gender, $sname, $fname, $email, $IP, $ref, $status, $emails_sent, $mails_confirmed, $emails_received, $nick) = SQL_FETCHROW($result)) {
118                 // Get unconfirmed emails
119                 $LINKS = GET_TOTAL_DATA($uid, "user_links", "id", "userid", true);
120
121                 // Set link to unconfirmed emails
122                 if ($LINKS > 0) {
123                         // Translate value
124                         $LINKS = TRANSLATE_COMMA($LINKS);
125
126                         // Add link
127                         $LINKS = $BASE."&amp;what=list_links&amp;u_id=".$uid."\">".$LINKS."</A>]";
128                 } // END - if
129
130                 // Add nickname
131                 if ((empty($nick)) || ($uid == $nick)) $nick = "---";
132
133                 // Sent emails
134                 $SENT = $emails_sent;
135                 if ($emails_sent > 0) $SENT = $BASE."&amp;what=email_details&amp;u_id=".$uid."\">".TRANSLATE_COMMA($emails_sent)."</A>]";
136
137                 // Calculate total points
138                 $pointsTotal = GET_TOTAL_DATA($uid, "user_points", "points")  - GET_TOTAL_DATA($uid, "user_data", "used_points");
139
140                 // Clickrate
141                 $clickRate = 0;
142                 if ($emails_received > 0) {
143                         $clickRate = $mails_confirmed / $emails_received * 100;
144                 } // END - if
145
146                 // Transfer data to array
147                 $content = array(
148                         'sw'     => $SW,
149                         'uid'    => ADMIN_USER_PROFILE_LINK($uid),
150                         'gender' => TRANSLATE_GENDER($gender),
151                         'sname'  => $sname,
152                         'fname'  => $fname,
153                         'email'  => "[<A href=\"".CREATE_EMAIL_LINK($email, "user_data")."\">".$email."</A>]",
154                         'addr'   => $IP,
155                         'ref'    => $ref,
156                         'status' => TRANSLATE_STATUS($status),
157                         'links'  => $LINKS,
158                         'alinks' => MEMBER_ACTION_LINKS($uid, $status),
159                         'nick'   => $nick,
160                         'points' => TRANSLATE_COMMA($pointsTotal),
161                         'sent'   => $SENT,
162                         'rate'   => TRANSLATE_COMMA($clickRate),
163                         'locked' => TRANSLATE_COMMA(GET_TOTAL_DATA($uid, "user_points", "locked_points"))
164                 );
165
166                 // Load row template and switch colors
167                 $OUT .= LOAD_TEMPLATE("admin_list_user_row", true, $content);
168                 $SW = 3 - $SW;
169         } // END - while
170
171         // Free memory
172         SQL_FREERESULT($result);
173
174         define('__USER_ROWS', $OUT);
175
176         // Load main template
177         LOAD_TEMPLATE("admin_list_user");
178
179         // Free some memory
180         SQL_FREERESULT($result_master);
181 } else {
182         // No one as registered so far! :-(
183         LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_ACCOUNT_NOREFS_404);
184 }
185
186 // Free memory
187 SQL_FREERESULT($result_master);
188
189 //
190 ?>