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 ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Add description as navigation point
41 ADD_DESCR("admin", basename(__FILE__));
43 // Do we edit/delete/change main menus or sub menus?
44 $AND = "what = ''"; $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 OPEN_TABLE("100%", "admin_content admin_content_align", "");
57 // List all menu points and make them editable
58 OUTPUT_HTML("<br /><br /></FONT>
59 <DIV align=\"center\">");
60 if ((isset($_POST['edit'])) && ($chk > 0) && (!IS_DEMO()))
63 define('__SUB_VALUE', $SUB);
64 define('__CHK_VALUE', $chk);
65 $SW = 2; $cnt = 0; $OUT = "";
66 foreach ($_POST['sel'] as $sel=>$confirm)
71 $result = SQL_QUERY_ESC("SELECT title, action, what, descr FROM "._MYSQL_PREFIX."_member_menu WHERE ".$AND." AND id=%d LIMIT 1",
72 array(bigintval($sel)), __FILE__, __LINE__);
73 if (SQL_NUMROWS($result) == 1)
75 // Entry found so we load the stuff...
76 list($menu, $act, $wht, $descr) = SQL_FETCHROW($result);
77 SQL_FREERESULT($result);
83 'act' => ADMIN_MAKE_MENU_SELECTION("member", "act", "sel_act[".$sel."]", $act),
84 'what' => ADMIN_MAKE_MENU_SELECTION("member", "what", "sel_what[".$sel."]", $wht),
87 $OUT .= LOAD_TEMPLATE("admin_mmenu_edit_row", true, $content);
96 $OUT .= LOAD_TEMPLATE("admin_menu_404_row", true, $content);
101 define('__MENU_ROWS', $OUT);
102 define('__CNT_VALUE', $cnt);
105 LOAD_TEMPLATE("admin_mmenu_edit");
107 elseif ((isset($_POST['del'])) && ($chk > 0) && (!IS_DEMO()))
109 // Del menu entries with or without confirmation
110 define('__SUB_VALUE', $SUB);
111 define('__CHK_VALUE', $chk);
112 $SW = 2; $cnt = 0; $OUT = "";
113 foreach ($_POST['sel'] as $sel=>$confirm)
118 $result = SQL_QUERY_ESC("SELECT title FROM "._MYSQL_PREFIX."_member_menu WHERE ".$AND." AND id=%d LIMIT 1",
119 array(bigintval($sel)), __FILE__, __LINE__);
120 if (SQL_NUMROWS($result) == 1)
122 // Entry found so we load the stuff...
123 list($title) = SQL_FETCHROW($result);
124 SQL_FREERESULT($result);
130 $OUT .= LOAD_TEMPLATE("admin_mmenu_delete_row", true, $content);
139 $OUT .= LOAD_TEMPLATE("admin_menu_404_row", true, $content);
143 define('__MENU_ROWS', $OUT);
144 define('__CNT_VALUE', $cnt);
147 LOAD_TEMPLATE("admin_mmenu_delete");
149 elseif ((isset($_POST['status'])) && ($chk > 0) && (!IS_DEMO()))
151 // Change status (visible / locked)
152 define('__SUB_VALUE', $SUB);
153 define('__CHK_VALUE', $chk);
154 $SW = 2; $cnt = 0; $OUT = "";
155 foreach ($_POST['sel'] as $sel=>$confirm)
160 $result = SQL_QUERY_ESC("SELECT title, visible, locked FROM "._MYSQL_PREFIX."_member_menu WHERE ".$AND." AND id=%d LIMIT 1",
161 array(bigintval($sel)), __FILE__, __LINE__);
162 if (SQL_NUMROWS($result) == 1)
164 // Entry found so we load the stuff...
165 list($menu, $vis, $locked) = SQL_FETCHROW($result);
166 SQL_FREERESULT($result);
172 'visible' => ADD_SELECTION("yn", $vis , "visible", $sel),
173 'locked' => ADD_SELECTION("yn", $locked, "locked" , $sel),
177 $OUT .= LOAD_TEMPLATE("admin_menu_status_row", true, $content);
186 $OUT .= LOAD_TEMPLATE("admin_menu_404_row", true, $content);
191 define('__MENU_ROWS', $OUT);
192 define('__CNT_VALUE', $cnt);
194 LOAD_TEMPLATE("admin_mmenu_status");
196 elseif ((isset($_POST['ok'])) && (!IS_DEMO()))
199 foreach ($_POST['sel'] as $sel=>$menu)
202 $sel = bigintval($sel);
203 if (!empty($SUB)) $AND = "action='".$SUB."'";
204 switch ($_POST['ok'])
206 case "edit": // Edit menu
207 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_member_menu SET title='%s', action='%s', what='%s', descr='%s' WHERE ".$AND." AND id=%d LIMIT 1",
208 array($menu, $_POST['sel_act'][$sel], $_POST['sel_what'][$sel], $_POST['sel_descr'][$sel], $sel), __FILE__, __LINE__);
211 case "del": // Delete menu
212 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE ".$AND." AND id=%d LIMIT 1",
213 array($sel), __FILE__, __LINE__);
216 case "status": // Change status of menus
217 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_member_menu SET visible='%s', locked='%s' WHERE ".$AND." AND id=%d LIMIT 1",
218 array($_POST['visible'][$sel], $_POST['locked'][$sel], $sel), __FILE__, __LINE__);
225 LOAD_TEMPLATE("admin_data_saved");
229 if ((!empty($_GET['act'])) && (!empty($_GET['tid'])) && (!empty($_GET['fid'])))
232 if (!empty($_GET['w']))
234 // Sub menus selected
235 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_member_menu WHERE action='%s' AND sort='%s' LIMIT 1",
236 array(bigintval($_GET['act']), bigintval($_GET['tid'])), __FILE__, __LINE__);
237 list($tid) = SQL_FETCHROW($result);
238 SQL_FREERESULT($result);
239 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_member_menu WHERE action='%s' AND sort='%s' LIMIT 1",
240 array(bigintval($_GET['act']), bigintval($_GET['fid'])), __FILE__, __LINE__);
241 list($fid) = SQL_FETCHROW($result);
242 SQL_FREERESULT($result);
246 // Main menu selected
247 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_member_menu WHERE what='' AND sort='%s' LIMIT 1",
248 array(bigintval($_GET['tid'])), __FILE__, __LINE__);
249 list($tid) = SQL_FETCHROW($result);
250 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_member_menu WHERE what='' AND sort='%s' LIMIT 1",
251 array(bigintval($_GET['fid'])), __FILE__, __LINE__);
252 list($fid) = SQL_FETCHROW($result);
255 if ((!empty($tid)) && (!empty($fid)))
258 $result_sort = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_member_menu SET sort='%s' WHERE ".$AND." AND id=%d LIMIT 1",
259 array(bigintval($_GET['tid']), bigintval($fid)), __FILE__, __LINE__);
260 $result_sort = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_member_menu SET sort='%s' WHERE ".$AND." AND id=%d LIMIT 1",
261 array(bigintval($_GET['fid']), bigintval($tid)), __FILE__, __LINE__);
268 $result = SQL_QUERY("SELECT id, action, what, title, sort FROM "._MYSQL_PREFIX."_member_menu WHERE ".$AND." AND what != '' ORDER BY sort ASC", __FILE__, __LINE__);
273 $result = SQL_QUERY("SELECT id, action, what, title, sort FROM "._MYSQL_PREFIX."_member_menu WHERE what='' ORDER BY sort ASC", __FILE__, __LINE__);
275 $max = SQL_NUMROWS($result);
279 if (!empty($SUB)) $SUB = $SUB;
280 define('__SUB_VALUE', $SUB);
282 $SW = 2; $cnt = 0; $OUT = "";
283 while (list($id, $act, $wht, $title, $sort) = SQL_FETCHROW($result))
286 if (($sort == 0) || (($sort == 1) && (!empty($SUB))))
288 // Is highest position
289 $NAVI = "<A href=\"".URL."/modules.php?module=admin&what=memedit&sub=".$SUB."&act=".$act."&w=".$wht."&tid=".($sort+1)."&fid=".$sort."\">".LOWER."</A>";
291 elseif ($cnt == $max)
293 // Is lowest position
294 $NAVI = "<A href=\"".URL."/modules.php?module=admin&what=memedit&sub=".$SUB."&act=".$act."&w=".$wht."&tid=".($sort-1)."&fid=".$sort."\">".HIGHER."</A>";
298 // Anything else between highest and lowest
299 $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>";
301 if (empty($act)) $act = " ";
302 if (empty($wht)) $wht = " ";
303 if (empty($title)) $title = " ";
313 $OUT .= LOAD_TEMPLATE("admin_menu_overview_row", true, $content);
318 SQL_FREERESULT($result);
319 define('__MENU_ROWS', $OUT);
320 LOAD_TEMPLATE("admin_mmenu_overview");
324 // Menu entries are missing... (???)
325 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NO_MENUS_FOUND);
328 OUTPUT_HTML("</DIV>");