Project

General

Profile

« Previous | Next » 

Revision 1cbe86f0

Added by Ermal LUÇI over 14 years ago

Fixes #1207. Allow renaming a limiter. Also prevent a limiter to be deleted if it is referenced in filter rules.

View differences:

etc/inc/shaper.inc
2877 2877
		}
2878 2878

  
2879 2879
	function ReadConfig(&$q) {
2880
           	$this->SetQname($q['name']);
2880
		if (!empty($q['name']) && !empty($q['newname']) && $q['name'] != $q['newname']) {
2881
			$this->SetQname($q['newname']);
2882
		} else if (!empty($q['newname'])) {
2883
			$this->SetQname($q['newname']);
2884
		} else {
2885
			$this->SetQname($q['name']);
2886
		}
2881 2887
		$this->SetNumber($q['number']);
2882 2888
		if (isset($q['bandwidth']) && $q['bandwidth'] <> "") { 
2883 2889
			$this->SetBandwidth($q['bandwidth']);
......
2983 2989
                $form .= "</td></tr>";
2984 2990
		$form .= "<tr><td valign=\"center\" class=\"vncellreq\"><br><span class=\"vexpl\">Name</span></td>";
2985 2991
		$form .= "<td class=\"vncellreq\">";
2986
		$form .= "<input type=\"text\" id=\"name\" name=\"name\" value=\"";
2992
		$form .= "<input type=\"text\" id=\"newname\" name=\"newname\" value=\"";
2993
		$form .= $this->GetQname()."\">";
2994
		$form .= "<input type=\"hidden\" id=\"name\" name=\"name\" value=\"";
2987 2995
		$form .= $this->GetQname()."\">";
2988 2996
		$form .= "</td></tr>";
2989 2997
		$form .= "<tr><td valign=\"center\" class=\"vncellreq\">Bandwidth";
......
3164 3172
        }		
3165 3173

  
3166 3174
	function ReadConfig(&$q) {
3167
          	$this->SetQname($q['name']);
3175
		if (!empty($q['name']) && !empty($q['newname']) && $q['name'] != $q['newname']) {
3176
			$this->SetQname($q['newname']);
3177
		} else if (!empty($q['newname'])) {
3178
			$this->SetQname($q['newname']);
3179
		} else {
3180
			$this->SetQname($q['name']);
3181
		}
3168 3182
		$this->SetNumber($q['number']);
3169 3183
		if (isset($q['qlimit']) && $q['qlimit'] <> "")
3170 3184
       		       	$this->SetQlimit($q['qlimit']);
......
3236 3250
                $form .= "</td></tr>";
3237 3251
		$form .= "<tr><td valign=\"center\" class=\"vncellreq\"><br><span class=\"vexpl\">Name</span></td>";
3238 3252
		$form .= "<td class=\"vncellreq\">";
3239
		$form .= "<input type=\"text\" id=\"name\" name=\"name\" value=\"";
3253
		$form .= "<input type=\"text\" id=\"newname\" name=\"newname\" value=\"";
3254
		$form .= $this->GetQname()."\">";
3255
		$form .= "<input type=\"hidden\" id=\"name\" name=\"name\" value=\"";
3240 3256
		$form .= $this->GetQname()."\">";
3241 3257
		$form .= "</td></tr>";
3242 3258
		$form .= "<tr><td valign=\"center\" class=\"vncellreq\">Mask</td>";
usr/local/www/firewall_shaper_vinterface.php
71 71
if ($_POST) {
72 72
	if ($_POST['name'])
73 73
        	$qname = htmlspecialchars(trim($_POST['name']));
74
	else if ($_POST['newname'])
75
        	$qname = htmlspecialchars(trim($_POST['name']));
74 76
        if ($_POST['pipe'])
75 77
        	$pipe = htmlspecialchars(trim($_POST['pipe']));
76 78
	else
77
		$pipe = htmlspecialchars(trim($_POST['name']));
79
		$pipe = htmlspecialchars(trim($qname));
78 80
	if ($_POST['parentqueue'])
79 81
		$parentqueue = htmlspecialchars(trim($_POST['parentqueue']));
80 82
}
......
94 96
	switch ($action) {
95 97
	case "delete":
96 98
			if ($queue) {
97
				$queue->delete_queue();
98
				write_config();
99
				mark_subsystem_dirty('shaper');
99
				if (is_array($config['filter']['rule'])) {
100
					foreach ($config['filter']['rule'] as $rule) {
101
						if ($rule['dnpipe'] == $queue->GetNumber() || $rule['pdnpipe'] == $queue->GetNumber())
102
							$input_errors[] = gettext("This pipe/queue is referenced in filter rules, please remove references from there before deleteing.");
103
					}
104
				}
105
				if (!$input_errors) {
106
					$queue->delete_queue();
107
					write_config();
108
					mark_subsystem_dirty('shaper');
109
					header("Location: firewall_shaper_vinterface.php");
110
					exit;
111
				}
112
				$output_form .= $queue->build_form();
113
			} else {
114
				$input_errors[] = gettext("No queue with name {$qname} was found!");
115
				$output_form .= "<p class=\"pgtitle\">" . $dn_default_shaper_msg."</p>";
116
				$dontshow = true;
100 117
			}
101
			header("Location: firewall_shaper_vinterface.php");
102
			exit;
103 118
		break;
104 119
	case "resetall":
105 120
			foreach ($dummynet_pipe_list as $dn)

Also available in: Unified diff