Author: jfthomps
Date: Tue Nov 11 20:24:54 2014
New Revision: 1638354
URL: http://svn.apache.org/r1638354
Log:
VCL-797 - system admin setting for randomly generated passwords
siteconfig.php
-modified generalOptions: added calls to userPasswordLength and
userPasswordSpeciakChar; okay to move these around, I'm not set on their
location on the page
-added GlobalSingleVariable class
-added userPasswordLength and userPasswordSpecialChar as inheriting classes of
GlobalSingleVariable
states.php: added userpasswordlength and userpasswordspecialchar entries in
$actions['classmapping']
utils.php: modified getDojoHTML: added dijit.form.CheckBox to siteconfig dojo
includes
siteconfig.js
-added GlobalSingleVariable class
-added userPasswordLength and userPasswordSpecialChar as inheriting classes of
GlobalSingleVariable
Modified:
vcl/trunk/web/.ht-inc/siteconfig.php
vcl/trunk/web/.ht-inc/states.php
vcl/trunk/web/.ht-inc/utils.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=1638354&r1=1638353&r2=1638354&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/siteconfig.php (original)
+++ vcl/trunk/web/.ht-inc/siteconfig.php Tue Nov 11 20:24:54 2014
@@ -75,6 +75,12 @@ function generalOptions($globalopts) {
$h .= $obj->getHTML($globalopts);
$obj = new reconnect();
$h .= $obj->getHTML($globalopts);
+ if($globalopts) {
+ $obj = new userPasswordLength();
+ $h .= $obj->getHTML();
+ $obj = new userPasswordSpecialChar();
+ $h .= $obj->getHTML();
+ }
$h .= "</td>\n";
# -------- end left column ---------
@@ -783,4 +789,201 @@ class generalEndNotice2 extends TimeVari
}
}
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \class GlobalSingleVariable
+///
+/// \brief base class for global number variables
+///
+////////////////////////////////////////////////////////////////////////////////
+class GlobalSingleVariable {
+ var $name;
+ var $key;
+ var $label;
+ var $desc;
+ var $domidbase;
+ var $basecdata;
+ var $jsname;
+ var $defaultval;
+ var $updatemsg;
+ var $type;
+
+
/////////////////////////////////////////////////////////////////////////////
+ ///
+ /// \fn __construct()
+ ///
+ /// \brief class construstor
+ ///
+
/////////////////////////////////////////////////////////////////////////////
+ function __construct() {
+ $this->basecdata = array('obj' => $this);
+ $this->updatemsg = _("New value saved");
+ $this->label = $this->name;
+ $type = 'text';
+ }
+
+
////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// \fn getHTML()
+ ///
+ /// \return string of HTML
+ ///
+ /// \brief generates HTML for setting numeric variables
+ ///
+
////////////////////////////////////////////////////////////////////////////////
+ function getHTML() {
+ global $user;
+ $val = getVariable($this->key, $this->defaultval);
+ $h = "<div class=\"configwidget\" style=\"width: 100%;\">\n";
+ $h .= "<h3>{$this->name}</h3>\n";
+ $h .= "<span class=\"siteconfigdesc\">\n";
+ $h .= $this->desc;
+ $h .= "<br><br></span>\n";
+ switch($this->type) {
+ case 'numeric':
+ $extra = array('smallDelta' => 1, 'largeDelta'
=> 10);
+ $h .= labeledFormItem($this->domidbase,
$this->label, 'spinner', "{min:{$this->minval}, max:{$this->maxval}}", 1, $val,
'', '', $extra);
+ break;
+ case 'boolean':
+ $extra = array();
+ if($val == 1)
+ $extra = array('checked' => 'checked');
+ $h .= labeledFormItem($this->domidbase,
$this->label, 'check', '', 1, 1, '', '', $extra);
+ break;
+ default:
+ $h .= labeledFormItem($this->domidbase,
$this->label, 'text', '', 1, $val);
+ break;
+ }
+ $h .= "<div id=\"{$this->domidbase}msg\"></div>\n";
+ $h .= dijitButton("{$this->domidbase}btn", _('Submit Changes'),
"{$this->jsname}.saveSettings();", 1);
+ $cdata = $this->basecdata;
+ $cont = addContinuationsEntry('AJupdateAllSettings', $cdata);
+ $h .= "<input type=\"hidden\" id=\"{$this->domidbase}cont\"
value=\"$cont\">\n";
+ $h .= "</div>\n";
+ return $h;
+ }
+
+
////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// \fn AJupdateAllSettings()
+ ///
+ /// \brief updates all values for implemented type of timevariable
+ ///
+
////////////////////////////////////////////////////////////////////////////////
+ function AJupdateAllSettings() {
+ if(! checkUserHasPerm('Site Configuration (global)')) {
+ $arr = array('status' => 'noaccess',
+ 'msg' => _('You do not have access to
modify the submitted settings.'));
+ sendJSON($arr);
+ return;
+ }
+ switch($this->type) {
+ case 'numeric':
+ $newval = processInputVar('newval',
ARG_NUMERIC);
+ if($newval < $this->minval || $newval >
$this->maxval) {
+ $arr = array('status' => 'failed',
+ 'msgid' =>
"{$this->domidbase}msg",
+ 'btn' =>
"{$this->domidbase}btn",
+ 'errmsg' => _("Invalid
value submitted"));
+ sendJSON($arr);
+ return;
+ }
+ break;
+ case 'boolean':
+ $newval = processInputVar('newval',
ARG_NUMERIC);
+ if($newval !== '0' && $newval !== '1') {
+ $arr = array('status' => 'failed',
+ 'msgid' =>
"{$this->domidbase}msg",
+ 'btn' =>
"{$this->domidbase}btn",
+ 'errmsg' => _("Invalid
value submitted"));
+ sendJSON($arr);
+ return;
+ }
+ break;
+ case 'text':
+ # TODO
+ $newval = processInputVar('newval',
ARG_STRING);
+ $arr = array('status' => 'failed',
+ 'msgid' => "{$this->domidbase}msg",
+ 'btn' => "{$this->domidbase}btn",
+ 'errmsg' => _("unsupported type"));
+ sendJSON($arr);
+ return;
+ default:
+ $arr = array('status' => 'failed',
+ 'msgid' => "{$this->domidbase}msg",
+ 'btn' => "{$this->domidbase}btn",
+ 'errmsg' => _("Invalid value
submitted"));
+ sendJSON($arr);
+ return;
+ }
+ setVariable($this->key, $newval, 'none');
+ $arr = array('status' => 'success',
+ 'msgid' => "{$this->domidbase}msg",
+ 'btn' => "{$this->domidbase}btn",
+ 'msg' => $this->updatemsg);
+ sendJSON($arr);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \class userPasswordLength
+///
+/// \brief extends TimeVariable class to implement general_end_notice_second
+///
+////////////////////////////////////////////////////////////////////////////////
+class userPasswordLength extends GlobalSingleVariable {
+
/////////////////////////////////////////////////////////////////////////////
+ ///
+ /// \fn __construct()
+ ///
+ /// \brief class construstor
+ ///
+
/////////////////////////////////////////////////////////////////////////////
+ function __construct() {
+ parent::__construct();
+ $this->name = _('User Reservation Password Length');
+ $this->key = 'user_password_length';
+ $this->label = _("Password Length");
+ $this->desc = _("For reservations not using federated
authentication, VCL generates random user passwords. This specifies how many
characters should be in the password.");
+ $this->domidbase = 'userpasswordlength';
+ $this->basecdata['obj'] = $this;
+ $this->jsname = 'userPasswordLength';
+ $this->defaultval = 6;
+ $this->minval = 6;
+ $this->maxval = 40;
+ $this->type = 'numeric';
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \class userPasswordSpecialChar
+///
+/// \brief extends TimeVariable class to implement general_end_notice_second
+///
+////////////////////////////////////////////////////////////////////////////////
+class userPasswordSpecialChar extends GlobalSingleVariable {
+
/////////////////////////////////////////////////////////////////////////////
+ ///
+ /// \fn __construct()
+ ///
+ /// \brief class construstor
+ ///
+
/////////////////////////////////////////////////////////////////////////////
+ function __construct() {
+ parent::__construct();
+ $this->name = _('User Reservation Password Special Characters');
+ $this->key = 'user_password_spchar';
+ $this->label = _("Include Special Characters");
+ $this->desc = _("For reservations not using federated
authentication, VCL generates random user passwords. This specifies if
characters other than letters and numbers should be included in the
passwords.");
+ $this->domidbase = 'userpasswordspchar';
+ $this->basecdata['obj'] = $this;
+ $this->jsname = 'userPasswordSpecialChar';
+ $this->defaultval = 1;
+ $this->type = 'boolean';
+ }
+}
+
?>
Modified: vcl/trunk/web/.ht-inc/states.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/states.php?rev=1638354&r1=1638353&r2=1638354&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/states.php (original)
+++ vcl/trunk/web/.ht-inc/states.php Tue Nov 11 20:24:54 2014
@@ -552,6 +552,8 @@ $actions['classmapping']['serverinuse']
$actions['classmapping']['clusterinuse'] = 'siteconfig';
$actions['classmapping']['generalendnotice1'] = 'siteconfig';
$actions['classmapping']['generalendnotice2'] = 'siteconfig';
+$actions['classmapping']['userpasswordlength'] = 'siteconfig';
+$actions['classmapping']['userpasswordspecialchar'] = 'siteconfig';
# resource
$actions['mode']['resource'] = "resource";
Modified: vcl/trunk/web/.ht-inc/utils.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/utils.php?rev=1638354&r1=1638353&r2=1638354&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/utils.php (original)
+++ vcl/trunk/web/.ht-inc/utils.php Tue Nov 11 20:24:54 2014
@@ -12909,6 +12909,7 @@ function getDojoHTML($refresh) {
'dijit.form.FilteringSelect',
'dijit.form.Select',
'dijit.form.NumberSpinner',
+ 'dijit.form.CheckBox',
'dijit.form.ValidationTextBox',
'dijit.layout.ContentPane',
'dijit.layout.TabContainer');
Modified: vcl/trunk/web/js/siteconfig.js
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/js/siteconfig.js?rev=1638354&r1=1638353&r2=1638354&view=diff
==============================================================================
--- vcl/trunk/web/js/siteconfig.js (original)
+++ vcl/trunk/web/js/siteconfig.js Tue Nov 11 20:24:54 2014
@@ -210,3 +210,33 @@ function generalEndNotice2() {
}
generalEndNotice2.prototype = new TimeVariable();
var generalEndNotice2 = new generalEndNotice2();
+
+function GlobalSingleVariable() {}
+
+GlobalSingleVariable.prototype.saveSettings = function() {
+ var data = {continuation: dojo.byId(this.domidbase + 'cont').value};
+ if('checked' in dijit.byId(this.domidbase)) {
+ if(dijit.byId(this.domidbase).checked)
+ data.newval = dijit.byId(this.domidbase).value;
+ else
+ data.newval = 0;
+ }
+ else
+ data.newval = dijit.byId(this.domidbase).value;
+ dijit.byId(this.domidbase + 'btn').set('disabled', true);
+ RPCwrapper(data, generalSiteConfigCB, 1);
+}
+
+function userPasswordLength() {
+ GlobalSingleVariable.apply(this, Array.prototype.slice.call(arguments));
+ this.domidbase = 'userpasswordlength';
+}
+userPasswordLength.prototype = new GlobalSingleVariable();
+var userPasswordLength = new userPasswordLength();
+
+function userPasswordSpecialChar() {
+ GlobalSingleVariable.apply(this, Array.prototype.slice.call(arguments));
+ this.domidbase = 'userpasswordspchar';
+}
+userPasswordSpecialChar.prototype = new GlobalSingleVariable();
+var userPasswordSpecialChar = new userPasswordSpecialChar();