From 3e152b19a9948f950728043e3e8987f2eaa2d361 Mon Sep 17 00:00:00 2001 From: BillyBoy0823 Date: Sun, 12 May 2013 20:14:51 -0400 Subject: [PATCH 1/3] Clean up of menu installs. Menu news_months_menu has 2 entries. One was set to location that conflicted with Login Menu. Both using location 1, Order 1. Changes; Removed unneeded news_months_menu Set other one to location 1, order 2 to remove conflict. Tested - Viewed DB after install - was OK. --- e107_core/xml/default_install.xml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/e107_core/xml/default_install.xml b/e107_core/xml/default_install.xml index 20673cfb3..60a1d53c4 100644 --- a/e107_core/xml/default_install.xml +++ b/e107_core/xml/default_install.xml @@ -872,8 +872,8 @@ City, State, Country 14 news_months_menu - 0 - 0 + 1 + 2 0 news/ @@ -946,17 +946,6 @@ City, State, Country - - 21 - news_months_menu - 1 - 1 - 0 - - news/ - - - From f8f241da5dd3d6a066a84fee40e071168d8889b4 Mon Sep 17 00:00:00 2001 From: BillyBoy0823 Date: Mon, 13 May 2013 00:32:11 -0400 Subject: [PATCH 2/3] Fixes issues with menu munipulation. 1. Scans all Menu's, All locations, And reorders them properly. - Does all in case a menu was deleted from system, but active in another area. 2. When activating. Increments so proper order number is assigned. 3. Fixed deactivating. It properly reorders remaining menus - And removes duplicates, if a loc-0, order-0 exists. - Also gives Admin log info - Menu Name, Last Location, Last Order. MenuID --- e107_handlers/menumanager_class.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/e107_handlers/menumanager_class.php b/e107_handlers/menumanager_class.php index 890035415..8fd282b6f 100644 --- a/e107_handlers/menumanager_class.php +++ b/e107_handlers/menumanager_class.php @@ -406,9 +406,12 @@ class e_menuManager { //Reorder all menus into 1...x order if (!is_object($sql2)) $sql2 = new db; // Shouldn't be needed - foreach ($this->menu_areas as $menu_act) + if (!is_object($sql3)) $sql3 = new db; + + $location_count = $sql3->select("menus", "menu_location", "menu_location>0 GROUP BY menu_location"); + while ($location_count) { - if ($sql->select("menus", "menu_id", "menu_location={$menu_act} ORDER BY menu_order ASC")) + if ($sql->select("menus", "menu_id", "menu_location={$location_count} ORDER BY menu_order ASC")) { $c = 1; while ($row = $sql->fetch()) @@ -417,8 +420,8 @@ class e_menuManager { $c++; } } + $location_count--; } - $sql->select("menus", "*", "menu_path NOT REGEXP('[0-9]+') "); while (list($menu_id, $menu_name, $menu_location, $menu_order) = $sql->fetch(MYSQL_NUM)) { @@ -598,6 +601,7 @@ class e_menuManager { $location = $this->menuActivateLoc; $menu_count = $sql->count("menus", "(*)", " WHERE menu_location=".$location." AND menu_layout = '".$this->dbLayout."' "); + $menu_count++; // Need to add 1 to create NEW order number. foreach($this->menuActivateIds as $sel_mens) { @@ -784,19 +788,20 @@ class e_menuManager { { // Get current menu name global $admin_log; $sql = e107::getDb(); + $sql2 = e107::getDb(); //echo "FOUND= ".$this->menuId; $error = false; - if($sql->gen('SELECT menu_name FROM #menus WHERE menu_id = '.$this->menuId.' LIMIT 1')) + if($sql->gen('SELECT menu_name, menu_location, menu_order FROM #menus WHERE menu_id = '.$this->menuId.' LIMIT 1')) { - $row = $sql->fetch(); + //Check to see if there is already a menu with location = 0 (to maintain BC) - if($sql->select('menus', 'menu_id', "menu_name='{$row['menu_name']}' AND menu_location = 0 AND menu_layout ='".$this->dbLayout."' LIMIT 1")) + if($sql2->select('menus', 'menu_id', "menu_name='{$row['menu_name']}' AND menu_location = 0 AND menu_layout ='".$this->dbLayout."' LIMIT 1")) { //menu_location=0 already exists, we can just delete this record - if(!$sql->db_Delete('menus', 'menu_id='.$this->menuId)) + if(!$sql2->db_Delete('menus', 'menu_id='.$this->menuId)) { $message = "Deletion Failed"; $error = true; @@ -805,15 +810,15 @@ class e_menuManager { else { //menu_location=0 does NOT exist, let's just convert this to it - if(!$sql->db_Update("menus", "menu_location=0, menu_order=0, menu_class=0, menu_pages='' WHERE menu_id=".$this->menuId)) + if(!$sql2->db_Update("menus", "menu_location=0, menu_order=0, menu_class=0, menu_pages='' WHERE menu_id=".$this->menuId)) { $message = "FAILED"; $error = true; } } - //Move all other menus up - $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_location={$location} AND menu_order > {$position} AND menu_layout = '".$this->dbLayout."' "); - $admin_log->log_event('MENU_04',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$position.'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,''); + //Move all menus up (reduces order number) that have a higher menu order number than one deactivated, in the selected location. + $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_location={$row['menu_location']} AND menu_order > {$row['menu_order']} AND menu_layout = '".$this->dbLayout."' "); + $admin_log->log_event('MENU_04',$row['menu_name'].'[!br!]'.$row['menu_location'].'[!br!]'.$row['menu_order'].'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,''); } else { From ccba27380861e35405db2644971cc0c419be0e8c Mon Sep 17 00:00:00 2001 From: BillyBoy0823 Date: Mon, 13 May 2013 00:34:21 -0400 Subject: [PATCH 3/3] Call to menuScanMenus() Not needed. It's already called by menuModify() in menumanager_class.php So it runs 2x on each page load. --- e107_admin/menus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 1f3f0398f..b7615b0b1 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -1133,7 +1133,7 @@ if($_POST) //BC - configure and dot delimiter deprecated if (!isset($_GET['configure'])) { - $men->menuScanMenus(); +// $men->menuScanMenus(); // - Runs 2x - Is already called by menuModify() in menumanager_class.php $text = $men->menuRenderMessage(); $text .= $men->menuSelectLayout(); $text .= $men->menuVisibilityOptions();