Some dublicated braces removed, some fixed (broken: update depencies got registered...
[mailer.git] / inc / modules / admin / what-config_mods.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 08/27/2004 *
4  * ================                             Last change: 08/27/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-config_mods.php                             *
8  * -------------------------------------------------------------------- *
9  * Short description : Module configuration                             *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Modul-Konfiguration                              *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
42         require($INC);
43 }
44
45 // Add description as navigation point
46 ADD_DESCR("admin", __FILE__);
47
48 $SEL = 0;
49 if (REQUEST_ISSET_POST('edit')) {
50         // Check if at least one module is selected
51         $SEL = SELECTION_COUNT(REQUEST_POST('sel'));
52         if ($SEL > 0) {
53                 // Output header
54                 $OUT = ""; $SW = 2;
55
56                 // Edit selected modules
57                 foreach (REQUEST_POST('sel') as $id => $sel) {
58                         // Load module data
59                         $result = SQL_QUERY_ESC("SELECT module, title, locked, hidden, admin_only, mem_only FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE id=%s LIMIT 1",
60                                 array(bigintval($id)), __FILE__, __LINE__);
61                         list($mod, $title, $locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
62                         SQL_FREERESULT($result);
63
64                         // Prepare array for the template
65                         $content = array(
66                                 'sw'     => $SW,
67                                 'mod'    => $mod,
68                                 'id'     => $id,
69                                 'title'  => $title,
70                                 'locked' => ADD_SELECTION("yn", $locked, "locked", $id),
71                                 'hidden' => ADD_SELECTION("yn", $hidden, "hidden", $id),
72                                 'admin'  => ADD_SELECTION("yn", $admin , "admin" , $id),
73                                 'mem'    => ADD_SELECTION("yn", $mem   , "member", $id),
74                         );
75
76                         // Load row template
77                         $OUT .= LOAD_TEMPLATE("admin_mods_edit_row", true, $content);
78                 }
79                 define('__MODS_ROWS', $OUT);
80
81                 // Load main template
82                 LOAD_TEMPLATE("admin_mods_edit");
83         } else {
84                 // Nothing selected
85                 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('MODS_NOTHING_SELECTED'));
86
87                 // Remove maybe confusing data
88                 REQUEST_UNSET_POST('edit');
89                 REQUEST_UNSET_POST('change');
90         }
91 } elseif (REQUEST_ISSET_POST('change')) {
92         // Init SQLs
93         INIT_SQLS();
94
95         // Change modules
96         foreach (REQUEST_POST('sel') as $id => $sel) {
97                 // Secure ID number
98                 $id = bigintval($id);
99
100                 // Update module
101                 ADD_SQL(SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET `title`='%s', `locked`='%s', hidden='%s', admin_only='%s', mem_only='%s' WHERE id=%s LIMIT 1",
102                         array(
103                                 REQUEST_POST('title', $id),
104                                 REQUEST_POST('locked', $id),
105                                 REQUEST_POST('hidden', $id),
106                                 REQUEST_POST('admin', $id),
107                                 REQUEST_POST('member', $id),
108                                 $id
109                         ),  __FILE__, __LINE__, false));
110         }
111
112         // Run all sqls
113         runFilterChain('run_sqls');
114
115         // Remove cache file if version matches
116         if (GET_EXT_VERSION("cache") >= "0.1.2") {
117                 if ($GLOBALS['cache_instance']->loadCacheFile("modreg")) $GLOBALS['cache_instance']->destroyCacheFile();
118         } // END - if
119
120         // Entries updated
121         LOAD_TEMPLATE("admin_settings_saved", false, getMessage('MODS_CHANGED'));
122 }
123
124 if ($SEL == 0) {
125         // Load module data (We do not need to check if there's at least one...)
126         $result = SQL_QUERY("SELECT id, module, locked, hidden, admin_only, title, mem_only
127 FROM `{!_MYSQL_PREFIX!}_mod_reg`
128 ORDER BY module", __FILE__, __LINE__);
129         $OUT = ""; $SW = 2;
130         while ($content = SQL_FETCHARRAY($result)) {
131                 // Reset title to --- if it is NULL
132                 if (empty($content['title'])) $content['title'] = "---";
133                 if (($content['module'] == "index") || ($content['module'] == "login")) {
134                         // Add link to detail statistics
135                         $content['module'] = "<strong><a href=\"{!URL!}/modules.php?module=admin&amp;what=stats_mods&amp;mod=".$content['module']."\">".$content['module']."</a></strong>";
136                 }
137
138                 // Prepare array for the template
139                 // @TODO Rewritings: mod->module in template
140                 $content = array(
141                         'sw'     => $SW,
142                         'id'     => $content['id'],
143                         'mod'    => $content['module'],
144                         'title'  => $content['title'],
145                         'locked' => TRANSLATE_YESNO($content['locked']),
146                         'hidden' => TRANSLATE_YESNO($content['hidden']),
147                         'admin'  => TRANSLATE_YESNO($content['admin_only']),
148                         'mem'    => TRANSLATE_YESNO($content['mem_only']),
149                 );
150
151                 // Load row template
152                 $OUT .= LOAD_TEMPLATE("admin_mods_list_row", true, $content);
153
154                 // Switch colors
155                 $SW = 3 - $SW;
156         }
157
158         // Free memory
159         SQL_FREERESULT($result);
160
161         // @TODO Rewrite this constant
162         define('__MODS_ROWS', $OUT);
163
164         // Load main template
165         LOAD_TEMPLATE("admin_mods_list");
166 }
167
168 //
169 ?>