Commit be42041b authored by Ad Schellevis's avatar Ad Schellevis

(proxy) refactor proxy interface selection to use new fieldtype

parent 2865da35
......@@ -47,31 +47,6 @@ class SettingsController extends ApiControllerBase
$result = array();
if ($this->request->isGet()) {
$mdlProxy = new Proxy();
// Define array for selected interfaces
$selopt = array();
// Get ConfigObject
$configObj = Config::getInstance()->object();
// Iterate over all interfaces configuration
// TODO: replace for <interfaces> helper
foreach ($configObj->interfaces->children() as $key => $value) {
// Check if interface is enabled, if tag is <enable/> treat as enabled.
if (isset($value->enable) && $value->enable != '0') {
// Check if interface has static ip
if ($value->ipaddr != 'dhcp') {
if ($value->descr == '') {
$description = strtoupper($key); // Use interface name as description if none is given
} else {
$description = $value->descr;
}
$selopt[$key] = (string)$description; // Add Interface to selectable options.
}
}
}
$mdlProxy->forward->interfaces->setSelectOptions($selopt);
$mdlProxy->forward->ftpInterfaces->setSelectOptions($selopt);
$result['proxy'] = $mdlProxy->getNodes();
}
......
......@@ -125,8 +125,13 @@
</traffic>
</general>
<forward>
<interfaces type="CSVListField">
<interfaces type="InterfaceField">
<Required>N</Required>
<multiple>Y</multiple>
<filters>
<enable>/^(?!0).*$/</enable>
<ipaddr>/^((?!dhcp).)*$/</ipaddr>
</filters>
</interfaces>
<port type="IntegerField">
<default>3128</default>
......@@ -135,8 +140,13 @@
<ValidationMessage>Proxy port needs to be an integer value between 1 and 65535</ValidationMessage>
<Required>Y</Required>
</port>
<ftpInterfaces type="CSVListField">
<ftpInterfaces type="InterfaceField">
<Required>N</Required>
<multiple>Y</multiple>
<filters>
<enable>/^(?!0).*$/</enable>
<ipaddr>/^((?!dhcp).)*$/</ipaddr>
</filters>
</ftpInterfaces>
<ftpPort type="IntegerField">
<default>2121</default>
......
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