Browse Source

Menu: Re-enable Restore Default button for menus other than default, adjust other code to work better with non-default menus.

Nate Jones 10 years ago
parent
commit
1fca2bfefb
3 changed files with 17 additions and 74 deletions
  1. 9 8
      core/menu/menu_edit.php
  2. 0 65
      core/menu/menu_restore_all_default.php
  3. 8 1
      resources/classes/menu.php

+ 9 - 8
core/menu/menu_edit.php

@@ -96,9 +96,9 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 				$sql .= "values ";
 				$sql .= "(";
 				$sql .= "'".$menu_uuid."', ";
-				$sql .= "'$menu_name', ";
-				$sql .= "'$menu_language', ";
-				$sql .= "'$menu_description' ";
+				$sql .= "'".$menu_name."', ";
+				$sql .= "'".$menu_language."', ";
+				$sql .= "'".$menu_description."' ";
 				$sql .= ")";
 				$db->exec(check_sql($sql));
 				unset($sql);
@@ -108,6 +108,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 				$menu = new menu;
 				$menu->db = $db;
 				$menu->menu_uuid = $menu_uuid;
+				$menu->menu_language = $menu_language;
 				$menu->restore();
 
 			//redirect the user back to the main menu
@@ -119,10 +120,10 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 		if ($action == "update") {
 			//update the menu
 				$sql = "update v_menus set ";
-				$sql .= "menu_name = '$menu_name', ";
-				$sql .= "menu_language = '$menu_language', ";
-				$sql .= "menu_description = '$menu_description' ";
-				$sql .= "where menu_uuid = '$menu_uuid'";
+				$sql .= "menu_name = '".$menu_name."', ";
+				$sql .= "menu_language = '".$menu_language."', ";
+				$sql .= "menu_description = '".$menu_description."' ";
+				$sql .= "where menu_uuid = '".$menu_uuid."'";
 				$db->exec(check_sql($sql));
 				unset($sql);
 
@@ -173,7 +174,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 	}
 	echo "<td width='70%' align='right'>\n";
 	echo "	<input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='menu.php'\" value='".$text['button-back']."'>\n";
-	if (permission_exists('menu_restore') && $action == "update" && $menu_uuid == 'b4750c3f-2a86-b00d-b7d0-345c14eca286') {
+	if (permission_exists('menu_restore') && $action == "update") {
 		echo "	<input type='button' class='btn' value='".$text['button-restore_default']."' onclick=\"document.location.href='menu_restore_default.php?menu_uuid=$menu_uuid&menu_language=$menu_language';\" />";
 	}
 	echo "	<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";

+ 0 - 65
core/menu/menu_restore_all_default.php

@@ -1,65 +0,0 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-include "root.php";
-require_once "resources/require.php";
-require_once "resources/check_auth.php";
-if (permission_exists('menu_restore')) {
-	//access granted
-}
-else {
-	echo "access denied";
-	return;
-}
-
-//add multi-lingual support
-	$language = new text;
-	$text = $language->get();
-
-//get the http value and set as a php variable
-	$menu_uuid = check_str($_REQUEST["menu_uuid"]);
-	$menu_language = check_str($_REQUEST["menu_language"]);
-
-//menu restore default
-	require_once "resources/classes/menu.php";
-	$menu = new menu;
-	$menu->db = $db;
-	$menu->menu_uuid = $menu_uuid;
-	$menu->menu_language = $menu_language;
-	$menu->delete();
-	$menu->restore_all();
-
-//unset the menu session variable
-	$_SESSION["menu"] = "";
-
-//unset the default template
-	$_SESSION["template_content"] = '';
-
-//show a message to the user
-	$_SESSION["message"] = $text['message-restore'];
-	header("Location: /core/menu/menu_edit.php?id=".$menu_uuid);
-	return;
-
-?>

+ 8 - 1
resources/classes/menu.php

@@ -41,7 +41,13 @@
 					$sql = "delete from v_menu_item_groups ";
 					$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
 					$sql .= "and menu_item_uuid in ( ";
-					$sql .= "	select menu_item_uuid from v_menu_items where menu_item_protected <> 'true' or menu_item_protected is null ";
+					$sql .= "	select menu_item_uuid ";
+					$sql .= "	from v_menu_items ";
+					$sql .= "	where menu_uuid = '".$this->menu_uuid."' ";
+					$sql .= "	and ( ";
+					$sql .= " 		menu_item_protected <> 'true' ";
+					$sql .= "		or menu_item_protected is null ";
+					$sql .= "	) ";
 					$sql .= ") ";
 					$db->exec(check_sql($sql));
 				//remove existing unprotected menu items
@@ -194,6 +200,7 @@
 							foreach ($sub_row['groups'] as $group) {
 								$sql = "select count(*) as count from v_menu_item_groups ";
 								$sql .= "where menu_item_uuid = '".$sub_row['uuid']."' ";
+								$sql .= "and menu_uuid = '".$this->menu_uuid."' ";
 								$sql .= "and group_name = '".$group."' ";
 								$sql .= "and group_uuid = '".$group_uuids[$group]."' ";
 								//echo $sql."<br>";