vcl-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jftho...@apache.org
Subject svn commit: r1793126 - in /vcl/trunk/web: .ht-inc/siteconfig.php .ht-inc/states.php .ht-inc/utils.php js/siteconfig.js
Date Fri, 28 Apr 2017 18:40:29 GMT
Author: jfthomps
Date: Fri Apr 28 18:40:29 2017
New Revision: 1793126

URL: http://svn.apache.org/viewvc?rev=1793126&view=rev
Log:
VCL-1029 - add a section for managing affiliations to Site Configuration

siteconfig.php:
-modified generalOptions: reordered several options; added conditional to only print AffilShibName
block if user has global config permission or the user's affiliation is not Local
-modified AffilTextVariable: added $updatefailmsg, $affils, $allowempty, $allowglobalempty,
$globalid, and initializations for them in the __construct function
-modified AffilTextVariable::validateValue: escaped any slashes in $this->constraints before
doing the preg_match
-modified AffilTextVariable::getHTML: modified to better handle users not having global site
config so that they see the default value from the Global setting and can set the value to
an empty string to cause the default value to be used
-modified AffilTextVariable::AJaddAffiliationSetting: set $affils from $this->affils instead
of calling getAffiliations
-modified AffilTextVariable::AJupdateAllSettings: modified to better handle users not having
global site config so that they can set the value to an empty string to cause the default
value to be used
-modified AffilHelpAddress: set $this->allowempty to 1
-modified AffilHelpAddress::setValue: modified to handle $value being NULL
-added AffilWebAddress
-modified AffilKMSserver: set $this->allowempty to 1; set $this->allowglobalempty to
1
-modified AffilTheme: set $this->allowempty to 1
-modified AffilTheme::deleteValue: added code to set theme value to NULL in database rather
than just returning 0
-added AffilShibOnly
-added AffilShibName

states.php:
-added affilwebaddress classmapping
-added affilshibonly classmapping
-added affilshibname classmapping

utils.php: modified getAffiliationTheme: updated query to return theme from Global affiliation
if passed in affiliation's setting is NULL; if no value found for either, return DEFAULTTHEME
setting

siteconfig.js:
-modified AffilTextVariable.prototype.addAffiliationSettingCBextra: fixed problem when adding
a new value where the savekeys value was getting an empty string in the list
-modified AffilTextVariable.prototype.saveSettings: if a value of 0 is going to be submitted,
change it to 'zero' so that the php function processInputVar will handle it correctly
-added affilwebaddr
-added affilshibonly
-added affilshibname
-modified messages.prototype.init: changed setTimeout from calling this.init to calling messages.init
or messages.prototype.init, depending on which one exists

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=1793126&r1=1793125&r2=1793126&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/siteconfig.php (original)
+++ vcl/trunk/web/.ht-inc/siteconfig.php Fri Apr 28 18:40:29 2017
@@ -55,6 +55,7 @@ function siteconfig() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function generalOptions($globalopts) {
+	global $user;
 	$h = '';
 	#$h .= "<div id=\"globalopts\" dojoType=\"dijit.layout.ContentPane\" title=\"Global Options\">\n";
 
@@ -72,25 +73,29 @@ function generalOptions($globalopts) {
 
 	# -------- left column ---------
 	$h .= "<div id=\"siteconfigleftcol\">\n";
-	if(checkUserHasPerm('Site Configuration (global)')) {
+	if($globalopts) {
+		$obj = new userPasswordLength();
+		$h .= $obj->getHTML();
+		$obj = new userPasswordSpecialChar();
+		$h .= $obj->getHTML();
 		$obj = new Affiliations();
 		$h .= $obj->getHTML($globalopts);
 	}
-	$obj = new connectedUserCheck();
-	$h .= $obj->getHTML($globalopts);
-	$obj = new acknowledge();
+	$obj = new AffilHelpAddress();
 	$h .= $obj->getHTML($globalopts);
-	$obj = new initialconnecttimeout();
+	$obj = new AffilWebAddress();
 	$h .= $obj->getHTML($globalopts);
-	$obj = new reconnecttimeout();
+	$obj = new AffilTheme();
 	$h .= $obj->getHTML($globalopts);
 	if($globalopts) {
-		$obj = new userPasswordLength();
-		$h .= $obj->getHTML();
-		$obj = new userPasswordSpecialChar();
-		$h .= $obj->getHTML();
+		$obj = new AffilShibOnly();
+		$h .= $obj->getHTML($globalopts);
 	}
-	$obj = new AffilHelpAddress();
+	if($globalopts || $user['affiliationid'] != getAffiliationID('Local')) {
+		$obj = new AffilShibName();
+		$h .= $obj->getHTML($globalopts);
+	}
+	$obj = new AffilKMSserver();
 	$h .= $obj->getHTML($globalopts);
 	$h .= "</div>\n"; # siteconfigleftcol
 	# -------- end left column ---------
@@ -98,6 +103,14 @@ function generalOptions($globalopts) {
 
 	# ---------- right column ---------
 	$h .= "<div id=\"siteconfigrightcol\">\n";
+	$obj = new connectedUserCheck();
+	$h .= $obj->getHTML($globalopts);
+	$obj = new acknowledge();
+	$h .= $obj->getHTML($globalopts);
+	$obj = new initialconnecttimeout();
+	$h .= $obj->getHTML($globalopts);
+	$obj = new reconnecttimeout();
+	$h .= $obj->getHTML($globalopts);
 	$obj = new generalInuse();
 	$h .= $obj->getHTML($globalopts);
 	$obj = new serverInuse();
@@ -112,10 +125,6 @@ function generalOptions($globalopts) {
 		$obj = new NATportRange();
 		$h .= $obj->getHTML();
 	}
-	$obj = new AffilKMSserver();
-	$h .= $obj->getHTML($globalopts);
-	$obj = new AffilTheme();
-	$h .= $obj->getHTML($globalopts);
 	$h .= "</div>\n"; # siteconfigrightcol
 	# -------- end right column --------
 
@@ -842,6 +851,11 @@ class AffilTextVariable {
 	var $width;
 	var $vartype;
 	var $allowdelete;
+	var $updatefailmsg;
+	var $affils;
+	var $allowempty;
+	var $allowglobalempty;
+	var $globalid;
 
 	/////////////////////////////////////////////////////////////////////////////
 	///
@@ -856,6 +870,11 @@ class AffilTextVariable {
 		$this->width = '200px';
 		$this->vartype = 'text';
 		$this->allowdelete = 1;
+		$this->updatefailmsg = i('Failed to update data for these affiliations:');
+		$this->affils = getAffiliations();
+		$this->allowempty = 0;
+		$this->allowglobalempty = 0;
+		$this->globalid = getAffiliationID('Global');
 	}
 
 	/////////////////////////////////////////////////////////////////////////////
@@ -913,7 +932,8 @@ class AffilTextVariable {
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function validateValue($value) {
-		if(preg_match("/{$this->constraints}/", $value))
+		$test = str_replace("/", "\/", $this->constraints);
+		if(preg_match("/$test/", $value))
 			return 1;
 		return 0;
 	}
@@ -935,27 +955,41 @@ class AffilTextVariable {
 		$h .= $this->desc;
 		$h .= "<br><br></div>\n";
 
-		$affils = getAffiliations();
+		$affils = $this->affils;
 		$saveids = array();
 
+		$required = 0;
+
 		if($globalopts) {
-			$id = getAffiliationID('Global');
-			$key = "{$this->domidbase}_$id";
-			$val = $this->values[$id];
-			$label = i('Global');
-			unset_by_val(i('Global'), $affils);
+			if(isset($this->values[$this->globalid])) {
+				$key = "{$this->domidbase}_{$this->globalid}";
+				$val = $this->values[$this->globalid];
+				$label = i('Global');
+				unset_by_val(i('Global'), $affils);
+				$required = ! $this->allowglobalempty;
+			}
 		}
 		else {
+			if(isset($this->values[$this->globalid])) {
+				$defaultval = $this->values[$this->globalid];
+				$h .= i('Default value') . ": $defaultval<br>\n";
+			}
 			$key = "{$this->domidbase}_{$user['affiliationid']}";
 			$val = $this->values[$user['affiliationid']];
+			if($this->vartype != 'text' && $val === NULL)
+				$val = $defaultval;
 			$label = $user['affiliation'];
 		}
-		$saveids[] = $key;
-		$h .= labeledFormItem($key, $label, $this->vartype, $this->constraints, 1, $val,
$this->errmsg, '', '', $this->width); 
+		if(isset($key)) {
+			$saveids[] = $key;
+			$h .= labeledFormItem($key, $label, $this->vartype, $this->constraints, $required,
$val, $this->errmsg, '', '', $this->width); 
+		}
 		if($globalopts) {
 			$h .= "<div id=\"{$this->domidbase}affildiv\">\n";
 			foreach($affils as $affil => $name) {
-				if(is_null($this->values[$affil]) || $this->values[$affil] == '')
+				if(! isset($this->values[$affil]))
+					continue;
+				if($this->values[$affil] === NULL || $this->values[$affil] === '')
 					continue;
 				$key = "{$this->domidbase}_$affil";
 				$saveids[] = $key;
@@ -1024,7 +1058,7 @@ class AffilTextVariable {
 			return;
 		}
 		$affilid = processInputVar('affilid', ARG_NUMERIC);
-		$affils = getAffiliations();
+		$affils = $this->affils;
 		if(! array_key_exists($affilid, $affils)) {
 			$arr = array('status' => 'failed',
 			             'msgid' => "{$this->domidbase}msg",
@@ -1086,6 +1120,7 @@ class AffilTextVariable {
 	///
 	////////////////////////////////////////////////////////////////////////////////
 	function AJupdateAllSettings() {
+		global $user;
 		if(! checkUserHasPerm('Site Configuration (global)') &&
 		   ! checkUserHasPerm('Site Configuration (affiliation only)')) {
 			$arr = array('status' => 'noaccess',
@@ -1093,24 +1128,32 @@ class AffilTextVariable {
 			sendJSON($arr);
 			return;
 		}
+		$affilonly = 0;
+		if(! checkUserHasPerm('Site Configuration (global)'))
+			$affilonly = 1;
 		$origvals = getContinuationVar('origvals');
 		$newvals = array();
 		foreach($origvals as $affilid => $val) {
+			if($affilonly && $affilid != $user['affiliationid'])
+				continue;
 			$id = "{$this->domidbase}_$affilid";
 			$newval = processInputVar($id, ARG_STRING);
-			if($newval === NULL)
-				continue;
-			if(! $this->validateValue($newval)) {
-				$affil = getAffiliationName($affilid);
-				$arr = array('status' => 'failed',
-				             'msgid' => "{$this->domidbase}msg",
-				             'btn' => "{$this->domidbase}btn",
-				             'errmsg' => i("Invalid value submitted for ") . $affil);
-				sendJSON($arr);
-				return;
+			if($newval !== NULL || # TODO test further
+	   		! $this->allowempty ||
+				($affilid == $this->globalid && ! $this->allowglobalempty)) {
+				if(! $this->validateValue($newval)) {
+					$affil = getAffiliationName($affilid);
+					$arr = array('status' => 'failed',
+					             'msgid' => "{$this->domidbase}msg",
+					             'btn' => "{$this->domidbase}btn",
+					             'errmsg' => i("Invalid value submitted for ") . $affil);
+					sendJSON($arr);
+					return;
+				}
 			}
 			if($newval != $val)
 				$newvals[$affilid] = $newval;
+
 		}
 		$fails = array();
 		foreach($newvals as $affilid => $val) {
@@ -1125,7 +1168,7 @@ class AffilTextVariable {
 		$savecont = addContinuationsEntry('AJupdateAllSettings', $cdata);
 
 		if(count($fails)) {
-			$msg = i("Failed to update address for these affiliations: ") . implode(', ', $fails);
+			$msg = $this->updatefailmsg . ' ' . implode(', ', $fails);
 			$arr = array('status' => 'failed',
 			             'msgid' => "{$this->domidbase}msg",
 			             'errmsg' => $msg,
@@ -1227,6 +1270,7 @@ class AffilHelpAddress extends AffilText
 		$this->addmsg = i("Help Email Address added for %s");
 		$this->updatemsg = i("Update successful");
 		$this->delmsg = i("Address for %s deleted");
+		$this->allowempty = 1;
 	}
 
 	/////////////////////////////////////////////////////////////////////////////
@@ -1259,9 +1303,14 @@ class AffilHelpAddress extends AffilText
 	/////////////////////////////////////////////////////////////////////////////
 	function setValue($affilid, $value) {
 		global $mysql_link_vcl;
-		$esc_value = mysql_real_escape_string($value);
+		if($value === NULL)
+			$newval = 'NULL';
+		else {
+			$esc_value = mysql_real_escape_string($value);
+			$newval = "'$esc_value'";
+		}
 		$query = "UPDATE affiliation "
-		       . "SET helpaddress = '$esc_value' "
+		       . "SET helpaddress = $newval "
 		       . "WHERE id = $affilid";
 		doQuery($query);
 		$rc = mysql_affected_rows($mysql_link_vcl);
@@ -1296,6 +1345,105 @@ class AffilHelpAddress extends AffilText
 
 ////////////////////////////////////////////////////////////////////////////////
 ///
+/// \class AffilWebAddress
+///
+/// \brief extends AffilTextVariable to implement AffilWebAddress
+///
+////////////////////////////////////////////////////////////////////////////////
+class AffilWebAddress extends AffilTextVariable {
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn __construct()
+	///
+	/// \brief class construstor
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function __construct() {
+		parent::__construct();
+		$this->name = i("Site Web Address");
+		$this->desc = i("This is the web address in emails sent by the VCL system to users.");
+		$this->constraints = '^http(s)?://([-A-Za-z0-9]{1,63})(\.[A-Za-z0-9-_]+)*(\.?[A-Za-z0-9])(/[-a-zA-Z0-9\._~&\+,=:@]*)*$';
+		$this->errmsg = i("Invalid web address(es) specified");
+		$this->domidbase = "affilwebaddr";
+		$this->jsname = "affilwebaddr";
+		$this->addmsg = i("Web Address added for %s");
+		$this->updatemsg = i("Update successful");
+		$this->delmsg = i("Web Address for %s deleted");
+		$this->allowempty = 1;
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn getValues()
+	///
+	/// \brief gets assigned values from database and sets in $this->values
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function getValues() {
+		$this->values = array();
+		$query = "SELECT id, sitewwwaddress FROM affiliation ORDER BY name";
+		$qh = doQuery($query);
+		while($row = mysql_fetch_assoc($qh))
+			$this->values[$row['id']] = $row['sitewwwaddress'];
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn setValue($affilid, $value)
+	///
+	/// \param $affilid - affiliationid
+	/// \param $value - value to be set for $affilid
+	///
+	/// \brief sets values in database
+	///
+	/// \return 1 if successfully set values, 0 if error encountered setting
+	/// values
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function setValue($affilid, $value) {
+		global $mysql_link_vcl;
+		if($value === NULL)
+			$newval = 'NULL';
+		else {
+			$esc_value = mysql_real_escape_string($value);
+			$newval = "'$esc_value'";
+		}
+		$query = "UPDATE affiliation "
+		       . "SET sitewwwaddress = $newval "
+		       . "WHERE id = $affilid";
+		doQuery($query);
+		$rc = mysql_affected_rows($mysql_link_vcl);
+		if($rc == 1)
+			return 1;
+		return 0;
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn deleteValue($affilid)
+	///
+	/// \param $affilid - affiliationid
+	///
+	/// \brief deletes a value from the database
+	///
+	/// \return 1 if successfully deleted value, 0 if error encountered
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function deleteValue($affilid) {
+		global $mysql_link_vcl;
+		$query = "UPDATE affiliation "
+		       . "SET sitewwwaddress = NULL "
+		       . "WHERE id = $affilid";
+		doQuery($query);
+		$rc = mysql_affected_rows($mysql_link_vcl);
+		if($rc == 1)
+			return 1;
+		return 0;
+	}
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
 /// \class AffilKMSserver
 ///
 /// \brief extends AffilTextVariable to implement AffilKMSserver
@@ -1322,6 +1470,8 @@ class AffilKMSserver extends AffilTextVa
 		$this->updatemsg = i("Update successful");
 		$this->delmsg = i("KMS server for %s deleted");
 		$this->width = '350px';
+		$this->allowempty = 1;
+		$this->allowglobalempty = 1;
 	}
 
 	/////////////////////////////////////////////////////////////////////////////
@@ -1524,7 +1674,8 @@ class AffilTheme extends AffilTextVariab
 		$this->delmsg = i("Theme setting for %s deleted");
 		$this->getValidValues();
 		$this->vartype = 'selectonly';
-		$this->allowdelete = 0;
+		$this->allowdelete = 1;
+		$this->allowempty = 1;
 	}
 
 	/////////////////////////////////////////////////////////////////////////////
@@ -1598,6 +1749,14 @@ class AffilTheme extends AffilTextVariab
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function deleteValue($affilid) {
+		global $mysql_link_vcl;
+		$query = "UPDATE affiliation "
+		       . "SET theme = NULL "
+		       . "WHERE id = $affilid";
+		doQuery($query);
+		$rc = mysql_affected_rows($mysql_link_vcl);
+		if($rc == 1)
+			return 1;
 		return 0;
 	}
 
@@ -1617,6 +1776,223 @@ class AffilTheme extends AffilTextVariab
 			return 1;
 		return 0;
 	}
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \class AffilShibOnly
+///
+/// \brief extends AffilTextVariable to implement AffilShibOnly
+///
+////////////////////////////////////////////////////////////////////////////////
+class AffilShibOnly extends AffilTextVariable {
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn __construct()
+	///
+	/// \brief class construstor
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function __construct() {
+		$this->constraints = array('False', 'True');
+		parent::__construct();
+		$this->name = i("LDAP Lookup for Shibboleth Authenticated Users");
+		$this->desc = i("If an affiliation gets configured for Shibboleth authentication, this
specifies that LDAP authentication has also been configured for that affiliation so that VCL
can perform lookups for new users before they log in to VCL.");
+		$this->errmsg = i("Invalid value submitted");
+		$this->domidbase = "affilshibonly";
+		$this->jsname = "affilshibonly";
+		$this->addmsg = i("LDAP lookup setting added for %s");
+		$this->updatemsg = i("Update successful");
+		$this->delmsg = i("LDAP lookup setting for %s deleted");
+		$this->vartype = 'selectonly';
+		$this->allowdelete = 0;
+		$this->allowempty = 1;
+		unset_by_val(i('Global'), $this->affils);
+		unset_by_val(i('Local'), $this->affils);
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn getValues()
+	///
+	/// \brief gets assigned values from database and sets in $this->values
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function getValues() {
+		$this->values = array();
+		$query = "SELECT id, "
+		       .        "shibonly "
+		       . "FROM affiliation "
+		       . "WHERE name NOT IN ('Global', 'Local') "
+		       . "ORDER BY name";
+		$qh = doQuery($query);
+		while($row = mysql_fetch_assoc($qh))
+			$this->values[$row['id']] = (int)(! $row['shibonly']);
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn setValue($affilid, $value)
+	///
+	/// \param $affilid - affiliationid
+	/// \param $value - value to be set for $affilid
+	///
+	/// \brief sets values in database
+	///
+	/// \return 1 if successfully set values, 0 if error encountered setting
+	/// values
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function setValue($affilid, $value) {
+		global $mysql_link_vcl;
+		$value = (int)(! $value);
+		$query = "UPDATE affiliation "
+		       . "SET shibonly = $value "
+		       . "WHERE id = $affilid";
+		doQuery($query);
+		$rc = mysql_affected_rows($mysql_link_vcl);
+		if($rc == 1)
+			return 1;
+		return 0;
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn deleteValue($affilid)
+	///
+	/// \param $affilid - affiliationid
+	///
+	/// \brief deletes a value from the database
+	///
+	/// \return 1 if successfully deleted value, 0 if error encountered
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function deleteValue($affilid) {
+		return 0;
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn validateValue($value)
+	///
+	/// \param $value - value to be validated
+	///
+	/// \brief validates a submitted value
+	///
+	/// \return 1 if $value is valid, 0 if $value is not valid
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function validateValue($value) {
+		if($value === 0 || $value == 1)
+			return 1;
+		return 0;
+	}
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \class AffilShibName
+///
+/// \brief extends AffilTextVariable to implement AffilShibName
+///
+////////////////////////////////////////////////////////////////////////////////
+class AffilShibName extends AffilTextVariable {
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn __construct()
+	///
+	/// \brief class construstor
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function __construct() {
+		parent::__construct();
+		$this->name = i("Shibboleth Scope");
+		$this->desc = i("This is the Shibboleth scope for an affiliation when Shibboleth authentication
is enabled.");
+		$this->errmsg = i("Invalid value submitted");
+		$this->domidbase = "affilshibname";
+		$this->jsname = "affilshibname";
+		$this->addmsg = i("Shibboleth scope added for %s");
+		$this->updatemsg = i("Update successful");
+		$this->delmsg = i("Shibboleth scope for %s deleted");
+		$this->vartype = 'text';
+		$this->constraints = '^([-A-Za-z0-9]{1,63})(\.[A-Za-z0-9-_]+)*(\.?[A-Za-z0-9])$$';
+		unset_by_val(i('Global'), $this->affils);
+		unset_by_val(i('Local'), $this->affils);
+		$this->allowempty = 1;
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn getValues()
+	///
+	/// \brief gets assigned values from database and sets in $this->values
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function getValues() {
+		$this->values = array();
+		$query = "SELECT id, "
+		       .        "shibname "
+		       . "FROM affiliation "
+		       . "WHERE name NOT IN ('Global', 'Local') "
+		       . "ORDER BY name";
+		$qh = doQuery($query);
+		while($row = mysql_fetch_assoc($qh))
+			$this->values[$row['id']] = $row['shibname'];
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn setValue($affilid, $value)
+	///
+	/// \param $affilid - affiliationid
+	/// \param $value - value to be set for $affilid
+	///
+	/// \brief sets values in database
+	///
+	/// \return 1 if successfully set values, 0 if error encountered setting
+	/// values
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function setValue($affilid, $value) {
+		global $mysql_link_vcl;
+		if($value === NULL)
+			$newval = 'NULL';
+		else {
+			$esc_value = mysql_real_escape_string($value);
+			$newval = "'$esc_value'";
+		}
+		$query = "UPDATE affiliation "
+		       . "SET shibname = $newval "
+		       . "WHERE id = $affilid";
+		doQuery($query);
+		$rc = mysql_affected_rows($mysql_link_vcl);
+		if($rc == 1)
+			return 1;
+		return 0;
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
+	/// \fn deleteValue($affilid)
+	///
+	/// \param $affilid - affiliationid
+	///
+	/// \brief deletes a value from the database
+	///
+	/// \return 1 if successfully deleted value, 0 if error encountered
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function deleteValue($affilid) {
+		global $mysql_link_vcl;
+		$query = "UPDATE affiliation "
+		       . "SET shibname = NULL "
+		       . "WHERE id = $affilid";
+		doQuery($query);
+		$rc = mysql_affected_rows($mysql_link_vcl);
+		if($rc == 1)
+			return 1;
+		return 0;
+	}
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: vcl/trunk/web/.ht-inc/states.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/states.php?rev=1793126&r1=1793125&r2=1793126&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/states.php (original)
+++ vcl/trunk/web/.ht-inc/states.php Fri Apr 28 18:40:29 2017
@@ -595,8 +595,11 @@ $actions['classmapping']['nfsmounts'] =
 $actions['classmapping']['affiliations'] = 'siteconfig';
 $actions['classmapping']['messages'] = 'siteconfig';
 $actions['classmapping']['affilhelpaddress'] = 'siteconfig';
+$actions['classmapping']['affilwebaddress'] = 'siteconfig';
 $actions['classmapping']['affilkmsserver'] = 'siteconfig';
 $actions['classmapping']['affiltheme'] = 'siteconfig';
+$actions['classmapping']['affilshibonly'] = 'siteconfig';
+$actions['classmapping']['affilshibname'] = '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=1793126&r1=1793125&r2=1793126&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/utils.php (original)
+++ vcl/trunk/web/.ht-inc/utils.php Fri Apr 28 18:40:29 2017
@@ -1649,19 +1649,19 @@ function getImageConnectMethods($imageid
 		       . "SELECT DISTINCT i.id, "
 		       .                 "ir.id, "
 		       .                 "c.id, "
-		      .                  "c.description, "
+		       .                 "c.description, "
 		       .                 "cm.disabled "
-		      . "FROM image i "
-		      . "LEFT JOIN OS o ON (o.id = i.OSid) "
-		      . "LEFT JOIN OStype ot ON (ot.name = o.type) "
-		      . "LEFT JOIN imagerevision ir ON (ir.imageid = i.id) "
+		       . "FROM image i "
+		       . "LEFT JOIN OS o ON (o.id = i.OSid) "
+		       . "LEFT JOIN OStype ot ON (ot.name = o.type) "
+		       . "LEFT JOIN imagerevision ir ON (ir.imageid = i.id) "
 		       . "LEFT JOIN connectmethodmap cm ON (%s) "
-		      . "LEFT JOIN connectmethod c ON (cm.connectmethodid = c.id) "
-		      . "WHERE cm.autoprovisioned IS NULL  "
+		       . "LEFT JOIN connectmethod c ON (cm.connectmethodid = c.id) "
+		       . "WHERE cm.autoprovisioned IS NULL "
 		       . "HAVING c.id IS NOT NULL "
-		      . "ORDER BY i.id, "
-		      .          "cm.disabled, "
-		      .          "c.description";
+		       . "ORDER BY i.id, "
+		       .          "cm.disabled, "
+		       .          "c.description";
 		$query = sprintf($qbase, "cm.OStypeid = ot.id");
 		doQuery($query);
 		$query = sprintf($qbase, "cm.OSid = o.id");
@@ -2569,9 +2569,9 @@ function encryptData($data) {
 	if(! $data)
 		return false;
 	if(! function_exists('openssl_encrypt')) {
-	$aes = new Crypt_AES();
-	$aes->setKey($cryptkey);
-	$cryptdata = $aes->encrypt($data);
+		$aes = new Crypt_AES();
+		$aes->setKey($cryptkey);
+		$cryptdata = $aes->encrypt($data);
 	}
 	else {
 		static $key;
@@ -2600,9 +2600,9 @@ function decryptData($data) {
 		return false;
 	$cryptdata = base64_decode($data);
 	if(! function_exists('openssl_encrypt')) {
-	$aes = new Crypt_AES();
-	$aes->setKey($cryptkey);
-	$decryptdata = $aes->decrypt($cryptdata);
+		$aes = new Crypt_AES();
+		$aes->setKey($cryptkey);
+		$decryptdata = $aes->decrypt($cryptdata);
 	}
 	else {
 		static $key;
@@ -2973,7 +2973,7 @@ function getResourceGroupMemberships($ty
 		$qh = doQuery($query, 282);
 		while($row = mysql_fetch_assoc($qh))
 			$return[$type][$row["id"]][] = $row["groupid"];
-			}
+	}
 	return $return;
 }
 
@@ -3346,12 +3346,16 @@ function getAffiliationDataUpdateText($a
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getAffiliationTheme($affilid) {
-	$query = "SELECT theme FROM affiliation WHERE id = $affilid";
+	$query = "SELECT COALESCE(a1.theme, a2.theme) AS theme "
+	       . "FROM affiliation a1, "
+  	       .      "affiliation a2 "
+	       . "WHERE a1.id = $affilid AND "
+  	       .       "a2.name = 'Global'";
 	$qh = doQuery($query);
 	if(($row = mysql_fetch_assoc($qh)) && ! empty($row['theme']))
 		return $row['theme'];
 	else
-		return 'default';
+		return DEFAULTTHEME;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -4325,7 +4329,7 @@ function isAvailable($images, $imageid,
 				if($debug) {
 					$cnt = count($resources['computer']);
 					print "console.log('computers available to user: $cnt');";
-			}
+				}
 			}
 			$alloccompids = implode(",", $allocatedcompids);
 
@@ -7545,7 +7549,7 @@ function showTimeTable($links) {
 			if(array_key_exists('tzoffset', $_SESSION['persistdata']))
 				$label = date('n/d/Y+g:i+a', $stamp + $_SESSION['persistdata']['tzoffset'] * 60);
 			else
-			$label = date('n/d/Y+g:i+a', $stamp);
+				$label = date('n/d/Y+g:i+a', $stamp);
 			$label = str_replace('+', '&nbsp;', $label);
 			$yesterday = $stampArr["mday"];
 		}
@@ -7553,7 +7557,7 @@ function showTimeTable($links) {
 			if(array_key_exists('tzoffset', $_SESSION['persistdata']))
 				$label = date('g:i a', $stamp + $_SESSION['persistdata']['tzoffset'] * 60);
 			else
-			$label = date('g:i a', $stamp);
+				$label = date('g:i a', $stamp);
 		}
 		print "          <TH align=right>$label</TH>\n";
 		$free = 0;
@@ -13696,9 +13700,9 @@ function printHTMLFooter() {
 function changeLocale() {
 	global $locale, $authed, $authMechs;
 	if($authed) {
-	$newlocale = getContinuationVar('locale');
-	$oldmode = getContinuationVar('oldmode');
-	$authtype = getContinuationVar('authtype', '');
+		$newlocale = getContinuationVar('locale');
+		$oldmode = getContinuationVar('oldmode');
+		$authtype = getContinuationVar('authtype', '');
 	}
 	else {
 		$newlocale = processInputVar('locale', ARG_STRING);
@@ -13800,23 +13804,23 @@ function getSelectLanguagePulldown() {
 	$rt  = "<form name=\"localeform\" class=\"localeform\" action=\"" . BASEURL . SCRIPT
. "\" method=post>\n";
 	if($authed) {
 		$rt .= "<select name=\"continuation\" onChange=\"this.form.submit();\" autocomplete=\"off\">\n";
-	$cdata = array('IP' => $remoteIP, 'oldmode' => $mode);
-	if($mode == 'selectauth') {
-		$type = processInputVar('authtype', ARG_STRING);
-		if(! empty($type) && array_key_exists($type, $authMechs))
-			$cdata['authtype'] = $type;
-	}
-	foreach($locales as $dir => $lang) {
-		$cdata['locale'] = $dir;
-		$tmp = explode('/', $dir);
-		$testlocale = array_pop($tmp);
-		$cont = addContinuationsEntry('changeLocale', $cdata, 86400);
-		if($locale == $testlocale)
-			$rt .= "<option value=\"$cont\" selected>{$lang}</option>\n";
-		else
-			$rt .= "<option value=\"$cont\">{$lang}</option>\n";
-	}
-	$rt .= "</select>\n";
+		$cdata = array('IP' => $remoteIP, 'oldmode' => $mode);
+		if($mode == 'selectauth') {
+			$type = processInputVar('authtype', ARG_STRING);
+			if(! empty($type) && array_key_exists($type, $authMechs))
+				$cdata['authtype'] = $type;
+		}
+		foreach($locales as $dir => $lang) {
+			$cdata['locale'] = $dir;
+			$tmp = explode('/', $dir);
+			$testlocale = array_pop($tmp);
+			$cont = addContinuationsEntry('changeLocale', $cdata, 86400);
+			if($locale == $testlocale)
+				$rt .= "<option value=\"$cont\" selected>{$lang}</option>\n";
+			else
+				$rt .= "<option value=\"$cont\">{$lang}</option>\n";
+		}
+		$rt .= "</select>\n";
 	}
 	else {
 		$rt .= "<select name=\"locale\" onChange=\"this.form.submit();\" autocomplete=\"off\">\n";

Modified: vcl/trunk/web/js/siteconfig.js
URL: http://svn.apache.org/viewvc/vcl/trunk/web/js/siteconfig.js?rev=1793126&r1=1793125&r2=1793126&view=diff
==============================================================================
--- vcl/trunk/web/js/siteconfig.js (original)
+++ vcl/trunk/web/js/siteconfig.js Fri Apr 28 18:40:29 2017
@@ -290,7 +290,10 @@ AffilTextVariable.prototype.addAffiliati
 	if(dijit.byId(this.domidbase + 'newaffilid').options.length == 0)
 		dojo.addClass(this.domidbase + 'adddiv', 'hidden');
 	var keys = dojo.byId(this.domidbase + 'savekeys').value.split(',');
-	keys.push(data.items.id);
+	if(keys.length == 1 && keys[0] == '')
+		keys[0] = data.items.id;
+	else
+		keys.push(data.items.id);
 	dojo.byId(this.domidbase + 'savekeys').value = keys.join(',');
 }
 
@@ -302,7 +305,11 @@ AffilTextVariable.prototype.saveSettings
 			dijit.byId(keys[i]).focus();
 			return;
 		}
-		data[keys[i]] = dijit.byId(keys[i]).get('value');
+		var newval = dijit.byId(keys[i]).get('value');
+		if(newval === 0)
+			data[keys[i]] = 'zero';
+		else
+			data[keys[i]] = newval;
 	}
 	dijit.byId(this.domidbase + 'btn').set('disabled', true);
 	RPCwrapper(data, generalSiteConfigCB, 1);
@@ -337,6 +344,13 @@ function affilhelpaddr() {
 affilhelpaddr.prototype = new AffilTextVariable();
 var affilhelpaddr = new affilhelpaddr();
 
+function affilwebaddr() {
+	AffilTextVariable.apply(this, Array.prototype.slice.call(arguments));
+	this.domidbase = 'affilwebaddr';
+}
+affilwebaddr.prototype = new AffilTextVariable();
+var affilwebaddr = new affilwebaddr();
+
 function affilkmsserver() {
 	AffilTextVariable.apply(this, Array.prototype.slice.call(arguments));
 	this.domidbase = 'affilkmsserver';
@@ -351,6 +365,20 @@ function affiltheme() {
 affiltheme.prototype = new AffilTextVariable();
 var affiltheme = new affiltheme();
 
+function affilshibonly() {
+	AffilTextVariable.apply(this, Array.prototype.slice.call(arguments));
+	this.domidbase = 'affilshibonly';
+}
+affilshibonly.prototype = new AffilTextVariable();
+var affilshibonly = new affilshibonly();
+
+function affilshibname() {
+	AffilTextVariable.apply(this, Array.prototype.slice.call(arguments));
+	this.domidbase = 'affilshibname';
+}
+affilshibname.prototype = new AffilTextVariable();
+var affilshibname = new affilshibname();
+
 function GlobalSingleVariable() {}
 
 GlobalSingleVariable.prototype.saveSettings = function() {
@@ -551,7 +579,10 @@ function messages() {
 }
 messages.prototype.init = function() {
 	if(typeof dijit !== 'object' || dijit.byId('messagesselid') === undefined) {
-		setTimeout(this.init, 500);
+		if('init' in messages)
+			setTimeout(messages.init, 500);
+		else
+			setTimeout(messages.prototype.init, 500);
 		return;
 	}
 	messages.setContents(1);



Mime
View raw message