New extension added, more EL-rewrites, naming-convention applied:
[mailer.git] / inc / modules / admin / what-config_mods.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
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 }
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 if (isFormSent('edit')) {
49         // Check if at least one module is selected
50         if (countPostSelection() > 0) {
51                 // Output header
52                 $OUT = ''; $SW = 2;
53
54                 // Edit selected modules
55                 foreach (postRequestParameter('sel') as $id => $sel) {
56                         // Load module data
57                         // @TODO This can be moved into mysql-function.php, see checkModulePermissions() function
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
61                         // Load data
62                         $data = SQL_FETCHARRAY($result);
63
64                         // Free result
65                         SQL_FREERESULT($result);
66
67                         // Prepare array for the template
68                         $content = array(
69                                 'sw'     => $SW,
70                                 'mod'    => $data['module'],
71                                 'id'     => $id,
72                                 'title'  => $data['title'],
73                                 'locked' => addSelectionBox('yn', $data['locked']    , 'locked', $id),
74                                 'hidden' => addSelectionBox('yn', $data['hidden']    , 'hidden', $id),
75                                 'admin'  => addSelectionBox('yn', $data['admin_only'], 'admin' , $id),
76                                 'mem'    => addSelectionBox('yn', $data['mem_only']  , 'member', $id),
77                         );
78
79                         // Load row template
80                         $OUT .= loadTemplate('admin_mods_edit_row', true, $content);
81                 } // END - foreach
82
83                 // Load main template
84                 loadTemplate('admin_mods_edit', false, $OUT);
85         } else {
86                 // Nothing selected
87                 loadTemplate('admin_settings_saved', false, getMessage('MODS_NOTHING_SELECTED'));
88
89                 // Remove maybe confusing data
90                 unsetPostRequestParameter('edit');
91                 unsetPostRequestParameter('change');
92         }
93 } elseif (isFormSent('change')) {
94         // Init SQLs
95         initSqls();
96
97         // Change modules
98         foreach (postRequestParameter('sel') as $id => $sel) {
99                 // Secure id number
100                 $id = bigintval($id);
101
102                 // Update module
103                 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",
104                         array(
105                                 postRequestParameter('title', $id),
106                                 postRequestParameter('locked', $id),
107                                 postRequestParameter('hidden', $id),
108                                 postRequestParameter('admin', $id),
109                                 postRequestParameter('member', $id),
110                                 $id
111                         ),  __FILE__, __LINE__, false));
112         }
113
114         // Run all sqls
115         runFilterChain('run_sqls');
116
117         // Remove cache file if version matches
118         if (isExtensionInstalledAndNewer('cache', '0.1.2')) {
119                 if ($GLOBALS['cache_instance']->loadCacheFile('modules')) $GLOBALS['cache_instance']->removeCacheFile();
120         } // END - if
121
122         // Entries updated
123         loadTemplate('admin_settings_saved', false, getMessage('MODS_CHANGED'));
124 }
125
126 if (countPostSelection() == 0) {
127         // Load module data (We do not need to check if there's at least one...)
128         $result = SQL_QUERY('SELECT
129         `id`, `module`, `locked`, `hidden`, `admin_only`, `title`, `mem_only`
130 FROM
131         `{?_MYSQL_PREFIX?}_mod_reg`
132 ORDER BY
133         `module` ASC', __FILE__, __LINE__);
134
135         $OUT = ''; $SW = 2;
136         while ($content = SQL_FETCHARRAY($result)) {
137                 // Reset title to --- if it is NULL
138                 if (empty($content['title'])) $content['title'] = '---';
139                 if (($content['module'] == 'index') || ($content['module'] == 'login')) {
140                         // Add link to detail statistics
141                         $content['module'] = '<strong><a href="{%url=modules.php?module=admin&amp;what=stats_mods&amp;mod=' . $content['module'] . '%}">' . $content['module'] . '</a></strong>';
142                 } // END - if
143
144                 // Prepare array for the template
145                 $content['sw'] = $SW;
146
147                 // Load row template
148                 $OUT .= loadTemplate('admin_list_mods_row', true, $content);
149
150                 // Switch colors
151                 $SW = 3 - $SW;
152         } // END - while
153
154         // Free memory
155         SQL_FREERESULT($result);
156
157         // Load main template
158         loadTemplate('admin_list_mods', false, $OUT);
159 } // END - if
160
161 // [EOF]
162 ?>