Index: /main/trunk/greenstone3/web/interfaces/default/transform/pages/authen.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/transform/pages/authen.xsl	(revision 32386)
+++ /main/trunk/greenstone3/web/interfaces/default/transform/pages/authen.xsl	(revision 32387)
@@ -40,5 +40,5 @@
 	<!-- set page breadcrumbs -->
 	<xsl:template name="breadcrumbs">
-		<gslib:siteLink/><gslib:rightArrow/><a href="{$library_name}/admin/ListUsers"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.authentication')"/></a>
+		<gslib:siteLink/><xsl:if test="/page/pageResponse/authenticationNode/service/@operation != 'AccountSettings' and /page/pageResponse/authenticationNode/service/@operation != 'Register'"><gslib:rightArrow/><a href="{$library_name}/admin/ListUsers"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.authentication')"/></a></xsl:if>
 	</xsl:template>
 	
@@ -53,7 +53,9 @@
 			<xsl:choose>
 				<!-- ********** -->
-				<!-- LOGIN PAGE -->
+				<!-- LOGIN PAGE: this page is used when the user has been directed to Login by trying to access a restricted page when they are not already logged in
+				If they click the login button, then the login.xsl is used -->
 				<!-- ********** -->
 				<xsl:when test="/page/pageResponse/authenticationNode/service/@operation = 'Login'">
+				  
 					<form method="POST" action="{$library_name}/admin/{/page/pageRequest/paramList/param[@name = 's1.authpage']/@value}">
 						<table id="loginTable">
@@ -273,45 +275,5 @@
 							</xsl:choose>						
 							<xsl:if test="/page/pageResponse/authenticationNode/service/@operation = 'EditUser'">
-								<tr>
-									<td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.groups')"/><xsl:text>: </xsl:text></td>
-									<td>
-										<input id="groupsInput" size="50" type="text" name="s1.groups" value="{/page/pageResponse/authenticationNode/service/userNodeList/userNode/@groups}"/>
-									</td>
-									<td>
-										<select id="groupSelector">
-											<option>COLLNAME-collection-editor</option>
-											<option>personal-collections-editor</option>
-											<option>all-collections-editor</option>
-											<option>administrator</option>
-										</select>
-									</td>
-									<td>
-										<button id="addGroupButton"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.add_group')"/></button>
-										<script type="text/javascript">
-											<xsl:text disable-output-escaping="yes">
-												var addGroupButton = document.getElementById("addGroupButton");
-												addGroupButton.onclick = function()
-												{
-													var groupsInput = document.getElementById("groupsInput");
-													var groupSelector = document.getElementById("groupSelector");
-													var options = groupSelector.getElementsByTagName("OPTION");
-													var selectedGroup = options[groupSelector.selectedIndex].innerHTML;
-													var currentValue = groupsInput.value;
-													
-													if(currentValue &amp;&amp; currentValue.search(/\w/) != -1)
-													{
-														groupsInput.value = currentValue + "," + selectedGroup;
-													}
-													else
-													{
-														groupsInput.value = selectedGroup;
-													}
-													return false;
-												}
-											</xsl:text>
-										</script>
-									</td>
-								</tr>
-								<tr><td colspan="4"><xsl:value-of select="util:getInterfaceText('default', /page/@lang, 'authen.group_desc')"/><ul><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.admin_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.all_coll_edit_desc')"/> </li> <li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.pers_coll_edit_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.single_coll_edit_desc')"/> </li></ul></td></tr>
+							  <xsl:call-template name="addGroupInputField"><xsl:with-param name="default_value"><xsl:value-of select="/page/pageResponse/authenticationNode/service/userNodeList/userNode/@groups"/></xsl:with-param></xsl:call-template>
 								<tr>
 									<td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.comment')"/><xsl:text>: </xsl:text></td>
@@ -343,23 +305,5 @@
 									<input id="submitButton" type="submit" value="{util:getInterfaceText($interface_name, /page/@lang, 'authen.submit')}"/>
 									<xsl:if test="/page/pageResponse/authenticationNode/service/@operation = 'AccountSettings'">
