From 2379d88b524df68f9116f65015ecb08cb99b381e Mon Sep 17 00:00:00 2001 From: mcfly Date: Sun, 18 Nov 2007 03:05:06 +0000 Subject: [PATCH] No longer resetting menus to location 0 (inactive) if that menu area does not appear in the currently selected site theme, this will allow for better dynamic placement of menus if the theme can change (user_theme). Also cleaned up a few queries and removed all extract() calls --- e107_admin/menus.php | 66 +++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 483416831..ffc5027a1 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $ -| $Revision: 1.5 $ -| $Date: 2007-11-18 02:20:59 $ +| $Revision: 1.6 $ +| $Date: 2007-11-18 03:05:06 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -170,28 +170,25 @@ if ($menu_act == 'config') { if ($menu_act == "adv") { require_once(e_HANDLER."userclass_class.php"); - $sql->db_Select("menus", "*", "menu_id='$id' "); + $sql->db_Select("menus", "*", "menu_id=".$id); $row = $sql->db_Fetch(); - extract($row); - $listtype = substr($menu_pages, 0, 1); - $menu_pages = substr($menu_pages, 2); + $listtype = substr($row['menu_pages'], 0, 1); + $menu_pages = substr($row['menu_pages'], 2); $menu_pages = str_replace("|", "\n", $menu_pages); $text = "
-
\n +
- + ".MENLAN_4." ". - r_userclass('menu_class', $menu_class, "off", "public,member,guest,admin,main,classes,nobody")." + r_userclass('menu_class', $row['menu_class'], "off", "public,member,guest,admin,main,classes,nobody")."

"; - $checked = ($listtype == 1) ? " checked='checked' " : - ""; + $checked = ($listtype == 1) ? " checked='checked' " : ""; $text .= " ".MENLAN_26."
"; - $checked = ($listtype == 2) ? " checked='checked' " : - ""; + $checked = ($listtype == 2) ? " checked='checked' " : ""; $text .= " ".MENLAN_27."

".MENLAN_28."
"; $text .= ""; $text .= " @@ -203,7 +200,7 @@ if ($menu_act == "adv") {
"; - $caption = MENLAN_7." ".$menu_name; + $caption = MENLAN_7." ".$row['menu_name']; $ns->tablerender($caption, $text); } @@ -314,32 +311,28 @@ if (strpos(e_QUERY, 'configure') === FALSE) } } -if (!is_object($sql2)) $sql2 = new db; // Shouldn't be needed -foreach ($menu_areas as $menu_act) { - if ($sql->db_Select("menus", "*", "menu_location='$menu_act' ORDER BY menu_order ASC")) { - $c = 1; - while ($row = $sql->db_Fetch()) { - extract($row); - $sql2->db_Update("menus", "menu_order='$c' WHERE menu_id='$menu_id' "); - $c++; + //Reorder all menus into 1...x order + if (!is_object($sql2)) $sql2 = new db; // Shouldn't be needed + foreach ($menu_areas as $menu_act) { + if ($sql->db_Select("menus", "menu_id", "menu_location={$menu_act} ORDER BY menu_order ASC")) { + $c = 1; + while ($row = $sql->db_Fetch()) { + $sql2->db_Update("menus", "menu_order={$c} WHERE menu_id=".$row['menu_id']); + $c++; + } } } -} - -$sql->db_Select("menus", "*", "menu_path NOT REGEXP('[0-9]+') "); -while (list($menu_id, $menu_name, $menu_location, $menu_order) = $sql->db_Fetch()) -{ - if (stristr($menustr, $menu_name) === FALSE) + + $sql->db_Select("menus", "*", "menu_path NOT REGEXP('[0-9]+') "); + while (list($menu_id, $menu_name, $menu_location, $menu_order) = $sql->db_Fetch()) { - $sql2->db_Delete("menus", "menu_name='$menu_name'"); - $message .= "".MENLAN_11." - ".$menu_name."
"; + if (stristr($menustr, $menu_name) === FALSE) + { + $sql2->db_Delete("menus", "menu_name='$menu_name'"); + $message .= "".MENLAN_11." - ".$menu_name."
"; + } } } -} - -foreach ($menu_areas as $menu_act) { - $menus_sql[] = "menu_location!='".$menu_act."'"; -} if ($message != "") { @@ -354,9 +347,6 @@ if (strpos(e_QUERY, 'configure') === FALSE) else { - $menus_query = implode(' && ', $menus_sql); - $sql->db_Update("menus", "menu_location='0', menu_order='0' WHERE ".$menus_query); - if ($CUSTOMPAGES) { if ($menu_act != 'adv') { $text = "