From 0d31aec93d0e6aaad9d38b44cef4ee6f83e371e4 Mon Sep 17 00:00:00 2001
From: Eric Rasmussen <erasmussen2@unl.edu>
Date: Mon, 24 Aug 2009 18:55:06 +0000
Subject: [PATCH] registration checks to prevent use of "unl_" names

---
 .../views/default/account/forms/register.php  | 59 ++++++++++++++-----
 .../views/default/page_elements/unl_nav.php   |  2 +-
 2 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/unl_theme/views/default/account/forms/register.php b/unl_theme/views/default/account/forms/register.php
index 2238113a..ea5e2d3f 100644
--- a/unl_theme/views/default/account/forms/register.php
+++ b/unl_theme/views/default/account/forms/register.php
@@ -45,20 +45,51 @@
 	
 	<h2 class="sec_header"><?php echo elgg_echo('register'); ?></h2>
 	<div class="three_col left formCool">
-	<p>Huskers worldwide are encouraged to create an account in order to use the social network. Upon creating an account with the form below, 
-	you will be sent an email with a verification link. Click the link to gain access by activating your account.</p>
-	<?php echo elgg_view('input/form', array('action' => "{$vars['url']}action/register", 'body' => $form_body)) ?>
-	<p style="clear:both"><a <?php echo " href=\"". $vars['url'] ."account/register.php\">"?>Forgot your password?</a></p>
+		<div id="nojs-notice"><h1>You must have JavaScript enabled to register. Please enable JavaScript and refresh the page.</h1></div>
+		<div id="register-nojs" style="display:none;">
+			<p>Huskers worldwide are encouraged to create an account in order to use the social network. Upon creating an account with the form below, 
+		you will be sent an email with a verification link. Click the link to gain access by activating your account.</p>
+			<?php echo elgg_view('input/form', array('action' => "{$vars['url']}action/register", 'body' => $form_body)) ?>
+			<p style="clear:both"><a <?php echo " href=\"". $vars['url'] ."account/forgotten_password.php\">"?>Forgot your password?</a></p>
+		</div>
 	</div>
 	<div class="col right">
-	<div class="zenbox cool">
-	<h3>my.UNL Account Users</h3>
-	<p>If you have a my.UNL account (used for most UNL services, like Blackboard), then we have an account waiting for you without registering.</p>
-					<?php 
-						$form_body = "<p>";
-						$form_body .= elgg_view('input/submit', array('value' => elgg_echo('UNL Login'))) . "</p>";
-						$form_body .= "<p><a href=\"https://login.unl.edu/faq/account-resetpw.shtml\">" . elgg_echo('Forgot your my.UNL password?') . "</a></p>";
-						echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."?loginwith=UNLlogin"));
-					?>
+		<div class="zenbox cool">
+		<h3>my.UNL Account Users</h3>
+		<p>If you have a my.UNL account (used for most UNL services, like Blackboard), then we have an account waiting for you without registering.</p>
+						<?php 
+							$form_body = "<p>";
+							$form_body .= elgg_view('input/submit', array('value' => elgg_echo('UNL Login'))) . "</p>";
+							$form_body .= "<p><a href=\"https://login.unl.edu/faq/account-resetpw.shtml\">" . elgg_echo('Forgot your my.UNL password?') . "</a></p>";
+							echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."?loginwith=UNLlogin"));
+						?>
+		</div>
 	</div>
-	</div>
\ No newline at end of file
+	
+	<script type="text/javascript">
+		function validate_required(field){
+			with (field){
+			  if (value.match(/^unl_/i) != null){
+				  alert("Please select a username that does not begin with unl_");
+				  return false;
+			  }
+			  else
+			    return true;
+			}
+		}
+	
+		function validate_form(thisform){
+			with (thisform){
+			  if (validate_required(username)==false){
+				  username.focus();
+				  return false;
+			  }
+			}
+		}
+	
+		WDN.jQuery(document).ready(function(){
+			WDN.jQuery('#register-nojs').show();
+			WDN.jQuery('#nojs-notice').hide();
+			WDN.jQuery('div.formCool form').attr('onsubmit','return validate_form(this)');
+		});
+	</script>
\ No newline at end of file
diff --git a/unl_theme/views/default/page_elements/unl_nav.php b/unl_theme/views/default/page_elements/unl_nav.php
index 8ec1d924..078d2eeb 100644
--- a/unl_theme/views/default/page_elements/unl_nav.php
+++ b/unl_theme/views/default/page_elements/unl_nav.php
@@ -89,7 +89,7 @@
     } else {
 ?>
 <li <?php echo setSelectedTab('/account/register.php');?>>
-        <a href="<?php echo $vars['url']; ?>/account/register.php" ><span>Register</span></a>
+        <a href="<?php echo $vars['url']; ?>account/register.php" ><span>Register</span></a>
     </li>
     <li <?php echo setSelectedTab('#login');?>>
         <a href="<?php echo $vars['url']; ?>#login" ><span>Login</span></a>
-- 
GitLab