From 0f86b38d53ac90fea1fc69953f75b3c15910561f Mon Sep 17 00:00:00 2001
From: "Leigh B. Stoller" <stoller@flux.utah.edu>
Date: Fri, 25 Mar 2005 16:15:34 +0000
Subject: [PATCH] Commit final version of wikisetup, which is used to
 initialize the wiki pages for projects and users on an existing testbed. This
 assumes I can easily partition the actual twiki code into a distribution that
 we can give people. I haven't really thought much about that, but I assume
 its not too hard.

---
 wiki/wikisetup.in | 46 +++++++++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/wiki/wikisetup.in b/wiki/wikisetup.in
index ffc2cb678e..eb4f18c306 100644
--- a/wiki/wikisetup.in
+++ b/wiki/wikisetup.in
@@ -93,8 +93,9 @@ my %wikinames  = ();	# Indexed by wikiname.
 #
 $query_result =
     DBQueryFatal("select pid from groups where pid=gid ".
-		 "and (pid='testbed' or pid='emulab-ops' or pid='tbres' or ".
-		 "     pid='utahstud')");
+#		 "and (pid='testbed' or pid='emulab-ops' or pid='tbres' or ".
+#		 "     pid='utahstud')" .
+		 "");
 
 while (my ($pid) = $query_result->fetchrow_array()) {
     #
@@ -160,37 +161,40 @@ foreach my $pid (keys(%wikipids)) {
 # Now the users.
 # 
 $query_result =
-    DBQueryFatal("select distinct g.uid,u.usr_name,u.usr_email ".
+    DBQueryFatal("select distinct g.uid,u.usr_name,u.usr_email,u.wikiname ".
 		 "  from group_membership as g ".
 		 "left join users as u on u.uid=g.uid ".
-		 "where u.status='active' and ".
-		 "     (g.pid='testbed' or g.pid='emulab-ops' or ".
-		 "      g.pid='tbres' or g.pid='utahstud')");
+		 "where u.status='active' ".
+#		 "  and (g.pid='testbed' or g.pid='emulab-ops' or ".
+#		 "       g.pid='tbres' or g.pid='utahstud')" .
+		 "order by u.admin");
 
 my %wikiuids   = ();	# Indexed by user uid, gives wikiname.
 my %emailaddrs = ();	# Indexed by user uid, gives user email address.
 # Clear this for next loop.
 %wikinames = ();
 
-while (my ($uid,$name,$email) = $query_result->fetchrow_array()) {
+while (my ($uid,$name,$email,$wikiname) = $query_result->fetchrow_array()) {
     $emailaddrs{$uid} = $email;
 
-    #
-    # Split the user name up into tokens. 
-    #
-    my @tokens = split(/\s+|-/, $name);
+    if (!defined($wikiname) || $wikiname eq "") {
+	#
+	# Split the user name up into tokens. 
+	#
+	my @tokens = split(/\s+|-/, $name);
 
-    #
-    # Build a wikiname from the tokens. Lowercase each token, then
-    # captialize it, then run them all together. Oh, get rid of any
-    # non alphanum characters.
-    #
-    my $wikiname = "";
+	#
+	# Build a wikiname from the tokens. Lowercase each token, then
+	# captialize it, then run them all together. Oh, get rid of any
+	# non alphanum characters.
+	#
+	$wikiname = "";
 
-    foreach my $token (@tokens) {
-	$token = ucfirst(lc($token));
-	$token =~ s/\.//g;
-	$wikiname .= $token;
+	foreach my $token (@tokens) {
+	    $token = ucfirst(lc($token));
+	    $token =~ s/\.//g;
+	    $wikiname .= $token;
+	}
     }
     #print "$wikiname\n";
 
-- 
GitLab