Author: jfthomps
Date: Mon Dec 15 19:44:31 2014
New Revision: 1645734
URL: http://svn.apache.org/r1645734
Log:
VCL-174 - NAT - support for sites that have small IP address ranges
siteconfig.php:
-modified generalOptions: changed id of table from 'dashboard' to 'siteconfig';
added NAT port range section
-modified TimeVariable::getHTML: added maxHeight of 250 for affiliation Select
object
-modified GlobalSingleVariable::getHTML and
GlobalSingleVariable::AJupdateAllSettings: added case for type 'textarea'
-added GlobalSingleVariable::validateValue
-added NATportRange class: extends GlobalSingleVariable
states.php: added 'natportrange' to $actions['classmapping']
siteconfig.js:
-modified generalSiteConfigCB: added check for data.items.contid and
data.items.savecont existing before setting it
-added natPortRange class: extends GlobalSingleVariable class
Modified:
vcl/trunk/web/.ht-inc/siteconfig.php
vcl/trunk/web/.ht-inc/states.php
vcl/trunk/web/js/siteconfig.js
Modified: vcl/trunk/web/.ht-inc/siteconfig.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/siteconfig.php?rev=1645734&r1=1645733&r2=1645734&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/siteconfig.php (original)
+++ vcl/trunk/web/.ht-inc/siteconfig.php Mon Dec 15 19:44:31 2014
@@ -62,7 +62,7 @@ function generalOptions($globalopts) {
$h .= timeSourceHTML($globalopts);
# ------ end full width ---------
- $h .= "<table summary=\"\" id=dashboard>\n";
+ $h .= "<table summary=\"\" id=siteconfig>\n";
$h .= "<tr>\n";
# -------- left column ---------
@@ -97,6 +97,10 @@ function generalOptions($globalopts) {
$h .= $obj->getHTML($globalopts);
$obj = new generalEndNotice2();
$h .= $obj->getHTML($globalopts);
+ if($globalopts) {
+ $obj = new NATportRange();
+ $h .= $obj->getHTML();
+ }
$h .= "</td>\n";
# -------- end right column --------
@@ -317,7 +321,8 @@ class TimeVariable {
$newval = $this->defaultval;
if($this->scale60)
$newval = (int)($newval / 60);
- $h .= selectInputHTML('', $affils,
"{$this->domidbase}newaffilid", "dojoType=\"dijit.form.Select\"");
+ $h .= selectInputHTML('', $affils,
"{$this->domidbase}newaffilid",
+ "dojoType=\"dijit.form.Select\"
maxHeight=\"250\"");
$h .= "<input dojoType=\"dijit.form.NumberSpinner\" ";
$h .= "required=\"1\" ";
$h .= "style=\"width: 70px;\" ";
@@ -801,7 +806,7 @@ class generalEndNotice2 extends TimeVari
///
/// \class GlobalSingleVariable
///
-/// \brief base class for global number variables
+/// \brief base class for global single value variables
///
////////////////////////////////////////////////////////////////////////////////
class GlobalSingleVariable {
@@ -858,6 +863,9 @@ class GlobalSingleVariable {
$extra = array('checked' => 'checked');
$h .= labeledFormItem($this->domidbase,
$this->label, 'check', '', 1, 1, '', '', $extra);
break;
+ case 'textarea':
+ $h .= labeledFormItem($this->domidbase,
$this->label, 'textarea', '', 1, $val, '', '', '', '120px');
+ break;
default:
$h .= labeledFormItem($this->domidbase,
$this->label, 'text', '', 1, $val);
break;
@@ -917,6 +925,19 @@ class GlobalSingleVariable {
'errmsg' => _("unsupported type"));
sendJSON($arr);
return;
+ case 'textarea':
+ $newval = processInputVar('newval',
ARG_STRING);
+ if(! $this->validateValue($newval)) {
+ $arr = array('status' => 'failed',
+ 'msgid' =>
"{$this->domidbase}msg",
+ 'btn' =>
"{$this->domidbase}btn",
+ 'errmsg' => _("Invalid
value submitted"));
+ if(isset($this->invalidvaluemsg))
+ $arr['errmsg'] =
$this->invalidvaluemsg;
+ sendJSON($arr);
+ return;
+ }
+ break;
default:
$arr = array('status' => 'failed',
'msgid' => "{$this->domidbase}msg",
@@ -932,13 +953,25 @@ class GlobalSingleVariable {
'msg' => $this->updatemsg);
sendJSON($arr);
}
+
+
////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// \fn validateValue($val)
+ ///
+ /// \brief validates that a new value is okay; should be implemented in
+ /// inheriting class
+ ///
+
////////////////////////////////////////////////////////////////////////////////
+ function validateValue($val) {
+ return 1;
+ }
}
////////////////////////////////////////////////////////////////////////////////
///
/// \class userPasswordLength
///
-/// \brief extends TimeVariable class to implement general_end_notice_second
+/// \brief extends GlobalSingleVariable class to implement userPasswordLength
///
////////////////////////////////////////////////////////////////////////////////
class userPasswordLength extends GlobalSingleVariable {
@@ -969,7 +1002,8 @@ class userPasswordLength extends GlobalS
///
/// \class userPasswordSpecialChar
///
-/// \brief extends TimeVariable class to implement general_end_notice_second
+/// \brief extends GlobalSingleVariable class to implement
+/// userPasswordSpecialChar
///
////////////////////////////////////////////////////////////////////////////////
class userPasswordSpecialChar extends GlobalSingleVariable {
@@ -994,4 +1028,52 @@ class userPasswordSpecialChar extends Gl
}
}
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \class NATportRange
+///
+/// \brief extends GlobalSingleVariable class to implement NATportRange
+///
+////////////////////////////////////////////////////////////////////////////////
+class NATportRange extends GlobalSingleVariable {
+
/////////////////////////////////////////////////////////////////////////////
+ ///
+ /// \fn __construct()
+ ///
+ /// \brief class construstor
+ ///
+
/////////////////////////////////////////////////////////////////////////////
+ function __construct() {
+ parent::__construct();
+ $this->name = _('NAT Port Ranges');
+ $this->key = 'nat_port_range';
+ $this->label = _("NAT Port Ranges");
+ $this->desc = _("Port ranges available for use on NAT servers.
Type of port (TCP/UDP) is not specified. List ranges one per line (ex:
10000-20000).");
+ $this->domidbase = 'natportrange';
+ $this->basecdata['obj'] = $this;
+ $this->jsname = 'natPortRange';
+ $this->defaultval = '10000-60000';
+ $this->type = 'textarea';
+ $this->invalidvaluemsg = _("Invalid value submitted. Must be
numeric ranges of ports of the form 10000-20000, one per line.");
+ }
+
+
////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// \fn validateValue($val)
+ ///
+ /// \brief validates that a new value is okay
+ ///
+
////////////////////////////////////////////////////////////////////////////////
+ function validateValue($val) {
+ $vals = explode("\n", $val);
+ foreach($vals as $testval) {
+ if(! preg_match('/^(\d+)-(\d+)$/', $testval, $matches))
+ return 0;
+ if($matches[1] >= $matches[2])
+ return 0;
+ }
+ return 1;
+ }
+}
+
?>
Modified: vcl/trunk/web/.ht-inc/states.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/states.php?rev=1645734&r1=1645733&r2=1645734&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/states.php (original)
+++ vcl/trunk/web/.ht-inc/states.php Mon Dec 15 19:44:31 2014
@@ -554,6 +554,7 @@ $actions['classmapping']['generalendnoti
$actions['classmapping']['generalendnotice2'] = 'siteconfig';
$actions['classmapping']['userpasswordlength'] = 'siteconfig';
$actions['classmapping']['userpasswordspecialchar'] = 'siteconfig';
+$actions['classmapping']['natportrange'] = 'siteconfig';
# resource
$actions['mode']['resource'] = "resource";
Modified: vcl/trunk/web/js/siteconfig.js
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/js/siteconfig.js?rev=1645734&r1=1645733&r2=1645734&view=diff
==============================================================================
--- vcl/trunk/web/js/siteconfig.js (original)
+++ vcl/trunk/web/js/siteconfig.js Mon Dec 15 19:44:31 2014
@@ -20,7 +20,8 @@ function generalSiteConfigCB(data, ioArg
dojo.removeClass(data.items.msgid, 'cfgerror');
dojo.addClass(data.items.msgid, 'cfgsuccess');
dojo.byId(data.items.msgid).innerHTML = data.items.msg;
- dojo.byId(data.items.contid).value = data.items.savecont;
+ if('contid' in data.items && 'savecont' in data.items)
+ dojo.byId(data.items.contid).value =
data.items.savecont;
if('btn' in data.items)
dijit.byId(data.items.btn).set('disabled', false);
if('extrafunc' in data.items) {
@@ -241,3 +242,10 @@ function userPasswordSpecialChar() {
}
userPasswordSpecialChar.prototype = new GlobalSingleVariable();
var userPasswordSpecialChar = new userPasswordSpecialChar();
+
+function natPortRange() {
+ GlobalSingleVariable.apply(this, Array.prototype.slice.call(arguments));
+ this.domidbase = 'natportrange';
+}
+natPortRange.prototype = new GlobalSingleVariable();
+var natPortRange = new natPortRange();