db87cf99b9b0f15a065dedf761c63c530a5119f8
[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  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 if (isFormSent('edit')) {
47         // Check if at least one module is selected
48         if (ifPostContainsSelections()) {
49                 // Output header
50                 $OUT = '';
51
52                 // Edit selected modules
53                 foreach (postRequestElement('sel') as $id => $sel) {
54                         // Load module data
55                         // @TODO This can be moved into mysql-function.php, see checkModulePermissions() function
56                         $result = SQL_QUERY_ESC("SELECT `id`, `module`, `title`, `locked`, `hidden`, `admin_only`, `mem_only` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `id`=%s LIMIT 1",
57                                 array(bigintval($id)), __FILE__, __LINE__);
58
59                         // Load data
60                         $content = SQL_FETCHARRAY($result);
61
62                         // Free result
63                         SQL_FREERESULT($result);
64
65                         // Prepare array for the template
66                         $content['locked']     = addSelectionBox('yn', $content['locked']    , 'locked', $id);
67                         $content['hidden']     = addSelectionBox('yn', $content['hidden']    , 'hidden', $id);
68                         $content['admin_only'] = addSelectionBox('yn', $content['admin_only'], 'admin' , $id);
69                         $content['mem_only']   = addSelectionBox('yn', $content['mem_only']  , 'member', $id);
70
71                         // Load row template
72                         $OUT .= loadTemplate('admin_edit_mods_row', TRUE, $content);
73                 } // END - foreach
74
75                 // Load main template
76                 loadTemplate('admin_edit_mods', FALSE, $OUT);
77         } else {
78                 // Nothing selected
79                 displayMessage('{--ADMIN_MODS_NOTHING_SELECTED--}');
80
81                 // Remove maybe confusing data
82                 unsetPostRequestElement('edit');
83                 unsetPostRequestElement('do_edit');
84         }
85 } elseif (isFormSent('do_edit')) {
86         // Init SQLs
87         initSqls();
88
89         // Change modules
90         foreach (postRequestElement('sel') as $id => $sel) {
91                 // Secure id number
92                 $id = bigintval($id);
93
94                 // Update module
95                 addSql(SQL_QUERY_ESC("UPDATE
96         `{?_MYSQL_PREFIX?}_mod_reg`
97 SET
98         `title`='%s',
99         `locked`='%s',
100         `hidden`='%s',
101         `admin_only`='%s',
102         `mem_only`='%s'
103 WHERE
104         `id`=%s
105 LIMIT 1",
106                         array(
107                                 postRequestElement('title', $id),
108                                 postRequestElement('locked', $id),
109                                 postRequestElement('hidden', $id),
110                                 postRequestElement('admin', $id),
111                                 postRequestElement('member', $id),
112                                 $id
113                         ),  __FILE__, __LINE__, FALSE));
114         }
115
116         // Run all sqls
117         runFilterChain('run_sqls');
118
119         // Remove cache file if version matches
120         rebuildCache('modules', 'modules');
121
122         // Entries updated
123         displayMessage('{--ADMIN_MODS_CHANGED--}');
124 }
125
126 if (!ifPostContainsSelections()) {
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 = '';
136         while ($content = SQL_FETCHARRAY($result)) {
137                 // Reset title to --- if it is NULL
138                 if (($content['module'] == 'index') || ($content['module'] == 'login')) {
139                         // Add link to detail statistics
140                         $content['module'] = '<strong><a href="{%url=modules.php?module=admin&amp;what=stats_mods&amp;mod=' . $content['module'] . '%}">' . $content['module'] . '</a></strong>';
141                 } // END - if
142
143                 // Load row template
144                 $OUT .= loadTemplate('admin_list_mods_row', TRUE, $content);
145         } // END - while
146
147         // Free memory
148         SQL_FREERESULT($result);
149
150         // Load main template
151         loadTemplate('admin_list_mods', FALSE, $OUT);
152 } // END - if
153
154 // [EOF]
155 ?>