83ea7425cef2015b6458be206db38f638f003193
[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 referral                  *
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 {
60         // List only persons w
61         $whereStatement = " WHERE refid='0' AND family LIKE '".$_GET['letter']."%'";
62 }
63 if ($_GET['sortby'] == "family_name") $_GET['sortby'] = "family";
64 $SQL = "SELECT userid, gender, surname, family, email, REMOTE_ADDR, refid, status".$MORE." FROM "._MYSQL_PREFIX."_user_data".$whereStatement." ORDER BY ".$_GET['sortby'];
65 $result_master = SQL_QUERY($SQL, __FILE__, __LINE__);
66
67 // Calculate page count (0.5 fixes a bug with page count)
68 $PAGES = round(SQL_NUMROWS($result_master) / $_CONFIG['user_limit'] + 0.5);
69
70 if (empty($_GET['page']))   $_GET['page']   = "1";
71 if (empty($_GET['offset'])) $_GET['offset'] = $_CONFIG['user_limit'];
72
73 // Add limitation to SQL string and run him again
74 $SQL .= " LIMIT ".($_GET['offset'] * $_GET['page'] - $_GET['offset']).", ".$_GET['offset'];
75 $result = SQL_QUERY($SQL, __FILE__, __LINE__);
76
77 $result_user = SQL_QUERY("SELECT emails_sent FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED'", __FILE__, __LINE__);
78 $user_count = SQL_NUMROWS($result_user);
79 SQL_FREERESULT($result_user);
80
81 if (SQL_NUMROWS($result_master) > 0)
82 {
83         // Free memory
84         SQL_FREERESULT($result_master);
85
86         // We have some (new?) registrations!
87         define('__COLSPAN1'  , $colspan);
88         define('__COLSPAN2'  , ($colspan + 2));
89         define('__USER_CNT'  , $user_count);
90         define('__ALPHA_SORT', alpha($_GET['sortby'], $colspan, true));
91         define('__SORT_LINKS', SortLinks($_GET['letter'], $_GET['sortby'], $colspan, true));
92         if ($PAGES > 1)
93         {
94                 define('__PAGE_NAV', ADD_PAGENAV($PAGES, $_CONFIG['user_limit'], true, $colspan, true));
95         }
96          else
97         {
98                 // No page navigation is required
99                 define('__PAGE_NAV', "");
100         }
101
102         // Column with nickname when nickname extension is present
103         if (EXT_IS_ACTIVE("nickname"))
104         {
105                 // Nickname extension found
106                 define('__NICKNAME_TH', "  <TD class=\"admin_title bottom2\" align=\"center\">".NICKNAME."</TD>");
107         }
108          else
109         {
110                 // Not found
111                 define('__NICKNAME_TH', "");
112         }
113
114         $SW = 2; $OUT = "";
115         while (list($uid, $gender, $sname, $fname, $email, $IP, $ref, $status, $nick) = SQL_FETCHROW($result))
116         {
117                 if ($ref > 0) $ref = ADMIN_USER_PROFILE_LINK($ref);
118                 $LINKS = TRANSLATE_COMMA(GET_TOTAL_DATA($uid, "user_links", "id", "userid", true));
119                 if ($LINKS > 0) $LINKS = $BASE."&amp;what=list_links&amp;u_id=".$uid."\">".$LINKS."</A>";
120
121                 // Add nickname
122                 if ((empty($nick)) || ($uid == $nick)) $nick = "---";
123
124                 // Transfer data to array
125                 $content = array(
126                         'sw'     => $SW,
127                         'uid'    => ADMIN_USER_PROFILE_LINK($uid),
128                         'gender' => TRANSLATE_GENDER($gender),
129                         'sname'  => $sname,
130                         'fname'  => $fname,
131                         'email'  => "<A href=\"".CREATE_EMAIL_LINK($email, "user_data")."\">".$email."</A>",
132                         'addr'   => $IP,
133                         'ref'    => $ref,
134                         'status' => TRANSLATE_STATUS($status),
135                         'links'  => $LINKS,
136                         'nick'   => $nick
137                 );
138
139                 // Load row template and switch colors
140                 $OUT .= LOAD_TEMPLATE("admin_list_user_row", true, $content);
141                 $SW = 3 - $SW;
142         }
143
144         // Free memory
145         SQL_FREERESULT($result);
146
147         define('__USER_ROWS', $OUT);
148
149         // Load main template
150         LOAD_TEMPLATE("admin_list_user");
151
152         // Free some memory
153         SQL_FREERESULT($result_master);
154 }
155  else
156 {
157         // No one as registered so far! :-(
158         LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_ACCOUNT_NOREFS_404);
159 }
160
161 //
162 ?>