Naming convention applied, new API function introduced:
[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 (ifPostContainsSelections()) {
51                 // Output header
52                 $OUT = '';
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 `id`, `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                         $content = SQL_FETCHARRAY($result);
63
64                         // Free result
65                         SQL_FREERESULT($result);
66
67                         // Prepare array for the template
68                         $content['locked']     => addSelectionBox('yn', $content['locked']    , 'locked', $id);
69                         $content['hidden']     => addSelectionBox('yn', $content['hidden']    , 'hidden', $id);
70                         $content['admin_only'] => addSelectionBox('yn', $content['admin_only'], 'admin' , $id);
71                         $content['mem_only']   => addSelectionBox('yn', $content['mem_only']  , 'member', $id);
72
73                         // Load row template
74                         $OUT .= loadTemplate('admin_edit_mods_row', true, $content
75                 } // END - foreach
76
77                 // Load main template
78                 loadTemplate('admin_edit_mods', false, $OUT);
79         } else {
80                 // Nothing selected
81                 loadTemplate('admin_settings_saved', false, '{--ADMIN_MODS_NOTHING_SELECTED--}');
82
83                 // Remove maybe confusing data
84                 unsetPostRequestParameter('edit');
85                 unsetPostRequestParameter('change');
86         }
87 } elseif (isFormSent('change')) {
88         // Init SQLs
89         initSqls();
90
91         // Change modules
92         foreach (postRequestParameter('sel') as $id => $sel) {
93                 // Secure id number
94                 $id = bigintval($id);
95
96                 // Update module
97                 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",
98                         array(
99                                 postRequestParameter('title', $id),
100                                 postRequestParameter('locked', $id),
101                                 postRequestParameter('hidden', $id),
102                                 postRequestParameter('admin', $id),
103                                 postRequestParameter('member', $id),
104                                 $id
105                         ),  __FILE__, __LINE__, false));
106         }
107
108         // Run all sqls
109         runFilterChain('run_sqls');
110
111         // Remove cache file if version matches
112         if (isExtensionInstalledAndNewer('cache', '0.1.2')) {
113                 if ($GLOBALS['cache_instance']->loadCacheFile('modules')) $GLOBALS['cache_instance']->removeCacheFile();
114         } // END - if
115
116         // Entries updated
117         loadTemplate('admin_settings_saved', false, '{--ADMIN_MODS_CHANGED--}');
118 }
119
120 if (!ifPostContainsSelections()) {
121         // Load module data (We do not need to check if there's at least one...)
122         $result = SQL_QUERY('SELECT
123         `id`, `module`, `locked`, `hidden`, `admin_only`, `title`, `mem_only`
124 FROM
125         `{?_MYSQL_PREFIX?}_mod_reg`
126 ORDER BY
127         `module` ASC', __FILE__, __LINE__);
128
129         $OUT = '';
130         while ($content = SQL_FETCHARRAY($result)) {
131                 // Reset title to --- if it is NULL
132                 if (($content['module'] == 'index') || ($content['module'] == 'login')) {
133                         // Add link to detail statistics
134                         $content['module'] = '<strong><a href="{%url=modules.php?module=admin&amp;what=stats_mods&amp;mod=' . $content['module'] . '%}">' . $content['module'] . '</a></strong>';
135                 } // END - if
136
137                 // Load row template
138                 $OUT .= loadTemplate('admin_list_mods_row', true, $content);
139         } // END - while
140
141         // Free memory
142         SQL_FREERESULT($result);
143
144         // Load main template
145         loadTemplate('admin_list_mods', false, $OUT);
146 } // END - if
147
148 // [EOF]
149 ?>