is missing
[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::                                                        $ *
15  * $Date::                                                            $ *
16  * $Tag:: 0.2.1-FINAL                                                 $ *
17  * $Author::                                                          $ *
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 - 2009 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')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 if (isGetRequestElementSet('userid')) {
49         // Check if the user already exists
50         $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
51                 array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
52         if (SQL_NUMROWS($result) == 1) {
53                 // Loads surname, family's name and the email address
54                 $content = SQL_FETCHARRAY($result);
55
56                 // Prepare constants
57                 // @TODO No longer needed? define('__CATS_BASE'   , "<a href=\"{?URL?}/modules.php?module=admin&amp;userid=");
58                 $content['userid']       = bigintval(getRequestElement('userid'));
59                 $content['member_links'] = generateMemberAdminActionLinks($content['userid']);
60                 $content['email']        = "<a href=\"".generateEmailLink($content['email'], 'user_data')."\">".$content['surname']." ".$content['family']."</a>";
61
62                 // Ok, list categories of this user
63                 $result_cats = SQL_QUERY("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats` ORDER BY `sort` ASC", __FILE__, __LINE__);
64
65                 if (SQL_NUMROWS($result_cats) > 0) {
66                         // List categories
67                         $cnt = 1; $OUT = ''; $SW = 2;
68                         while ($content = merge_array($content, SQL_FETCHARRAY($result_cats))) {
69                                 // Check user's selection
70                                 $result_user = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid`=%s AND `cat_id`=%s LIMIT 1",
71                                         array(bigintval(getRequestElement('userid')), bigintval($content['id'])), __FILE__, __LINE__);
72
73                                 // Set selection
74                                 $selection = "<font color=\"#ee0000\">{--NO--}</div>";
75                                 if (SQL_NUMROWS($result_user) == 1) $selection = "<font color=\"#00ee00\">{--YES--}</div>";
76
77                                 // Add more elements
78                                 $content['sw']  = $SW;
79                                 $content['cnt'] = $cnt;
80                                 $content['sel'] = $selection;
81
82                                 // Load row template and switch colors + count up
83                                 $OUT .= loadTemplate('admin_list_cats_row', true, $content);
84                                 $SW = 3 - $SW; $cnt++;
85                         } // END - while
86
87                         // Free memory
88                         SQL_FREERESULT($result);
89
90                         // Remember all rows in the array
91                         $content['rows'] = $OUT;
92
93                         // Load main template
94                         loadTemplate('admin_list_cats', false, $content);
95                 } else {
96                         // No categories selected! :-(
97                         loadTemplate('admin_list_cats_404', false, $content);
98                 }
99         } else {
100                 // User not found
101                 loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_MEMBER_404'), $content['userid']));
102         }
103
104         // Free result
105         SQL_FREERESULT($result);
106 } else {
107         // Output selection form with all confirmed user accounts listed
108         addMemberSelectionBox();
109 }
110
111 // [EOF]
112 ?>