A lot texts rewritten and exclamation signs removed
[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 - 2009 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')) || (!isAdmin())) {
41         die();
42 }
43
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
46
47 $SEL = 0;
48 if (isPostRequestElementSet('edit')) {
49         // Check if at least one module is selected
50         $SEL = countPostSelection();
51         if ($SEL > 0) {
52                 // Output header
53                 $OUT = ''; $SW = 2;
54
55                 // Edit selected modules
56                 foreach (postRequestElement('sel') as $id => $sel) {
57                         // Load module data
58                         $result = SQL_QUERY_ESC("SELECT module, title, locked, hidden, admin_only, mem_only FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `id`=%s LIMIT 1",
59                         array(bigintval($id)), __FILE__, __LINE__);
60                         list($mod, $title, $locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
61                         SQL_FREERESULT($result);
62
63                         // Prepare array for the template
64                         $content = array(
65                                 'sw'     => $SW,
66                                 'mod'    => $mod,
67                                 'id'     => $id,
68                                 'title'  => $title,
69                                 'locked' => addSelectionBox('yn', $locked, 'locked', $id),
70                                 'hidden' => addSelectionBox('yn', $hidden, 'hidden', $id),
71                                 'admin'  => addSelectionBox('yn', $admin , 'admin' , $id),
72                                 'mem'    => addSelectionBox('yn', $mem   , 'member', $id),
73                         );
74
75                         // Load row template
76                         $OUT .= loadTemplate('admin_mods_edit_row', true, $content);
77                 }
78
79                 // Load main template
80                 loadTemplate('admin_mods_edit', false, $OUT);
81         } else {
82                 // Nothing selected
83                 loadTemplate('admin_settings_saved', false, getMessage('MODS_NOTHING_SELECTED'));
84
85                 // Remove maybe confusing data
86                 unsetPostRequestElement('edit');
87                 unsetPostRequestElement('change');
88         }
89 } elseif (isPostRequestElementSet('change')) {
90         // Init SQLs
91         initSqls();
92
93         // Change modules
94         foreach (postRequestElement('sel') as $id => $sel) {
95                 // Secure id number
96                 $id = bigintval($id);
97
98                 // Update module
99                 addSql(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",
100                         array(
101                                 postRequestElement('title', $id),
102                                 postRequestElement('locked', $id),
103                                 postRequestElement('hidden', $id),
104                                 postRequestElement('admin', $id),
105                                 postRequestElement('member', $id),
106                                 $id
107                         ),  __FILE__, __LINE__, false));
108         }
109
110         // Run all sqls
111         runFilterChain('run_sqls');
112
113         // Remove cache file if version matches
114         if (getExtensionVersion('cache') >= '0.1.2') {
115                 if ($GLOBALS['cache_instance']->loadCacheFile('modules')) $GLOBALS['cache_instance']->removeCacheFile();
116         } // END - if
117
118         // Entries updated
119         loadTemplate('admin_settings_saved', false, getMessage('MODS_CHANGED'));
120 }
121
122 if ($SEL == 0) {
123         // Load module data (We do not need to check if there's at least one...)
124         $result = SQL_QUERY('SELECT id, module, locked, hidden, admin_only, title, mem_only
125 FROM `{?_MYSQL_PREFIX?}_mod_reg`
126 ORDER BY module', __FILE__, __LINE__);
127         $OUT = ''; $SW = 2;
128         while ($content = SQL_FETCHARRAY($result)) {
129                 // Reset title to --- if it is NULL
130                 if (empty($content['title'])) $content['title'] = '---';
131                 if (($content['module'] == 'index') || ($content['module'] == 'login')) {
132                         // Add link to detail statistics
133                         $content['module'] = "<strong><a href=\"{?URL?}/modules.php?module=admin&amp;what=stats_mods&amp;mod=".$content['module']."\">".$content['module']."</a></strong>";
134                 }
135
136                 // Prepare array for the template
137                 // @TODO Rewritings: mod->module in template
138                 $content = array(
139                         'sw'     => $SW,
140                         'id'     => $content['id'],
141                         'mod'    => $content['module'],
142                         'title'  => $content['title'],
143                         'locked' => translateYesNo($content['locked']),
144                         'hidden' => translateYesNo($content['hidden']),
145                         'admin'  => translateYesNo($content['admin_only']),
146                         'mem'    => translateYesNo($content['mem_only']),
147                 );
148
149                 // Load row template
150                 $OUT .= loadTemplate('admin_list_mods_row', true, $content);
151
152                 // Switch colors
153                 $SW = 3 - $SW;
154         }
155
156         // Free memory
157         SQL_FREERESULT($result);
158
159         // Load main template
160         loadTemplate('admin_list_mods', false, $OUT);
161 }
162
163 // [EOF]
164 ?>