9ec6e996f07e36e11e519371153aaca6e6f95c80
[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 ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
37 {
38         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
39         require($INC);
40 }
41 // Add description as navigation point
42 ADD_DESCR("admin", basename(__FILE__));
43
44 OPEN_TABLE("100%", "admin_content admin_content_align", "");
45 if (!empty($_GET['u_id']))
46 {
47         // Check if the user already exists
48         $result = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
49          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
50         if (SQL_NUMROWS($result) == 1)
51         {
52                 // Loads surname, family's name and the email address
53                 list($sname, $fname, $email) = SQL_FETCHROW($result);
54                 SQL_FREERESULT($result);
55
56                 // Prepare constants
57                 define('__CATS_BASE'   , "<A href=\"".URL."/modules.php?module=admin&amp;u_id=");
58                 define('__UID'         , bigintval($_GET['u_id']));
59                 define('__MEMBER_LINKS', MEMBER_ACTION_LINKS(__UID));
60                 define('__EMAIL'       , "<A href=\"".CREATE_EMAIL_LINK($email, "user_data")."\">".$sname." ".$fname."</A>");
61
62                 // Ok, list categories of this user
63                 $result_cats = SQL_QUERY("SELECT id, cat FROM "._MYSQL_PREFIX."_cats ORDER BY sort", __FILE__, __LINE__);
64
65                 if (SQL_NUMROWS($result_cats) > 0)
66                 {
67                         // List categories
68                         $cnt = "1"; $SW = 2; $OUT = "";
69                         while (list($cid, $cat) = SQL_FETCHROW($result_cats))
70                         {
71                                 // Check user's selection
72                                 $result_user = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_cats WHERE userid=%s AND cat_id=%s LIMIT 1",
73                                  array(bigintval($_GET['u_id']), bigintval($cid)), __FILE__, __LINE__);
74
75                                 // Set selection
76                                 $SELECTED = "<FONT color=\"red\">".NO."</FONT>";
77                                 if (SQL_NUMROWS($result_user) == 1) $SELECTED = "<FONT color=\"green\">".YES."</FONT>";
78
79                                 // Prepare array for the row template
80                                 $content = array(
81                                         'sw'  => $SW,
82                                         'cnt' => $cnt,
83                                         'cat' => $cat,
84                                         'sel' => $SELECTED,
85                                 );
86
87                                 // Load row template and switch colors + count up
88                                 $OUT .= LOAD_TEMPLATE("admin_list_cats_row", true, $content);
89                                 $SW = 3 - $SW; $cnt++;
90                         }
91
92                         // Free memory
93                         SQL_FREERESULT($result);
94                         define('__CATS_ROWS', $OUT);
95
96                         // Load main template
97                         LOAD_TEMPLATE("admin_list_cats");
98                 }
99                  else
100                 {
101                         // No categories selected! :-(
102                         LOAD_TEMPLATE("admin_list_cats_404");
103                 }
104         }
105          else
106         {
107                 // User not found
108                 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_MEMBER_404_1.__UID.ADMIN_MEMBER_404_2);
109         }
110 }
111  else
112 {
113         // Output selection form with all confirmed user accounts listed
114         ADD_MEMBER_SELECTION_BOX();
115 }
116 CLOSE_TABLE();
117 //
118 ?>