Functions imported, some dev-scripts added
[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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Add description as navigation point
41 ADD_DESCR("admin", __FILE__);
42
43 $SEL = 0;
44 if (isset($_POST['edit'])) {
45         // Check if at least one module is selected
46         $SEL = SELECTION_COUNT($_POST['sel']);
47         if ($SEL > 0) {
48                 // Output header
49                 $OUT = ""; $SW = 2;
50
51                 // Edit selected modules
52                 foreach ($_POST['sel'] as $id => $sel) {
53                         // Load module data
54                         $result = SQL_QUERY_ESC("SELECT module, title, locked, hidden, admin_only, mem_only FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE id=%s LIMIT 1",
55                                 array(bigintval($id)), __FILE__, __LINE__);
56                         list($mod, $title, $locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
57                         SQL_FREERESULT($result);
58
59                         // Prepare array for the template
60                         $content = array(
61                                 'sw'     => $SW,
62                                 'mod'    => $mod,
63                                 'id'     => $id,
64                                 'title'  => $title,
65                                 'locked' => ADD_SELECTION("yn", $locked, "locked", $id),
66                                 'hidden' => ADD_SELECTION("yn", $hidden, "hidden", $id),
67                                 'admin'  => ADD_SELECTION("yn", $admin , "admin" , $id),
68                                 'mem'    => ADD_SELECTION("yn", $mem   , "member", $id),
69                         );
70
71                         // Load row template
72                         $OUT .= LOAD_TEMPLATE("admin_mods_edit_row", true, $content);
73                 }
74                 define('__MODS_ROWS', $OUT);
75
76                 // Load main template
77                 LOAD_TEMPLATE("admin_mods_edit");
78         } else {
79                 // Nothing selected
80                 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('MODS_NOTHING_SELECTED'));
81
82                 // Remove maybe confusing data
83                 unset($_POST['edit']);
84                 unset($_POST['change']);
85         }
86 } elseif (isset($_POST['change'])) {
87         // Change modules
88         foreach ($_POST['sel'] as $id => $sel) {
89                 // Secure ID number
90                 $id = bigintval($id);
91
92                 // Update module
93                 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",
94                         array($_POST['title'][$id], $_POST['locked'][$id], $_POST['hidden'][$id], $_POST['admin'][$id], $_POST['member'][$id], $id),  __FILE__, __LINE__);
95         }
96
97         // Remove cache file if version matches
98         if (GET_EXT_VERSION("cache") >= "0.1.2") {
99                 if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
100         }
101
102         // Entries updated
103         LOAD_TEMPLATE("admin_settings_saved", false, getMessage('MODS_CHANGED'));
104 }
105
106 if ($SEL == 0) {
107         // Load module data (We do not need to check if there's at least one...)
108         $result = SQL_QUERY("SELECT id, module, locked, hidden, admin_only, title, mem_only, clicks
109 FROM `{!_MYSQL_PREFIX!}_mod_reg`
110 ORDER BY module", __FILE__, __LINE__);
111         $OUT = ""; $SW = 2;
112         while (list($id, $mod, $locked, $hidden, $admin, $title, $mem) = SQL_FETCHROW($result)) {
113                 // Reset title to --- if it is NULL
114                 if (empty($title)) $title = "---";
115                 if (($mod == "index") || ($mod == "login")) {
116                         // Add link to detail statistics
117                         $mod = "<strong><a href=\"{!URL!}/modules.php?module=admin&amp;what=stats_mods&amp;mod=".$mod."\">".$mod."</a></strong>";
118                 }
119
120                 // Prepare array for the template
121                 $content = array(
122                         'sw'     => $SW,
123                         'id'     => $id,
124                         'mod'    => $mod,
125                         'title'  => $title,
126                         'locked' => TRANSLATE_YESNO($locked),
127                         'hidden' => TRANSLATE_YESNO($hidden),
128                         'admin'  => TRANSLATE_YESNO($admin),
129                         'mem'    => TRANSLATE_YESNO($mem),
130                 );
131
132                 // Load row template
133                 $OUT .= LOAD_TEMPLATE("admin_mods_list_row", true, $content);
134
135                 // Switch colors
136                 $SW = 3 - $SW;
137         }
138
139         // Free memory
140         SQL_FREERESULT($result);
141         define('__MODS_ROWS', $OUT);
142
143         // Load main template
144         LOAD_TEMPLATE("admin_mods_list");
145 }
146
147 //
148 ?>