vcl-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jftho...@apache.org
Subject svn commit: r1788997 - in /vcl/trunk/web: .ht-inc/siteconfig.php js/siteconfig.js
Date Mon, 27 Mar 2017 19:49:15 GMT
Author: jfthomps
Date: Mon Mar 27 19:49:15 2017
New Revision: 1788997

URL: http://svn.apache.org/viewvc?rev=1788997&view=rev
Log:
VCL-1029 - add a section for managing affiliations to Site Configuration
VCL-915 - Add ability to automatically mount NFS share when user logs in

siteconfig.php:
-modified generalOptions: restricted seeing block to manage Affiliations to users with 'Site
Configuration (global)' access
-modified GlobalMultiVariable: added $allowduplicates variable
-modified GlobalMultiVariable::__construct: set $this->allowduplicates to 0 as default
-added GlobalMultiVariable::setValues
-modified GlobalMultiVariable::AJaddConfigMultiVal: added check for having proper permissions;
added call to $this->setValues and regenerated add, delete, and save continuations which
are then sent back in returned data
-modified GlobalMultiVariable::AJdeleteMultiSetting: added check for having proper permissions;
added call to $this->setValues and regenerated save continuation which is then sent back
in returned data
-modified GlobalMultiVariable::AJupdateAllSettings: wrapped check for duplicate values with
check for $this->allowduplicates being false; added call to $this->setValues and regenerated
save continuation which is then sent back in returned data
-modified NFSmounts::__construct: set $this->allowduplicates to 1
-added NFSmounts::setValues
-added Affiliations::setValues
-modified Affiliations::AJaddConfigMultiVal: added check for having proper permissions

siteconfig.js:
-modified GlobalMultiVariable.prototype.addNewMultiValCBextra: update add, delete, and save
continuations with returned data; added check for keys[0] being an empty string and if so,
set it to the id of the item being added
-modified GlobalMultiVariable.prototype.deleteMultiValCBextra and GlobalMultiVariable.prototype.saveCBextra:
update save continuation with returned data

Modified:
    vcl/trunk/web/.ht-inc/siteconfig.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=1788997&r1=1788996&r2=1788997&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/siteconfig.php (original)
