Index: admin/include/lib/vulab.users.class.php
===================================================================
--- admin/include/lib/vulab.users.class.php	(revision 6566)
+++ admin/include/lib/vulab.users.class.php	(working copy)
@@ -35,7 +35,28 @@
 				$u['researcher'],
 				$u['disabled']) = $user_result->fields;	
 
+	if ($u['researcher'] = 'Y') {
 	
+		$researchSQL = "SELECT * FROM designer WHERE username = '".$u['username']."'";
+		$research_result = execute_sql($researchSQL);
+		list(	$researcher['username'],
+				$researcher['password'],
+				$researcher['auth'],
+				$researcher['realm'],
+				$researcher['fname'],
+				$researcher['lname'],
+				$researcher['email'],
+				$researcher['pdesign'],
+				$researcher['pstatus'],
+				$researcher['pdata'],
+				$researcher['pall'],
+				$researcher['pgroup'],
+				$researcher['puser'],
+				$researcher['disabled'],
+				$researcher['changed'],
+				$researcher['expiration'] ) = $research_result->fields;
+		$u['designer'] = $researcher;
+	}
 	$u = array_reverse($u);
 	
 	//load details
 
Index: admin/signup.php
===================================================================
--- admin/signup.php	(revision 6566)
+++ admin/signup.php	(working copy)
@@ -11,7 +11,30 @@
 *******************************************************************************/
 ?>
 <?php
-error_reporting(E_ALL);
+
+	unset($found_user);
+	
+	# inital includes
+	require_once 'include_all.php';
+	require_once ($ESPCONFIG['include_path']."/lib/vulabdatalib.php");
+    esp_init_adodb();
+    
+	# lets see if there are any users in the database
+	$users_sql = 'SELECT * FROM user';
+	$users_res = execute_sql($users_sql);
+	if (!$users_res) {
+	}
+	$users_num = $users_res->RecordCount();
+    
+    if ($users_num > 0) { $found_user = true; } else { $found_user = false; }
+
+    # if there is no users found, aka this is the first user, lets make them a superuser
+    if ($found_user == true) {
+    	$realm = 'auto';
+    } else {
+    	$realm = 'superuser';
+    }    
+
 if (isset($_REQUEST['Register']))
 {
 	$required_fields = array(
@@ -35,18 +58,17 @@
 		if (!($_REQUEST[$field] == $_REQUEST['c'.$field]))
 			error_non_confirmed();
 	}
-	require_once 'include_all.php';
-	require_once ($ESPCONFIG['include_path']."/lib/vulabdatalib.php");
-    esp_init_adodb();
+    
+    	
     $sql = "INSERT INTO $ESPCONFIG[user_table] VALUES('','$_REQUEST[username]',PASSWORD('$_REQUEST[password]'),'$_REQUEST[fname]','$_REQUEST[lname]','$_REQUEST[email]','$_REQUEST[type]','N')";
     $result = execute_sql($sql);
     
     if ($_REQUEST['type'] == 'Y')
     {
-	    $sql = "INSERT INTO `designer` VALUES ('$_REQUEST[username]',PASSWORD('$_REQUEST[password]'),'BASIC','auto','$_REQUEST[fname]','$_REQUEST[lname]','$_REQUEST[email]','Y','N','N','N','N','N','N',now(),NULL)";
+	    $sql = "INSERT INTO `designer` VALUES ('$_REQUEST[username]',PASSWORD('$_REQUEST[password]'),'BASIC','$realm','$_REQUEST[fname]','$_REQUEST[lname]','$_REQUEST[email]','Y','N','N','N','N','N','N',now(),NULL)";
     	$result = execute_sql($sql);
 	}
-	$sql = "INSERT INTO `respondent` VALUES('$_REQUEST[username]',PASSWORD('$_REQUEST[password]'),'BASIC','auto','$_REQUEST[fname]','$_REQUEST[lname]','$_REQUEST[email]','N',now(),NULL)";
+	$sql = "INSERT INTO `respondent` VALUES('$_REQUEST[username]',PASSWORD('$_REQUEST[password]'),'BASIC','$realm','$_REQUEST[fname]','$_REQUEST[lname]','$_REQUEST[email]','N',now(),NULL)";
 		
     $result = execute_sql($sql);
     
@@ -107,8 +129,27 @@
 <label for="password">Confirm E-Mail Address:</label><input type="text" name="cemail" />
 </div><div class="row">
 <label for="password">I am a:</label><select name="type">
+<?php
+	# lets see if there are any users in the database
+	$users_sql = 'SELECT * FROM user';
+	$users_res = execute_sql($users_sql);
+	if (!$users_res) {
+	}
+	$users_num = $users_res->RecordCount();
+	
+	echo $users_num;
+# if there are no users, lets make the first user a researcher aka admin aka superuser aka root
+ if ($users_num < 1) {
+?>
+	<option value="Y">Admin User</option>
+<?php
+} else {
+?>
 	<option value="Y">Researcher</option>
 	<option value="N" SELECTED>Tester</option>
+<?php
+}
+?>
 </select>
 </div><div class="row">
 <input type="submit" name="Register" value="Submit" /><input type="reset" value="Clear" /></div></fieldset>
Index: admin/manage.php
===================================================================
--- admin/manage.php	(revision 6566)
+++ admin/manage.php	(working copy)
@@ -20,7 +20,6 @@
 	if (!empty($_SESSION['survey_id'])) { unset($_SESSION['survey_id']); }
 	if (!empty($_SESSION['new_survey'])) { unset($_SESSION['new_survey']); }
 }
-
 //ini_set('display_errors','0');
 
     /* $Id: manage.php,v 1.32 2007/12/10 12:15:55 liedekef Exp $ */
@@ -116,9 +115,11 @@
             'disabled'  => 'N'
         );
     }
-	
 	if($_SESSION['acl']) {
 		$user = new User($_SESSION['acl']['userid']);
+		if ($user->details['designer']['realm'] == 'superuser') {
+			$superuser = true;
+		}
 		if ($user->details['researcher'] == 'Y') {
 			$interface = 'researcher';
 			$interface_suffix = '';
@@ -141,9 +142,7 @@
         include(esp_where($where));
         exit;
     }
-    
-    if ($_SESSION['acl']['username'] == 'root')
-		$_SESSION['acl']['superuser'] = 'Y';
+    if ($superuser === true) { $_SESSION['acl']['superuser'] = 'Y'; }
 ?>
 
 <?php if (@$_GET[lay] != 'ajax') { ?>
