All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

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