More language constants rewritten ({--LANGUAGE--} is for constants)
[mailer.git] / inc / modules / admin / what-list_cats.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 01/27/2004 *
4  * ================                             Last change: 07/13/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_cats.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : List selected categories from users              *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Ausgewaehlte Kategorien eines Mitgliedes         *
12  *                     auflisten                                        *
13  * -------------------------------------------------------------------- *
14  *                                                                      *
15  * -------------------------------------------------------------------- *
16  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
17  * For more information visit: http://www.mxchange.org                  *
18  *                                                                      *
19  * This program is free software; you can redistribute it and/or modify *
20  * it under the terms of the GNU General Public License as published by *
21  * the Free Software Foundation; either version 2 of the License, or    *
22  * (at your option) any later version.                                  *
23  *                                                                      *
24  * This program is distributed in the hope that it will be useful,      *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
27  * GNU General Public License for more details.                         *
28  *                                                                      *
29  * You should have received a copy of the GNU General Public License    *
30  * along with this program; if not, write to the Free Software          *
31  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
32  * MA  02110-1301  USA                                                  *
33  ************************************************************************/
34
35 // Some security stuff...
36 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 // Add description as navigation point
42 ADD_DESCR("admin", __FILE__);
43
44 if (!empty($_GET['u_id'])) {
45         // Check if the user already exists
46         $result = SQL_QUERY_ESC("SELECT surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
47          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
48         if (SQL_NUMROWS($result) == 1) {
49                 // Loads surname, family's name and the email address
50                 list($sname, $fname, $email) = SQL_FETCHROW($result);
51                 SQL_FREERESULT($result);
52
53                 // Prepare constants
54                 define('__CATS_BASE'   , "<a href=\"{!URL!}/modules.php?module=admin&amp;u_id=");
55                 define('__UID'         , bigintval($_GET['u_id']));
56                 define('__MEMBER_LINKS', MEMBER_ACTION_LINKS(__UID));
57                 define('__EMAIL'       , "<a href=\"".CREATE_EMAIL_LINK($email, "user_data")."\">".$sname." ".$fname."</a>");
58
59                 // Ok, list categories of this user
60                 $result_cats = SQL_QUERY("SELECT id, cat FROM `{!_MYSQL_PREFIX!}_cats` ORDER BY `sort`", __FILE__, __LINE__);
61
62                 if (SQL_NUMROWS($result_cats) > 0) {
63                         // List categories
64                         $cnt = "1"; $SW = 2; $OUT = "";
65                         while (list($cid, $cat) = SQL_FETCHROW($result_cats)) {
66                                 // Check user's selection
67                                 $result_user = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE userid=%s AND cat_id=%s LIMIT 1",
68                                  array(bigintval($_GET['u_id']), bigintval($cid)), __FILE__, __LINE__);
69
70                                 // Set selection
71                                 $SELECTED = "<font color=\"red\">{--NO--}</div>";
72                                 if (SQL_NUMROWS($result_user) == 1) $SELECTED = "<font color=\"green\">{--YES--}</div>";
73
74                                 // Prepare array for the row template
75                                 $content = array(
76                                         'sw'  => $SW,
77                                         'cnt' => $cnt,
78                                         'cat' => $cat,
79                                         'sel' => $SELECTED,
80                                 );
81
82                                 // Load row template and switch colors + count up
83                                 $OUT .= LOAD_TEMPLATE("admin_list_cats_row", true, $content);
84                                 $SW = 3 - $SW; $cnt++;
85                         }
86
87                         // Free memory
88                         SQL_FREERESULT($result);
89                         define('__CATS_ROWS', $OUT);
90
91                         // Load main template
92                         LOAD_TEMPLATE("admin_list_cats");
93                 } else {
94                         // No categories selected! :-(
95                         LOAD_TEMPLATE("admin_list_cats_404");
96                 }
97         } else {
98                 // User not found
99                 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_MEMBER_404_1.__UID.ADMIN_MEMBER_404_2);
100         }
101 } else {
102         // Output selection form with all confirmed user accounts listed
103         ADD_MEMBER_SELECTION_BOX();
104 }
105
106 //
107 ?>