Commit 9d882479 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add drop down menu to approve project form that allows admin person to

select the default user interface for a project. The choice is current
'emulab or 'plab', defaults to 'emulab'. New users that join emulab
get the default user interface from the first project they join.

Also generalize the plab_user bit as new "user_interface" slot of the
users table, which is an enum of interface tokens, currently either
'emulab' or 'plab', defaults to 'emulab'. The plab_user bit will be
removed later.
parent 443834cf
......@@ -50,6 +50,11 @@ if (isset($head_uid) && strcmp($head_uid,"")) {
"gid='$pid'");
}
if (!isset($user_interface) ||
!in_array($user_interface, $TBDB_USER_INTERFACE_LIST)) {
$user_interface = TBDB_USER_INTERFACE_EMULAB;
}
#
# Get the current status for the headuid, which we might need to change
# anyway, and to verify that the user is a valid user. We also need
......@@ -178,11 +183,11 @@ elseif (strcmp($approval, "approve") == 0) {
TBERROR("Invalid $headuid status $curstatus in ".
"approveproject.php3", 1);
}
DBQueryFatal("UPDATE users set status='$newstatus' ".
DBQueryFatal("UPDATE users set status='$newstatus', ".
" user_interface='$user_interface' ".
"WHERE uid='$headuid'");
}
#
# Change the trust value in group_membership to group_root, and set the
# project "approved" field to true.
......@@ -191,7 +196,9 @@ elseif (strcmp($approval, "approve") == 0) {
"set trust='project_root',date_approved=now() ".
"WHERE uid='$headuid' and pid='$pid' and gid='$pid'");
DBQueryFatal("UPDATE projects set approved='1' WHERE pid='$pid'");
DBQueryFatal("update projects set approved='1', ".
" default_user_interface='$user_interface' ".
"where pid='$pid'");
#
# XXX
......
......@@ -156,6 +156,20 @@ echo " </select>
</td>
</tr>\n";
#
# Set the user interface.
#
echo "<tr>
<td align=center>
Default User Interface:
<select name=user_interface>\n";
foreach ($TBDB_USER_INTERFACE_LIST as $interface) {
echo " <option value='$interface'>$interface</option>\n";
}
echo " </select>
</td>
</tr>\n";
#
# XXX
......
......@@ -202,7 +202,7 @@ while (list ($header, $value) = each ($HTTP_POST_VARS)) {
# 1. For our benefit
$$foo = $approval;
# 2. For the strcmp below's benefit
# 2. For the strcmp below.
$default_approval = $approval;
# 3. For the sanity check
......@@ -443,7 +443,12 @@ while (list ($header, $value) = each ($POST_VARS_COPY)) {
TBERROR("Invalid $user status $curstatus in approveuser.php3",
1);
}
DBQueryFatal("UPDATE users set status='$newstatus' ".
if (!($user_interface = TBGetDefaultProjectUserInterface($project)))
$user_interface = TBDB_USER_INTERFACE_EMULAB;
DBQueryFatal("UPDATE users set ".
" status='$newstatus', ".
" user_interface='$user_interface' ".
"WHERE uid='$user'");
#
......
......@@ -135,6 +135,12 @@ define("TBDB_IFACEROLE_FAKE", "fake");
define("TBDB_IFACEROLE_GW", "gw");
define("TBDB_IFACEROLE_OTHER", "other");
# User Interface types
define("TBDB_USER_INTERFACE_EMULAB", "emulab");
define("TBDB_USER_INTERFACE_PLAB", "plab");
$TBDB_USER_INTERFACE_LIST = array(TBDB_USER_INTERFACE_EMULAB,
TBDB_USER_INTERFACE_PLAB);
# Some regex functions to check various arguments
function TBvalid_uid($uid) {
global $TBDB_UIDLEN, $TBDB_MINLEN;
......@@ -1724,6 +1730,20 @@ function TBGetExptIdleIgnore($pid,$eid) {
return $row[idle_ignore];
}
#
# Get the default user interface that has been selected for the project.
#
function TBGetDefaultProjectUserInterface($pid) {
$query_result =
DBQueryWarn("select default_user_interface from projects ".
"where pid='$pid'");
if (mysql_num_rows($query_result) == 0) {
return 0;
}
$row = mysql_fetch_array($query_result);
return $row[0];
}
#
# Check if a site-specific variable exists.
......
......@@ -255,9 +255,9 @@ function SPITFORM($formfields, $errors)
</tr>\n";
#
# Planetlab bit
# Planetlab bit. This should really be a drop down menu of the choices.
#
if ($formfields['plab_user']) {
if ($formfields[user_interface] == TBDB_USER_INTERFACE_PLAB) {
$checked = "checked";
} else {
$checked = "";
......@@ -266,8 +266,10 @@ function SPITFORM($formfields, $errors)
echo "<tr>
<td colspan=2>Use simplified PlanetLab view:</td>
<td class=left>
<input type='checkbox' name=\"formfields[plab_user]\" value='1'
$checked>
<input type='checkbox'
name=\"formfields[user_interface]\"
value=\"" . TBDB_USER_INTERFACE_PLAB . "\"
$checked>
</td>
</tr>\n";
......@@ -388,7 +390,7 @@ $defaults[usr_title] = $row[usr_title];
$defaults[usr_affil] = $row[usr_affil];
$defaults[usr_shell] = $row[usr_shell];
$defaults[notes] = $row[notes];
$defaults[plab_user] = $row[plab_user];
$defaults[user_interface] = $row[user_interface];
#
# On first load, display a form consisting of current user values, and exit.
......@@ -605,10 +607,12 @@ if ($isadmin &&
#
# Change the plab bit to a simple 1 or 0
#
if ($formfields[plab_user]) {
$plab_bit = 1;
} else {
$plab_bit = 0;
if (isset($formfields[user_interface]) &&
$formfields[user_interface] == TBDB_USER_INTERFACE_PLAB) {
$user_interface = TBDB_USER_INTERFACE_PLAB;
}
else {
$user_interface = TBDB_USER_INTERFACE_EMULAB;
}
#
......@@ -628,7 +632,7 @@ if (strcmp($defaults[usr_name], $formfields[usr_name]) ||
strcmp($defaults[usr_title], $formfields[usr_title]) ||
strcmp($defaults[usr_affil], $formfields[usr_affil]) ||
strcmp($defaults[usr_shell], $formfields[usr_shell]) ||
strcmp($defaults[plab_user], $formfields[plab_user]) ||
strcmp($defaults[user_interface], $formfields[user_interface]) ||
# Check this too, since we want to call out if the email addr changed.
strcmp($defaults[usr_email], $formfields[usr_email])) {
......@@ -645,7 +649,7 @@ if (strcmp($defaults[usr_name], $formfields[usr_name]) ||
"usr_title=\"$usr_title\", ".
"usr_affil=\"$usr_affil\", ".
"usr_shell=\"$usr_shell\", ".
"plab_user=\"$plab_bit\", ".
"user_interface=\"$user_interface\", ".
"usr_modified=now() ".
"WHERE uid=\"$target_uid\"");
......
......@@ -148,7 +148,7 @@ function CHECKLOGIN($uid) {
$query_result =
DBQueryFatal("select NOW()>=u.pswd_expires,l.hashkey,l.timeout, ".
" status,admin,cvsweb,g.trust,adminoff,webonly, " .
" plab_user, n.type " .
" user_interface, n.type " .
" from users as u ".
"left join login as l on l.uid=u.uid ".
"left join group_membership as g on g.uid=u.uid ".
......@@ -180,7 +180,7 @@ function CHECKLOGIN($uid) {
}
$adminoff = $row[7];
$webonly = $row[8];
$plab = $row[9];
$interface= $row[9];
$type = $row[10];
......@@ -294,7 +294,7 @@ function CHECKLOGIN($uid) {
$CHECKLOGIN_STATUS |= CHECKLOGIN_TRUSTED;
if ($cvsweb)
$CHECKLOGIN_STATUS |= CHECKLOGIN_CVSWEB;
if ($plab)
if ($interface == TBDB_USER_INTERFACE_PLAB)
$CHECKLOGIN_STATUS |= CHECKLOGIN_PLABUSER;
if (strcmp($status, TBDB_USERSTATUS_NEWUSER) == 0)
$CHECKLOGIN_STATUS |= CHECKLOGIN_NEWUSER;
......@@ -436,14 +436,14 @@ function ISPLABUSER() {
return 0;
}
$query_result =
DBQueryFatal("SELECT plab_user FROM users WHERE uid='$uid'");
DBQueryFatal("SELECT user_interface FROM users WHERE uid='$uid'");
if (!mysql_num_rows($query_result)) {
return 0;
}
$row = mysql_fetch_row($query_result);
if ($row[0]) {
return 1;
return ($row[0] == TBDB_USER_INTERFACE_PLAB);
} else {
return 0;
}
......
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