Commit 395e0e0e authored by Kevin Atkinson's avatar Kevin Atkinson

Add "Affiliation Abbreviation" field to users table and use it next to

the User Name (or id) in various tables.  This also involved adding
the field to the newproject, joinproject, and moduserinfo forms.

Note: also modified 4.149 database-migrate.txt entry to add a note
to add the necessary "slot" to table_regex.
parent 4d797f17
......@@ -154,7 +154,8 @@ my %usually_required = ("address" => "usr_addr",
"country" => "usr_country",
"phone" => "usr_phone",
"title" => "usr_title",
"affiliation" => "usr_affil");
"affiliation" => "usr_affil",
"affiliation_abbreviation" => "usr_affil_abbrev");
if ($type eq "wikionly") {
%optional = (%optional, %usually_required);
} else {
......
......@@ -136,6 +136,7 @@ my %xmlfields =
"usr_name" => ["usr_name", $SLOT_OPTIONAL],
"usr_title" => ["usr_title", $SLOT_OPTIONAL],
"usr_affil" => ["usr_affil", $SLOT_OPTIONAL],
"usr_affil_abbrev" => ["usr_affil_abbrev", $SLOT_OPTIONAL],
"usr_shell" => ["usr_shell", $SLOT_OPTIONAL],
"usr_URL" => ["usr_URL", $SLOT_OPTIONAL],
"usr_email" => ["usr_email", $SLOT_OPTIONAL],
......
......@@ -145,6 +145,7 @@ sub modified($) { return field($_[0], "usr_modified"); }
sub name($) { return field($_[0], "usr_name"); }
sub title($) { return field($_[0], "usr_title"); }
sub affil($) { return field($_[0], "usr_affil"); }
sub affil_abbrev($) { return field($_[0], "usr_affil_abbrev"); }
sub email($) { return field($_[0], "usr_email"); }
sub URL($) { return field($_[0], "usr_URL"); }
sub addr($) { return field($_[0], "usr_addr"); }
......@@ -807,7 +808,8 @@ sub ModUserInfo($$$$)
# (Others above already did their own updates.)
#
my %updates;
foreach my $col ("usr_name", "usr_title", "usr_affil", "usr_URL",
foreach my $col ("usr_name", "usr_title", "usr_affil", "usr_affil_abbrev",
"usr_URL",
"usr_addr", "usr_addr2", "usr_city", "usr_state",
"usr_zip", "usr_country", "usr_phone", "usr_shell") {
# Copy args we want so that others can't get through.
......@@ -832,6 +834,7 @@ sub ModUserInfo($$$$)
# Send an audit e-mail reporting what is being changed.
my @report = ("Name:usr_name", "Email:usr_email",
"Job Title:usr_title", "Affiliation:usr_affil",
"Affiliation Abbreviation:usr_affil_abbrev",
"URL:usr_URL", "Address1:usr_addr",
"Address2:usr_addr2", "City:usr_city",
"State:usr_state", "ZIP/Postal Code:usr_zip",
......
......@@ -604,6 +604,7 @@ REPLACE INTO table_regex VALUES ('users','usr_email','text','regex','^([-\\w\\+\
REPLACE INTO table_regex VALUES ('users','usr_shell','text','regex','^(csh|sh|bash|tcsh|zsh)$',0,0,NULL);
REPLACE INTO table_regex VALUES ('users','usr_title','text','redirect','default:tinytext',0,0,NULL);
REPLACE INTO table_regex VALUES ('users','usr_affil','text','redirect','default:tinytext',0,0,NULL);
REPLACE INTO `table_regex` VALUES ('users','usr_affil_abbrev','text','regex','^[\\040-\\176]*$',0,16,NULL);
REPLACE INTO table_regex VALUES ('users','usr_addr','text','redirect','default:tinytext',0,0,NULL);
REPLACE INTO table_regex VALUES ('users','usr_addr2','text','redirect','default:tinytext',0,0,NULL);
REPLACE INTO table_regex VALUES ('users','usr_state','text','redirect','default:tinytext',0,0,NULL);
......
......@@ -4478,10 +4478,13 @@ last_net_act,last_cpu_act,last_ext_act);
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
4.149: Add usr_affil_abbrev column to users and deleted users tables
and add 'slot' to table_regex
alter table users add usr_affil_abbrev varchar(16) after usr_affil;
alter table deleted_users add usr_affil_abbrev varchar(16) after usr_affil;
REPLACE INTO `table_regex` VALUES ('users','usr_affil_abbrev','text','regex','^[\\040-\\176]*$',0,16,NULL);
4.150: Improvements to the sslcerts table for GENI support.
Generally, its nice to support real revocation, but
specifically, we want to remember expired and revoked
......@@ -4497,4 +4500,3 @@ last_net_act,last_cpu_act,last_ext_act);
add `password` tinytext,
add KEY `uid` (`uid`),
add KEY `uid_idx` (`uid_idx`);
......@@ -238,6 +238,10 @@ function TBvalid_title($token) {
function TBvalid_affiliation($token) {
return TBvalid_userdata($token);
}
function TBvalid_affiliation_abbreviation($token) {
return TBcheck_dbslot($token, "users", "usr_affil_abbrev",
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR);
}
function TBvalid_addr($token) {
return TBvalid_userdata($token);
}
......
......@@ -1131,6 +1131,7 @@ class Group
echo "<thead class='sort'>";
echo "<tr>
<th>Name</th>\n";
echo "<th>Affiliation</th>\n";
if (! $projgrp) {
echo "<th>Email</th>\n";
}
......@@ -1149,6 +1150,7 @@ class Group
TBERROR("Could not lookup object for user $uid_idx", 1);
}
$usr_name = $target_user->name();
$usr_affil = $target_user->affil_abbrev();
$usr_email = $target_user->email();
$usr_uid = $target_user->uid();
$showuser_url = CreateURL("showuser", $target_user);
......@@ -1157,6 +1159,8 @@ class Group
echo "<tr>
<td>$usr_name</td>\n";
echo "<td>$usr_affil</td>\n";
if (! $projgrp) {
echo "<td>$usr_email</td>\n";
}
......
......@@ -238,12 +238,23 @@ function SPITFORM($formfields, $returning, $errors)
# Affiliation:
#
echo "<tr>
<td colspan=2>*Institutional<br>Affiliation:</td>
<td colspan=2>*Institutional Affiliation:</td>
<td class=left>
<input type=text
<table>
<tr>
<td>Name</td>
<td><input type=text
name=\"formfields[usr_affil]\"
value=\"" . $formfields["usr_affil"] . "\"
size=40>
size=40></td></tr>
<tr>
<td>Abbreviation:</td>
<td><input type=text
name=\"formfields[usr_affil_abbrev]\"
value=\"" . $formfields["usr_affil_abbrev"] . "\"
size=16 maxlength=16> (e.g. MIT)</td>
</tr>
</table>
</td>
</tr>\n";
......@@ -491,6 +502,7 @@ if (! isset($submit)) {
$defaults["usr_phone"] = "";
$defaults["usr_title"] = "";
$defaults["usr_affil"] = "";
$defaults["usr_affil_abbrev"] = "";
$defaults["password1"] = "";
$defaults["password2"] = "";
$defaults["wikiname"] = "";
......@@ -573,10 +585,17 @@ if (! $returning) {
}
if (!isset($formfields["usr_affil"]) ||
strcmp($formfields["usr_affil"], "") == 0) {
$errors["Affiliation"] = "Missing Field";
$errors["Affiliation Name"] = "Missing Field";
}
elseif (! TBvalid_affiliation($formfields["usr_affil"])) {
$errors["Affiliation"] = TBFieldErrorString();
$errors["Affiliation Name"] = TBFieldErrorString();
}
if (!isset($formfields["usr_affil_abbrev"]) ||
strcmp($formfields["usr_affil_abbrev"], "") == 0) {
$errors["Affiliation Abbreviation"] = "Missing Field";
}
elseif (! TBvalid_affiliation_abbreviation($formfields["usr_affil"])) {
$errors["Affiliation Name"] = TBFieldErrorString();
}
}
if (!isset($formfields["usr_email"]) ||
......@@ -738,6 +757,7 @@ if (! $returning) {
$args["shell"] = 'tcsh';
$args["title"] = $formfields["usr_title"];
$args["affiliation"] = $formfields["usr_affil"];
$args["affiliation_abbreviation"] = $formfields["usr_affil_abbrev"];
$args["password"] = $formfields["password1"];
$args["wikiname"] = ($WIKISUPPORT ? $formfields["wikiname"] : "");
......
......@@ -125,12 +125,23 @@ function SPITFORM($formfields, $errors)
# Affiliation:
#
echo "<tr>
<td colspan=2>${optfield}Institutional<br>Affiliation:</td>
<td colspan=2>*Institutional Affiliation:</td>
<td class=left>
<input type=text
<table>
<tr>
<td>Name</td>
<td><input type=text
name=\"formfields[usr_affil]\"
value=\"" . $formfields["usr_affil"] . "\"
size=40>
size=40></td></tr>
<tr>
<td>Abbreviation:</td>
<td><input type=text
name=\"formfields[usr_affil_abbrev]\"
value=\"" . $formfields["usr_affil_abbrev"] . "\"
size=16 maxlength=16> (e.g. MIT)</td>
</tr>
</table>
</td>
</tr>\n";
......@@ -414,6 +425,7 @@ if (!isset($submit)) {
$defaults["usr_phone"] = $target_user->phone();
$defaults["usr_title"] = $target_user->title();
$defaults["usr_affil"] = $target_user->affil();
$defaults["usr_affil_abbrev"] = $target_user->affil_abbrev();
$defaults["usr_shell"] = $target_user->shell();
$defaults["notes"] = $target_user->notes();
$defaults["password1"] = "";
......@@ -495,6 +507,10 @@ if (isset($formfields["usr_affil"]) && $formfields["usr_affil"] != "" &&
$formfields["usr_affil"] != $target_user->affil()) {
$args["usr_affil"] = $formfields["usr_affil"];
}
if (isset($formfields["usr_affil_abbrev"]) && $formfields["usr_affil_abbrev"] != "" &&
$formfields["usr_affil"] != $target_user->affil_abbrev()) {
$args["usr_affil_abbrev"] = $formfields["usr_affil_abbrev"];
}
if (isset($formfields["usr_shell"]) && $formfields["usr_shell"] != "" &&
$formfields["usr_shell"] != $target_user->shell()) {
$args["usr_shell"] = $formfields["usr_shell"];
......
......@@ -238,12 +238,23 @@ function SPITFORM($formfields, $returning, $errors)
# Affiliation:
#
echo "<tr>
<td colspan=2>*Institutional<br>Affiliation:</td>
<td colspan=2>*Institutional Affiliation:</td>
<td class=left>
<input type=text
<table>
<tr>
<td>Name</td>
<td><input type=text
name=\"formfields[usr_affil]\"
value=\"" . $formfields["usr_affil"] . "\"
size=40>
size=40></td></tr>
<tr>
<td>Abbreviation:</td>
<td><input type=text
name=\"formfields[usr_affil_abbrev]\"
value=\"" . $formfields["usr_affil_abbrev"] . "\"
size=16 maxlength=16> (e.g. MIT)</td>
</tr>
</table>
</td>
</tr>\n";
......@@ -603,6 +614,7 @@ if (! isset($submit)) {
$defaults["wikiname"] = "";
$defaults["usr_title"] = "";
$defaults["usr_affil"] = "";
$defaults["usr_affil_abbrev"] = "";
$defaults["usr_URL"] = "$HTTPTAG";
$defaults["usr_email"] = "";
$defaults["usr_addr"] = "";
......@@ -706,10 +718,17 @@ if (! $returning) {
}
if (!isset($formfields["usr_affil"]) ||
strcmp($formfields["usr_affil"], "") == 0) {
$errors["Affiliation"] = "Missing Field";
$errors["Affiliation Name"] = "Missing Field";
}
elseif (! TBvalid_affiliation($formfields["usr_affil"])) {
$errors["Affiliation"] = TBFieldErrorString();
$errors["Affiliation Name"] = TBFieldErrorString();
}
if (!isset($formfields["usr_affil_abbrev"]) ||
strcmp($formfields["usr_affil_abbrev"], "") == 0) {
$errors["Affiliation Abbreviation"] = "Missing Field";
}
elseif (! TBvalid_affiliation_abbreviation($formfields["usr_affil"])) {
$errors["Affiliation Name"] = TBFieldErrorString();
}
if (!isset($formfields["usr_email"]) ||
strcmp($formfields["usr_email"], "") == 0) {
......@@ -904,6 +923,7 @@ if (!$returning) {
$args["shell"] = 'tcsh';
$args["title"] = $formfields["usr_title"];
$args["affiliation"] = $formfields["usr_affil"];
$args["affiliation_abbreviation"] = $formfields["usr_affil_abbrev"];
$args["password"] = $formfields["password1"];
$args["wikiname"] = ($WIKISUPPORT ? $formfields["wikiname"] : "");
......
......@@ -384,6 +384,8 @@ if ($thumb && !$idle) {
TBERROR("Could not lookup object for user $huid", 1);
}
$showuser_url = CreateURL("showuser", $head_user);
$head_affil = $head_user->affil_abbrev();
$head_affil_text = $head_affil ? "&nbsp;($head_affil)" : "";
if ($idle && ($str=="&nbsp;" || !$pcs)) { continue; }
......@@ -446,7 +448,7 @@ if ($thumb && !$idle) {
}
echo "<font size=-2><b>Created by:</b> ".
"<a href='$showuser_url'>$huid</a>".
"<a href='$showuser_url'>$huid</a>$head_affil_text".
"</font><br />\n";
$special = 0;
......@@ -544,6 +546,9 @@ if ($thumb && !$idle) {
TBERROR("Could not lookup object for user $huid", 1);
}
$showuser_url = CreateURL("showuser", $head_user);
$head_affil = $head_user->affil_abbrev();
$head_affil_text = $head_affil ? "&nbsp;($head_affil)" : "";
if ($swapreqs && !$isidle) {
$swapreqs = "";
......@@ -695,7 +700,7 @@ if ($thumb && !$idle) {
echo "<td>$name</td>\n";
}
echo "<td><A href='$showuser_url'>$huid</A></td>\n";
echo "<td><A href='$showuser_url'>$huid</A>$head_affil_text</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
......
......@@ -156,6 +156,7 @@ function GENPLIST ($query_result)
echo "<th>PID</th>\n";
echo "<th>(Approved?) Description</th>\n";
echo "<th>Leader</th>\n";
echo "<th>Affil</th>\n";
echo "<th>Days<br>Idle</th>\n";
echo "<th>Expts<br>Created</th>\n";
echo "<th>Expts<br>Run</th>\n";
......@@ -188,6 +189,7 @@ function GENPLIST ($query_result)
}
$showuser_url = CreateURL("showuser", $head_user);
$headuid = $head_user->uid();
$affil = $head_user->affil_abbrev();
echo "<tr>
<td><A href='showproject.php3?pid=$pid'>$pid</A></td>
......@@ -200,6 +202,7 @@ function GENPLIST ($query_result)
}
echo " $Pname</td>
<td><A href='$showuser_url'>$headuid</A></td>\n";
echo "<td>$affil</td>\n";
echo "<td>$idle</td>\n";
echo "<td>$expt_count</td>\n";
......
......@@ -167,6 +167,7 @@ echo "<tr>
<th>&nbsp</th>
<th>UID</th>
<th>Name</th>
<th>Affiliation</th>
<th>Projects</th>\n";
if (! strcmp($showtype, "inactive")) {
......@@ -183,6 +184,7 @@ while ($row = mysql_fetch_array($query_result)) {
$thisuid = $row["uid"];
$webid = $row["uid_idx"];
$name = $row["usr_name"];
$affil = $row["usr_affil_abbrev"];
$status = $row["status"];
$unix_uid = $row["unix_uid"];
$webidle = $row["webidle"];
......@@ -200,7 +202,8 @@ while ($row = mysql_fetch_array($query_result)) {
}
echo "<td><A href='$showuser_url'>$thisuid</A></td>
<td>$name</td>\n";
<td>$name</td>
<td>$affil</td>\n";
# List of projects.
reset($projmemb_array);
......
......@@ -252,6 +252,7 @@ class User
function name() { return $this->field("usr_name"); }
function title() { return $this->field("usr_title"); }
function affil() { return $this->field("usr_affil"); }
function affil_abbrev() { return $this->field("usr_affil_abbrev"); }
function email() { return $this->field("usr_email"); }
function URL() { return $this->field("usr_URL"); }
function addr() { return $this->field("usr_addr"); }
......@@ -647,6 +648,7 @@ class User
$usr_shell = $user->shell();
$usr_title = $user->title();
$usr_affil = $user->affil();
$usr_affil_abbrev = $user->affil_abbrev();
$status = $user->status();
$admin = $user->admin();
$notes = $user->notes();
......@@ -777,6 +779,11 @@ class User
<td>$usr_affil</td>
</tr>\n";
echo "<tr>
<td>Institutional Abbreviation:</td>
<td>$usr_affil_abbrev</td>
</tr>\n";
echo "<tr>
<td>Status:</td>
<td>$status</td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment