Fix in CREATE_EXTENSION_DEACTIVATION_TASK() and coding-style updated
[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 {
46         // Check if at least one module is selected
47         $SEL = SELECTION_COUNT($_POST['sel']);
48         if ($SEL > 0)
49         {
50                 // Output header
51                 $OUT = ""; $SW = 2;
52
53                 // Edit selected modules
54                 foreach ($_POST['sel'] as $id => $sel)
55                 {
56                         // Load module data
57                         $result = SQL_QUERY_ESC("SELECT module, title, locked, hidden, admin_only, mem_only FROM "._MYSQL_PREFIX."_mod_reg WHERE id=%s LIMIT 1",
58                          array(bigintval($id)), __FILE__, __LINE__);
59                         list($mod, $title, $locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
60                         SQL_FREERESULT($result);
61
62                         // Prepare array for the template
63                         $content = array(
64                                 'sw'     => $SW,
65                                 'mod'    => $mod,
66                                 'id'     => $id,
67                                 'title'  => $title,
68                                 'locked' => ADD_SELECTION("yn", $locked, "locked", $id),
69                                 'hidden' => ADD_SELECTION("yn", $hidden, "hidden", $id),
70                                 'admin'  => ADD_SELECTION("yn", $admin , "admin" , $id),
71                                 'mem'    => ADD_SELECTION("yn", $mem   , "member", $id),
72                         );
73
74                         // Load row template
75                         $OUT .= LOAD_TEMPLATE("admin_mods_edit_row", true, $content);
76                 }
77                 define('__MODS_ROWS', $OUT);
78
79                 // Load main template
80                 LOAD_TEMPLATE("admin_mods_edit");
81         }
82          else
83         {
84                 // Nothing selected
85                 LOAD_TEMPLATE("admin_settings_saved", false, MODS_NOTHING_SELECTED);
86                 OUTPUT_HTML("<br />");
87
88                 // Remove maybe confusing data
89                 unset($_POST['edit']);
90                 unset($_POST['change']);
91         }
92 }
93  elseif (isset($_POST['change']))
94 {
95         // Change modules
96         foreach ($_POST['sel'] as $id => $sel)
97         {
98                 // Secure ID number
99                 $id = bigintval($id);
100
101                 // Update module
102                 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",
103                         array($_POST['title'][$id], $_POST['locked'][$id], $_POST['hidden'][$id], $_POST['admin'][$id], $_POST['member'][$id], $id),  __FILE__, __LINE__);
104         }
105
106         // Remove cache file if version matches
107         if (GET_EXT_VERSION("cache") >= "0.1.2")
108         {
109                 if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
110         }
111
112         // Entries updated
113         LOAD_TEMPLATE("admin_settings_saved", false, MODS_CHANGED);
114         OUTPUT_HTML("<br />");
115 }
116
117 if ($SEL == 0)
118 {
119         // Load module data (We do not need to check if there's at least one...)
120         $result = SQL_QUERY("SELECT id, module, locked, hidden, admin_only, title, mem_only, clicks
121 FROM "._MYSQL_PREFIX."_mod_reg
122 ORDER BY module", __FILE__, __LINE__);
123         $OUT = ""; $SW = 2;
124         while (list($id, $mod, $locked, $hidden, $admin, $title, $mem) = SQL_FETCHROW($result))
125         {
126                 // Reset title to --- if it is NULL
127                 if (empty($title)) $title = "---";
128                 if (($mod == "index") || ($mod == "login"))
129                 {
130                         // Add link to detail statistics
131                         $mod = "<STRONG><A href=\"".URL."/modules.php?module=admin&amp;what=stats_mods&amp;mod=".$mod."\">".$mod."</A></STRONG>";
132                 }
133
134                 // Prepare array for the template
135                 $content = array(
136                         'sw'     => $SW,
137                         'id'     => $id,
138                         'mod'    => $mod,
139                         'title'  => $title,
140                         'locked' => TRANSLATE_YESNO($locked),
141                         'hidden' => TRANSLATE_YESNO($hidden),
142                         'admin'  => TRANSLATE_YESNO($admin),
143                         'mem'    => TRANSLATE_YESNO($mem),
144                 );
145
146                 // Load row template
147                 $OUT .= LOAD_TEMPLATE("admin_mods_list_row", true, $content);
148
149                 // Switch colors
150                 $SW = 3 - $SW;
151         }
152
153         // Free memory
154         SQL_FREERESULT($result);
155         define('__MODS_ROWS', $OUT);
156
157         // Load main template
158         LOAD_TEMPLATE("admin_mods_list");
159 }
160
161 //
162 ?>