2 /************************************************************************
3 * MXChange v0.2.1 Start: 09/28/2003 *
4 * =============== Last change: 05/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-memedit.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Edit member's menu *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Editieren Sie das Menue fuer Ihre Mitglieder *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
32 ************************************************************************/
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Add description as navigation point
41 ADD_DESCR("admin", __FILE__);
43 // Do we edit/delete/change main menus or sub menus?
44 $AND = "(what = '' OR what IS NULL)"; $SUB = "";
46 if (!empty($_GET['sub']))
48 $AND = sprintf("action='%s'", SQL_ESCAPE($_GET['sub']));
49 $SUB = SQL_ESCAPE($_GET['sub']);
52 // Get count of (maybe) selected menu points
54 if (!empty($_POST['sel'])) $chk = SELECTION_COUNT($_POST['sel']);
56 // List all menu points and make them editable
57 if ((isset($_POST['edit'])) && ($chk > 0) && (!IS_DEMO()))
60 define('__SUB_VALUE', $SUB);
61 define('__CHK_VALUE', $chk);
62 $SW = 2; $cnt = 0; $OUT = "";
63 foreach ($_POST['sel'] as $sel => $confirm)
68 $result = SQL_QUERY_ESC("SELECT title, action, what FROM "._MYSQL_PREFIX."_member_menu WHERE ".$AND." AND id=%s LIMIT 1",
69 array(bigintval($sel)), __FILE__, __LINE__);
70 if (SQL_NUMROWS($result) == 1)
72 // Entry found so we load the stuff...
73 list($menu, $act, $wht, $descr) = SQL_FETCHROW($result);
74 SQL_FREERESULT($result);
80 'act' => ADMIN_MAKE_MENU_SELECTION("member", "act", "sel_act[".$sel."]", $act),
81 'what' => ADMIN_MAKE_MENU_SELECTION("member", "what", "sel_what[".$sel."]", $wht),
84 $OUT .= LOAD_TEMPLATE("admin_mmenu_edit_row", true, $content);
93 $OUT .= LOAD_TEMPLATE("admin_menu_404_row", true, $content);
98 define('__MENU_ROWS', $OUT);
99 define('__CNT_VALUE', $cnt);
102 LOAD_TEMPLATE("admin_mmenu_edit");
104 elseif ((isset($_POST['del'])) && ($chk > 0) && (!IS_DEMO()))
106 // Del menu entries with or without confirmation
107 define('__SUB_VALUE', $SUB);
108 define('__CHK_VALUE', $chk);
109 $SW = 2; $cnt = 0; $OUT = "";
110 foreach ($_POST['sel'] as $sel => $confirm)
115 $result = SQL_QUERY_ESC("SELECT title FROM "._MYSQL_PREFIX."_member_menu WHERE ".$AND." AND id=%s LIMIT 1",
116 array(bigintval($sel)), __FILE__, __LINE__);
117 if (SQL_NUMROWS($result) == 1)
119 // Entry found so we load the stuff...
120 list($title) = SQL_FETCHROW($result);
121 SQL_FREERESULT($result);
127 $OUT .= LOAD_TEMPLATE("admin_mmenu_delete_row", true, $content);
136 $OUT .= LOAD_TEMPLATE("admin_menu_404_row", true, $content);
140 define('__MENU_ROWS', $OUT);
141 define('__CNT_VALUE', $cnt);
144 LOAD_TEMPLATE("admin_mmenu_delete");
146 elseif ((isset($_POST['status'])) && ($chk > 0) && (!IS_DEMO()))
148 // Change status (visible / locked)
149 define('__SUB_VALUE', $SUB);
150 define('__CHK_VALUE', $chk);
151 $SW = 2; $cnt = 0; $OUT = "";
152 foreach ($_POST['sel'] as $sel => $confirm)
157 $result = SQL_QUERY_ESC("SELECT title, visible, locked FROM "._MYSQL_PREFIX."_member_menu WHERE ".$AND." AND id=%s LIMIT 1",
158 array(bigintval($sel)), __FILE__, __LINE__);
159 if (SQL_NUMROWS($result) == 1)
161 // Entry found so we load the stuff...
162 list($menu, $vis, $locked) = SQL_FETCHROW($result);
163 SQL_FREERESULT($result);
169 'visible' => ADD_SELECTION("yn", $vis , "visible", $sel),
170 'locked' => ADD_SELECTION("yn", $locked, "locked" , $sel),
174 $OUT .= LOAD_TEMPLATE("admin_menu_status_row", true, $content);
183 $OUT .= LOAD_TEMPLATE("admin_menu_404_row", true, $content);
188 define('__MENU_ROWS', $OUT);
189 define('__CNT_VALUE', $cnt);
191 LOAD_TEMPLATE("admin_mmenu_status");
193 elseif ((isset($_POST['ok'])) && (!IS_DEMO()))
196 foreach ($_POST['sel'] as $sel => $menu)
198 $AND = "(what = '' OR what IS NULL)";
199 $sel = bigintval($sel);
200 if (!empty($SUB)) $AND = "action='".$SUB."'";
201 switch ($_POST['ok'])
203 case "edit": // Edit menu
204 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_member_menu SET title='%s', action='%s', what='%s' WHERE ".$AND." AND id=%s LIMIT 1",
205 array($menu, $_POST['sel_act'][$sel], $_POST['sel_what'][$sel], $sel), __FILE__, __LINE__);
208 case "del": // Delete menu
209 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE ".$AND." AND id=%s LIMIT 1",
210 array($sel), __FILE__, __LINE__);
213 case "status": // Change status of menus
214 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_member_menu SET visible='%s', locked='%s' WHERE ".$AND." AND id=%s LIMIT 1",
215 array($_POST['visible'][$sel], $_POST['locked'][$sel], $sel), __FILE__, __LINE__);
222 LOAD_TEMPLATE("admin_data_saved");
226 if ((!empty($_GET['act'])) && (!empty($_GET['tid'])) && (!empty($_GET['fid'])))
229 if (!empty($_GET['w']))
231 // Sub menus selected
232 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_member_menu WHERE action='%s' AND sort='%s' LIMIT 1",
233 array(bigintval($_GET['act']), bigintval($_GET['tid'])), __FILE__, __LINE__);
234 list($tid) = SQL_FETCHROW($result);
235 SQL_FREERESULT($result);
236 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_member_menu WHERE action='%s' AND sort='%s' LIMIT 1",
237 array(bigintval($_GET['act']), bigintval($_GET['fid'])), __FILE__, __LINE__);
238 list($fid) = SQL_FETCHROW($result);
239 SQL_FREERESULT($result);
243 // Main menu selected
244 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_member_menu WHERE (what='' OR what IS NULL) AND sort='%s' LIMIT 1",
245 array(bigintval($_GET['tid'])), __FILE__, __LINE__);
246 list($tid) = SQL_FETCHROW($result);
247 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_member_menu WHERE (what='' OR what IS NULL) AND sort='%s' LIMIT 1",
248 array(bigintval($_GET['fid'])), __FILE__, __LINE__);
249 list($fid) = SQL_FETCHROW($result);
252 if ((!empty($tid)) && (!empty($fid)))
255 $result_sort = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_member_menu SET sort='%s' WHERE ".$AND." AND id=%s LIMIT 1",
256 array(bigintval($_GET['tid']), bigintval($fid)), __FILE__, __LINE__);
257 $result_sort = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_member_menu SET sort='%s' WHERE ".$AND." AND id=%s LIMIT 1",
258 array(bigintval($_GET['fid']), bigintval($tid)), __FILE__, __LINE__);
265 $result = SQL_QUERY("SELECT id, action, what, title, sort FROM "._MYSQL_PREFIX."_member_menu WHERE ".$AND." AND what != '' AND what IS NOT NULL ORDER BY sort ASC", __FILE__, __LINE__);
270 $result = SQL_QUERY("SELECT id, action, what, title, sort FROM "._MYSQL_PREFIX."_member_menu WHERE (what='' OR what IS NULL) ORDER BY sort ASC", __FILE__, __LINE__);
272 $max = SQL_NUMROWS($result);
276 if (!empty($SUB)) $SUB = $SUB;
277 define('__SUB_VALUE', $SUB);
279 $SW = 2; $cnt = 0; $OUT = "";
280 while (list($id, $act, $wht, $title, $sort) = SQL_FETCHROW($result))
283 if (($sort == 0) || (($sort == 1) && (!empty($SUB))))
285 // Is highest position
286 $NAVI = "<A href=\"".URL."/modules.php?module=admin&what=memedit&sub=".$SUB."&act=".$act."&w=".$wht."&tid=".($sort+1)."&fid=".$sort."\">".LOWER."</A>";
288 elseif ($cnt == $max)
290 // Is lowest position
291 $NAVI = "<A href=\"".URL."/modules.php?module=admin&what=memedit&sub=".$SUB."&act=".$act."&w=".$wht."&tid=".($sort-1)."&fid=".$sort."\">".HIGHER."</A>";
295 // Anything else between highest and lowest
296 $NAVI = "<A href=\"".URL."/modules.php?module=admin&what=memedit&sub=".$SUB."&act=".$act."&w=".$wht."&tid=".($sort-1)."&fid=".$sort."\">".HIGHER."</A>/<A href=\"".URL."/modules.php?module=admin&what=memedit&sub=".$SUB."&act=".$act."&w=".$wht."&tid=".($sort+1)."&fid=".$sort."\">".LOWER."</A>";
298 if (empty($act)) $act = " ";
299 if (empty($wht)) $wht = " ";
300 if (empty($title)) $title = " ";
310 $OUT .= LOAD_TEMPLATE("admin_menu_overview_row", true, $content);
315 SQL_FREERESULT($result);
316 define('__MENU_ROWS', $OUT);
317 LOAD_TEMPLATE("admin_mmenu_overview");
321 // Menu entries are missing... (???)
322 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NO_MENUS_FOUND);