More rewrites/templates swapped out:
[mailer.git] / inc / modules / admin / what-list_cats.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
23  * For more information visit: http://www.mxchange.org                  *
24  *                                                                      *
25  * This program is free software; you can redistribute it and/or modify *
26  * it under the terms of the GNU General Public License as published by *
27  * the Free Software Foundation; either version 2 of the License, or    *
28  * (at your option) any later version.                                  *
29  *                                                                      *
30  * This program is distributed in the hope that it will be useful,      *
31  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
32  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
33  * GNU General Public License for more details.                         *
34  *                                                                      *
35  * You should have received a copy of the GNU General Public License    *
36  * along with this program; if not, write to the Free Software          *
37  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
38  * MA  02110-1301  USA                                                  *
39  ************************************************************************/
40
41 // Some security stuff...
42 if ((!defined('__SECURITY')) || (!isAdmin())) {
43         die();
44 } // END - if
45
46 // Add description as navigation point
47 addMenuDescription('admin', __FILE__);
48
49 if (isGetRequestParameterSet('userid')) {
50         // Check if the user already exists
51         if (fetchUserData(getRequestParameter('userid'))) {
52                 // Loads surname, family's name and the email address
53                 $content = getUserDataArray();
54
55                 // Prepare constants
56                 // @TODO No longer needed? define('__CATS_BASE'   , '<a href="{%url=modules.php?module=admin&amp;userid=');
57                 $content['userid']       = bigintval(getRequestParameter('userid'));
58                 $content['member_links'] = generateMemberAdminActionLinks($content['userid']);
59                 $content['email']        = '<a href="' . generateEmailLink($content['email'], 'user_data') . '">' . $content['surname'] . ' ' . $content['family'] . '</a>';
60
61                 // Ok, list categories of this user
62                 $result_cats = SQL_QUERY("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats` ORDER BY `sort` ASC", __FILE__, __LINE__);
63
64                 if (SQL_NUMROWS($result_cats) > 0) {
65                         // List categories
66                         $cnt = 1; $OUT = ''; $SW = 2;
67                         while ($row = SQL_FETCHARRAY($result_cats)) {
68                                 // Merge both arrays
69                                 $content = merge_array($content, $row);
70
71                                 // Check user's selection
72                                 // @TODO Rewrite this to countSum.....() function
73                                 $result_user = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid`=%s AND `cat_id`=%s LIMIT 1",
74                                         array(bigintval(getRequestParameter('userid')), bigintval($content['id'])), __FILE__, __LINE__);
75
76                                 // Set selection
77                                 $selection = '<font color="#ee0000">{--NO--}</div>';
78                                 if (SQL_NUMROWS($result_user) == 1) $selection = '<font color="#00ee00">{--YES--}</div>';
79
80                                 // Add more elements
81                                 $content['sw']  = $SW;
82                                 $content['cnt'] = $cnt;
83                                 $content['sel'] = $selection;
84
85                                 // Load row template and switch colors + count up
86                                 $OUT .= loadTemplate('admin_list_cats_row', true, $content);
87                                 $SW = 3 - $SW; $cnt++;
88                         } // END - while
89
90                         // Free memory
91                         SQL_FREERESULT($result_cats);
92
93                         // Remember all rows in the array
94                         $content['rows'] = $OUT;
95
96                         // Load main template
97                         loadTemplate('admin_list_cats', false, $content);
98                 } else {
99                         // No categories selected! :-(
100                         loadTemplate('admin_list_cats_404', false, $content);
101                 }
102         } else {
103                 // User not found
104                 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_MEMBER_404', $content['userid']));
105         }
106 } else {
107         // Output selection form with all confirmed user accounts listed
108         addMemberSelectionBox();
109 }
110
111 // [EOF]
112 ?>