-										<script type="text/javascript">
-											<xsl:text disable-output-escaping="yes">
-												$("#submitButton").click(function()
-												{
-													var passwordOne = $("#passwordOne");
-													var passwordTwo = $("#passwordTwo");
-													
-													if(passwordOne.val() != passwordTwo.val())
-													{
-														alert("The passwords you have entered do not match");
-														return false;
-													}
-													else
-													{
-														return true;
-													}
-												});
-											</xsl:text>
-										</script>
+									  <xsl:call-template name="addPasswordCheckJavascript"/>
 									</xsl:if>
 								</td>
@@ -414,45 +358,5 @@
 							</tr>
 							<xsl:if test="/page/pageResponse/authenticationNode/service/@operation = 'AddUser'">
-								<tr>
-									<td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.groups')"/><xsl:text>: </xsl:text></td>
-									<td>
-										<input id="groupsInput" size="50" type="text" name="s1.groups"/>
-									</td>
-									<td>
-										<select id="groupSelector">
-										  <option>COLLNAME-collection-editor</option>
-											<option>personal-collections-editor</option>
-											<option>all-collections-editor</option>
-											<option>administrator</option>
-										</select>
-									</td>
-									<td>
-										<button id="addGroupButton"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.add_group')"/></button>
-										<script type="text/javascript">
-											<xsl:text disable-output-escaping="yes">
-												var addGroupButton = document.getElementById("addGroupButton");
-												addGroupButton.onclick = function()
-												{
-													var groupsInput = document.getElementById("groupsInput");
-													var groupSelector = document.getElementById("groupSelector");
-													var options = groupSelector.getElementsByTagName("OPTION");
-													var selectedGroup = options[groupSelector.selectedIndex].innerHTML;
-													var currentValue = groupsInput.value;
-													
-													if(currentValue &amp;&amp; currentValue.search(/\w/) != -1)
-													{
-														groupsInput.value = currentValue + "," + selectedGroup;
-													}
-													else
-													{
-														groupsInput.value = selectedGroup;
-													}
-													return false;
-												}
-											</xsl:text>
-										</script>
-									</td>
-								</tr>
-								<tr><td colspan="4"><xsl:value-of select="util:getInterfaceText('default', /page/@lang, 'authen.group_desc')"/><ul><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.admin_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.all_coll_edit_desc')"/> </li> <li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.pers_coll_edit_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.single_coll_edit_desc')"/> </li></ul></td></tr>
+							  <xsl:call-template name="addGroupInputField"/>
 								<tr>
 									<td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.comment')"/><xsl:text>: </xsl:text></td>
@@ -469,22 +373,12 @@
 								</tr>
 							</xsl:if>
-							<tr>
-							  <td colspan="2">
-							<div class="g-recaptcha" data-sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"><xsl:text> </xsl:text></div></td></tr>
+							<xsl:call-template name="addRecaptcha">
+							  <xsl:with-param name="formName">registerForm</xsl:with-param>
+							</xsl:call-template>
 							<tr>
 							  <td>
-							    <!-- need to add s1. to the name of g-recaptcha-response, so that it gets passed to the service -->
-								  <script type="text/javascript">
-								    <xsl:text disable-output-escaping="yes">
-									    $( "#registerForm").submit(function( event ) {
-									    var captchaelem = $("#g-recaptcha-response");
-									    captchaelem.attr("name", "s1.g-recaptcha-response");
-									    return true;
-									    });
-									    
-										</xsl:text>
-									</script>
-									<input id="submitButton" type="submit" value="{util:getInterfaceText($interface_name, /page/@lang, 'authen.submit')}"/>
-								</td>
+							    <input id="submitButton" type="submit" value="{util:getInterfaceText($interface_name, /page/@lang, 'authen.submit')}"/>
+							    <xsl:call-template name="addPasswordCheckJavascript"/>
+							  </td>
 							</tr>
 						</table>