+++ vcl/trunk/web/.ht-inc/siteconfig.php Mon Mar 27 19:49:15 2017
@@ -71,9 +71,10 @@ function generalOptions($globalopts) {
 	$h .= "<div id=\"siteconfiglayout\">\n";
 
 	# -------- left column ---------
-	# TODO control access to affiliations
-	$h .= "<div id=\"siteconfigleftcol\">\n";
-	$obj = new Affiliations();
+	if(! checkUserHasPerm('Site Configuration (global)')) {
+		$h .= "<div id=\"siteconfigleftcol\">\n";
+		$obj = new Affiliations();
+	}
 	$h .= $obj->getHTML($globalopts);
 	$obj = new connectedUserCheck();
 	$h .= $obj->getHTML($globalopts);
@@ -1914,6 +1915,7 @@ class GlobalMultiVariable {
 	var $addCBextra;
 	var $deleteCBextra;
 	var $saveCBextra;
+	var $allowduplicates;
 
 	/////////////////////////////////////////////////////////////////////////////
 	///
@@ -1929,6 +1931,17 @@ class GlobalMultiVariable {
 		$this->addCBextra = 'addNewMultiValCBextra';
 		$this->deleteCBextra = 'deleteMultiValCBextra';
 		$this->saveCBextra = 'saveCBextra';
+		$this->allowduplicates = 0;
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn setValues
+	///
+	/// \brief sets values in $this->values
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function setValues() {
 	}
 
 	////////////////////////////////////////////////////////////////////////////////
@@ -2068,7 +2081,12 @@ class GlobalMultiVariable {
 	///
 	////////////////////////////////////////////////////////////////////////////////
 	function AJaddConfigMultiVal() {
-		# TODO check access?
+		if(! checkUserHasPerm('Site Configuration (global)')) {
+			$arr = array('status' => 'noaccess',
+			             'msg' => _('You do not have access to modify the submitted settings.'));
+			sendJSON($arr);
+			return;
+		}
 		$newkey = processInputVar('multivalid', ARG_NUMERIC);
 		$newval = processInputVar('multival', ARG_STRING);
 		if(! array_key_exists($newkey, $this->units)) {
@@ -2090,6 +2108,10 @@ class GlobalMultiVariable {
 			return;
 		}
 		setVariable("{$this->domidbase}|$newkey", $newval, 'none');
+		$this->setValues();
+		$addcont = addContinuationsEntry('AJaddConfigMultiVal', $this->basecdata);
+		$delcont = addContinuationsEntry('AJdeleteMultiSetting', $this->basecdata);
+		$savecont = addContinuationsEntry('AJupdateAllSettings', $this->basecdata);
 		$arr = array('status' => 'success',
 		             'msgid' => "{$this->domidbase}msg",
 		             'addid' => "{$this->domidbase}|$newkey",
@@ -2097,6 +2119,9 @@ class GlobalMultiVariable {
 		             'addval' => $newval,
 		             'delkey' => $newkey,
 		             'extrafunc' => "{$this->jsname}.{$this->addCBextra}",
+		             'addcont' => $addcont,
+		             'delcont' => $delcont,
+		             'savecont' => $savecont,
 		             'msg' => $this->addmsg,
 		             'regexp' => $this->constraint,
 		             'invalidmsg' => str_replace('&amp;', '&', $this->invalidmsg));
@@ -2111,7 +2136,12 @@ class GlobalMultiVariable {
 	///
 	////////////////////////////////////////////////////////////////////////////////
 	function AJdeleteMultiSetting() {
-		# TODO check access?
+		if(! checkUserHasPerm('Site Configuration (global)')) {
+			$arr = array('status' => 'noaccess',
+			             'msg' => _('You do not have access to modify the submitted settings.'));
+			sendJSON($arr);
+			return;
+		}
 		$key = processInputVar('key', ARG_NUMERIC);
 		if(! array_key_exists($key, $this->values)) {
 			$arr = array('status' => 'failed',
@@ -2131,13 +2161,16 @@ class GlobalMultiVariable {
 			sendJSON($arr);
 			return;
 		}
+		$this->setValues();
+		$savecont = addContinuationsEntry('AJupdateAllSettings', $this->basecdata);
 		$arr = array('status' => 'success',
 		             'msgid' => "{$this->domidbase}msg",
 		             'delid' => "{$this->domidbase}|$key",
 		             'extrafunc' => "{$this->jsname}.{$this->deleteCBextra}",
 		             'addid' => "$key",
 		             'addname' => $this->units[$key]['name'],
-		             'msg' => $this->delmsg);
+		             'msg' => $this->delmsg,
+		             'savecont' => $savecont);
 		sendJSON($arr);
 	}
 
@@ -2210,14 +2243,16 @@ class GlobalMultiVariable {
 						sendJSON($arr);
 						return;
 					}
-					foreach($newvals as $testval) {
-						if($newval == $testval) {
-							$arr = array('status' => 'failed',
-							             'msgid' => "{$this->domidbase}msg",
-							             'btn' => "{$this->domidbase}btn",
-							             'errmsg' => _("Duplicate new values submitted"));
-							sendJSON($arr);
-							return;
+					if(! $this->allowduplicates) {
+						foreach($newvals as $testval) {
+							if($newval == $testval) {
+								$arr = array('status' => 'failed',
+								             'msgid' => "{$this->domidbase}msg",
+								             'btn' => "{$this->domidbase}btn",
+								             'errmsg' => _("Duplicate new values submitted"));
+								sendJSON($arr);
+								return;
+							}
 						}
 					}
 					if($newval != $origvals[$key])
@@ -2254,11 +2289,14 @@ class GlobalMultiVariable {
 		}
 		foreach($newvals as $key => $val)
 			$this->updateValue($key, $val);
+		$this->setValues();
+		$savecont = addContinuationsEntry('AJupdateAllSettings', $this->basecdata);
 		$arr = array('status' => 'success',
 		             'msgid' => "{$this->domidbase}msg",
 		             'btn' => "{$this->domidbase}btn",
 		             'msg' => $this->updatemsg,
-		             'extrafunc' => "{$this->jsname}.{$this->saveCBextra}");
+		             'extrafunc' => "{$this->jsname}.{$this->saveCBextra}",
+		             'savecont' => $savecont);
 		sendJSON($arr);
 	}
 
@@ -2335,6 +2373,24 @@ class NFSmounts extends GlobalMultiVaria
 		$this->invalidmsg = _("Invalid value - must be in the form") . str_replace('&',
'&amp;', $formbase);
 		$this->invalidvaluemsg = html_entity_decode($this->invalidmsg);
 		$this->width = '400px';
+		$this->allowduplicates = 1;
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn setValues
+	///
+	/// \brief sets values in $this->values
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function setValues() {
+		$vals = getVariablesRegex('^nfsmount\\\|[0-9]+$');
+		$this->values = array();
+		foreach($vals as $key => $val) {
+			$tmp = explode('|', $key);
+			$id = $tmp[1];
+			$this->values[$id] = $val;
+		}
 	}
 
 	////////////////////////////////////////////////////////////////////////////////
@@ -2420,6 +2476,23 @@ class Affiliations extends GlobalMultiVa
 		$this->saveCBextra = 'pagerefresh';
 	}
 
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn setValues
+	///
+	/// \brief sets values in $this->values
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function setValues() {
+		$affils = getAffiliations();
+		$this->values = array();
+		foreach($affils as $key => $val) {
+			if($val == 'Global')
+				continue;
+			$this->values[$key] = $val;
+		}
+	}
+
 	////////////////////////////////////////////////////////////////////////////////
 	///
 	/// \fn existingValuesHTML()
@@ -2499,6 +2572,12 @@ class Affiliations extends GlobalMultiVa
 	///
 	////////////////////////////////////////////////////////////////////////////////
 	function AJaddConfigMultiVal() {
+		if(! checkUserHasPerm('Site Configuration (global)')) {
+			$arr = array('status' => 'noaccess',
+			             'msg' => _('You do not have access to modify the submitted settings.'));
+			sendJSON($arr);
+			return;
+		}
 		$newval = processInputVar('multival', ARG_STRING);
 		if(! $this->validateValue($newval)) {
 			$arr = array('status' => 'failed',

Modified: vcl/trunk/web/js/siteconfig.js
URL: http://svn.apache.org/viewvc/vcl/trunk/web/js/siteconfig.js?rev=1788997&r1=1788996&r2=1788997&view=diff
==============================================================================
--- vcl/trunk/web/js/siteconfig.js (original)
+++ vcl/trunk/web/js/siteconfig.js Mon Mar 27 19:49:15 2017
@@ -453,8 +453,14 @@ GlobalMultiVariable.prototype.addNewMult
 	dijit.byId(this.domidbase + 'newmultivalid').removeOption({value: data.items.delkey});
 	if(dijit.byId(this.domidbase + 'newmultivalid').options.length == 0)
 		dojo.addClass(this.domidbase + 'multivalnewspan', 'hidden');
+	dojo.byId(this.domidbase + 'addcont').value = data.items.addcont;
+	dojo.byId('delete' + this.domidbase + 'cont').value = data.items.delcont;
+	dojo.byId(this.domidbase + 'cont').value = data.items.savecont;
 	var keys = dojo.byId(this.domidbase + 'savekeys').value.split(',');
-	keys.push(data.items.addid);
+	if(keys[0] == '')
+		keys[0] = data.items.addid;
+	else
+		keys.push(data.items.addid);
 	dojo.byId(this.domidbase + 'savekeys').value = keys.join(',');
 	dijit.byId(this.domidbase + 'addbtn').set('disabled', false);
 }
@@ -476,8 +482,10 @@ GlobalMultiVariable.prototype.deleteMult
 	}
 	dojo.byId(this.domidbase + 'savekeys').value = newkeys.join(',');
 	dojo.removeClass(this.domidbase + 'multivalnewspan', 'hidden');
+	dojo.byId(this.domidbase + 'cont').value = data.items.savecont;
 }
 GlobalMultiVariable.prototype.saveCBextra = function(data) {
+	dojo.byId(this.domidbase + 'cont').value = data.items.savecont;
 }
 
 function nfsmount() {



Mime
View raw message