More XHTML-fied and extended header added to templates
[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  * $Revision:: 856                                                    $ *
15  * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. March 2009)             $ *
16  * $Tag:: 0.2.1-FINAL                                                 $ *
17  * $Author:: stelzi                                                   $ *
18  * Needs to be in all Files and every File needs "svn propset           *
19  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
20  * -------------------------------------------------------------------- *
21  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
42         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
43         require($INC);
44 }
45
46 // Add description as navigation point
47 ADD_DESCR("admin", __FILE__);
48
49 if (REQUEST_ISSET_GET(('uid'))) {
50         // Check if the user already exists
51         $result = SQL_QUERY_ESC("SELECT surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
52                 array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
53         if (SQL_NUMROWS($result) == 1) {
54                 // Loads surname, family's name and the email address
55                 list($sname, $fname, $email) = SQL_FETCHROW($result);
56                 SQL_FREERESULT($result);
57
58                 // Prepare constants
59                 define('__CATS_BASE'   , "<a href=\"{!URL!}/modules.php?module=admin&amp;uid=");
60                 define('__UID'         , bigintval(REQUEST_GET('uid')));
61                 define('__MEMBER_LINKS', MEMBER_ACTION_LINKS(constant('__UID')));
62                 define('__EMAIL'       , "<a href=\"".CREATE_EMAIL_LINK($email, "user_data")."\">".$sname." ".$fname."</a>");
63
64                 // Ok, list categories of this user
65                 $result_cats = SQL_QUERY("SELECT id, cat FROM `{!_MYSQL_PREFIX!}_cats` ORDER BY `sort`", __FILE__, __LINE__);
66
67                 if (SQL_NUMROWS($result_cats) > 0) {
68                         // List categories
69                         $cnt = 1; $OUT = ""; $SW = 2;
70                         while ($content = SQL_FETCHARRAY($result_cats)) {
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(REQUEST_GET('uid')), bigintval($content['id'])), __FILE__, __LINE__);
74
75                                 // Set selection
76                                 $selection = "<font color=\"#ee0000\">{--NO--}</div>";
77                                 if (SQL_NUMROWS($result_user) == 1) $selection = "<font color=\"#00ee00\">{--YES--}</div>";
78
79                                 // Add more elements
80                                 $content['sw']  = $SW;
81                                 $content['cnt'] = $cnt;
82                                 $content['sel'] = $selection;
83
84                                 // Load row template and switch colors + count up
85                                 $OUT .= LOAD_TEMPLATE("admin_list_cats_row", true, $content);
86                                 $SW = 3 - $SW; $cnt++;
87                         } // END - while
88
89                         // Free memory
90                         SQL_FREERESULT($result);
91
92                         // @TODO Rewrite this constant
93                         define('__CATS_ROWS', $OUT);
94
95                         // Load main template
96                         LOAD_TEMPLATE("admin_list_cats");
97                 } else {
98                         // No categories selected! :-(
99                         LOAD_TEMPLATE("admin_list_cats_404");
100                 }
101         } else {
102                 // User not found
103                 LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('ADMIN_MEMBER_404'), constant('__UID')));
104         }
105 } else {
106         // Output selection form with all confirmed user accounts listed
107         ADD_MEMBER_SELECTION_BOX();
108 }
109
110 //
111 ?>