@@ -515,5 +409,96 @@
 			</xsl:choose>
 		</div>
-	</xsl:template>
-	
+	      </xsl:template>
+
+	      <xsl:template name="addGroupInputField">
+		<xsl:param name="default_value"/>
+		<tr>
+		  <td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.groups')"/><xsl:text>: </xsl:text></td>
+		  <td>
+		    <input id="groupsInput" size="50" type="text" name="s1.groups" value="{$default_value}"/>
+		  </td>
+		  <td>
+		    <select id="groupSelector">
+		      <option>COLLNAME-collection-editor</option>
+		      <option>personal-collections-editor</option>
+		      <option>all-collections-editor</option>
+		      <option>administrator</option>
+		    </select>
+		  </td>
+		  <td>
+		    <button id="addGroupButton"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.add_group')"/></button>
+		    <script type="text/javascript">
+		      <xsl:text disable-output-escaping="yes">
+			var addGroupButton = document.getElementById("addGroupButton");
+			addGroupButton.onclick = function()
+			{
+			var groupsInput = document.getElementById("groupsInput");
+			var groupSelector = document.getElementById("groupSelector");
+			var options = groupSelector.getElementsByTagName("OPTION");
+			var selectedGroup = options[groupSelector.selectedIndex].innerHTML;
+			var currentValue = groupsInput.value;
+			
+			if(currentValue &amp;&amp; currentValue.search(/\w/) != -1)
+			{
+			groupsInput.value = currentValue + "," + selectedGroup;
+			}
+			else
+			{
+			groupsInput.value = selectedGroup;
+			}
+			return false;
+			}
+		      </xsl:text>
+		    </script>
+		  </td>
+		</tr>
+		<tr><td colspan="4"><xsl:value-of select="util:getInterfaceText('default', /page/@lang, 'authen.group_desc')"/><ul><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.admin_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.all_coll_edit_desc')"/> </li> <li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.pers_coll_edit_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.single_coll_edit_desc')"/> </li></ul></td></tr>
+
+	      </xsl:template>
+	      
+	      <xsl:template name="addPasswordCheckJavascript">
+		<script type="text/javascript">
+		  <xsl:text disable-output-escaping="yes">
+		    $("#submitButton").click(function()
+		    {
+		      var passwordOne = $("#passwordOne");
+		      var passwordTwo = $("#passwordTwo");
+		    
+		      if(passwordOne.val() != passwordTwo.val())
+		      {
+		        alert("The passwords you have entered do not match");
+		        return false;
+		      }
+		      else
+		      {
+		        return true;
+		      }
+		    });
+		  </xsl:text>
+		</script>
+		
+	      </xsl:template>
+
+	      <!-- adds in recaptcha box if the recaptcha_key attribute is set for authenticationNode/service - this is determined by operations element in Authentication serviceRack -->
+	      <xsl:template name="addRecaptcha">
+		<xsl:param name="formName"/>
+		<xsl:variable name="recaptcha_key"><xsl:value-of select="/page/pageResponse/authenticationNode/service/@recaptcha_key"/></xsl:variable>
+		<xsl:if test="$recaptcha_key">
+		<tr>
+		  <td colspan="2">
+		    <div class="g-recaptcha" data-sitekey="{$recaptcha_key}"><xsl:text> </xsl:text></div>
+		    <!-- need to add s1. to the name of g-recaptcha-response, so that it gets passed to the service -->
+		    <script type="text/javascript">
+		      <xsl:text disable-output-escaping="yes">
+			$( "#</xsl:text><xsl:value-of select="$formName"/><xsl:text disable-output-escaping="yes">").submit(function( event ) {
+			var captchaelem = $("#g-recaptcha-response");
+			captchaelem.attr("name", "s1.g-recaptcha-response");
+			return true;
+			});
+			
+		      </xsl:text>
+		    </script>
+		</td></tr>
+		</xsl:if>
+	      </xsl:template>
 </xsl:stylesheet>
