Removed deprecated 'hidden' column from mod_reg table.
[mailer.git] / inc / modules / admin / what-list_mods.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/24/2012 *
4  * ===================                          Last change: 11/24/2012 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_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 - 2013 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 = sqlQueryEscaped('SELECT
57         `id`,
58         `module`,
59         `title`,
60         `locked`,
61         `admin_only`,
62         `mem_only`
63 FROM
64         `{?_MYSQL_PREFIX?}_mod_reg`
65 WHERE
66         `id`=%s
67 LIMIT 1',
68                                 array(bigintval($id)), __FILE__, __LINE__);
69
70                         // Load data
71                         $content = sqlFetchArray($result);
72
73                         // Free result
74                         sqlFreeResult($result);
75
76                         // Prepare array for the template
77                         $content['locked']     = addSelectionBox('yn', $content['locked']    , 'locked', $id);
78                         $content['admin_only'] = addSelectionBox('yn', $content['admin_only'], 'admin' , $id);
79                         $content['mem_only']   = addSelectionBox('yn', $content['mem_only']  , 'member', $id);
80
81                         // Load row template
82                         $OUT .= loadTemplate('admin_edit_mods_row', TRUE, $content);
83                 } // END - foreach
84
85                 // Load main template
86                 loadTemplate('admin_edit_mods', FALSE, $OUT);
87         } else {
88                 // Nothing selected
89                 displayMessage('{--ADMIN_MODS_NOTHING_SELECTED--}');
90
91                 // Remove maybe confusing data
92                 unsetPostRequestElement('edit');
93                 unsetPostRequestElement('do_edit');
94         }
95 } elseif (isFormSent('do_edit')) {
96         // Init SQLs
97         initSqls();
98
99         // Change modules
100         foreach (postRequestElement('sel') as $id => $sel) {
101                 // Secure id number
102                 $id = bigintval($id);
103
104                 // Update module
105                 addSql(sqlQueryEscaped("UPDATE
106         `{?_MYSQL_PREFIX?}_mod_reg`
107 SET
108         `title`='%s',
109         `locked`='%s',
110         `admin_only`='%s',
111         `mem_only`='%s'
112 WHERE
113         `id`=%s
114 LIMIT 1",
115                         array(
116                                 postRequestElement('title', $id),
117                                 postRequestElement('locked', $id),
118                                 postRequestElement('admin', $id),
119                                 postRequestElement('member', $id),
120                                 $id
121                         ),  __FILE__, __LINE__, FALSE));
122         }
123
124         // Run all sqls
125         runFilterChain('run_sqls');
126
127         // Remove cache file if version matches
128         rebuildCache('modules', 'modules');
129
130         // Entries updated
131         displayMessage('{--ADMIN_MODS_CHANGED--}');
132 }
133
134 if (!ifPostContainsSelections()) {
135         // Load module data (We do not need to check if there's at least one...)
136         $result = sqlQuery('SELECT
137         `id`,
138         `module`,
139         `locked`,
140         `admin_only`,
141         `title`,
142         `mem_only`
143 FROM
144         `{?_MYSQL_PREFIX?}_mod_reg`
145 ORDER BY
146         `module` ASC', __FILE__, __LINE__);
147
148         $OUT = '';
149         while ($content = sqlFetchArray($result)) {
150                 // Reset title to --- if it is NULL
151                 if (($content['module'] == 'index') || ($content['module'] == 'login')) {
152                         // Add link to detail statistics
153                         $content['module'] = '<strong><a href="{%url=modules.php?module=admin&amp;what=stats_mods&amp;mod=' . $content['module'] . '%}">' . $content['module'] . '</a></strong>';
154                 } // END - if
155
156                 // Load row template
157                 $OUT .= loadTemplate('admin_list_mods_row', TRUE, $content);
158         } // END - while
159
160         // Free memory
161         sqlFreeResult($result);
162
163         // Load main template
164         loadTemplate('admin_list_mods', FALSE, $OUT);
165 } // END - if
166
167 // [EOF]
168 ?>