Commit 66f8411d authored by Ad Schellevis's avatar Ad Schellevis

(trafficshaper) automatic number new rules behind existing ones

parent 1bf389a1
...@@ -363,6 +363,7 @@ class SettingsController extends ApiControllerBase ...@@ -363,6 +363,7 @@ class SettingsController extends ApiControllerBase
} else { } else {
// generate new node, but don't save to disc // generate new node, but don't save to disc
$node = $mdlShaper->rules->rule->add() ; $node = $mdlShaper->rules->rule->add() ;
$node->sequence = $mdlShaper->getMaxRuleSequence() + 10;
return array("rule" => $node->getNodes()); return array("rule" => $node->getNodes());
} }
return array(); return array();
......
...@@ -120,4 +120,19 @@ class TrafficShaper extends BaseModel ...@@ -120,4 +120,19 @@ class TrafficShaper extends BaseModel
$queue->number = $newId; $queue->number = $newId;
return $queue; return $queue;
} }
/**
* retrieve last generated rule sequence number
*/
public function getMaxRuleSequence()
{
$seq = 0;
foreach ($this->rules->rule->__items as $rule) {
if ((string)$rule->sequence > $seq) {
$seq = (string)$rule->sequence;
}
}
return $seq;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment