Commit ea5680c9 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Database changes: Get rid of group table and make it the project table.

Also change grp_memb to proj_memb.
parent 72ec2795
......@@ -28,24 +28,23 @@ they will be able to log into machines in your Project's experiments.</p>
more or less access to your nodes:
<ul>
<li>User - Can log into machines in your experiments.
<li>Local Root - Granted root access on your project's machines; can create new experiments.
";
#echo "<li>Group Root - Can approve users, create projects, and update any project info or personal info for project members.";
echo "</ul>
</p></h3>\n";
$query="SELECT gid FROM grp_memb WHERE uid='$auth_usr' and trust='group_root'";
<li>Root - Granted root access on your project's machines;
can create new experiments.
</ul></p></h3>\n";
$query="SELECT pid FROM proj_memb WHERE uid='$auth_usr' and trust='group_root'";
$result = mysql_db_query("tbdb", $query);
$select = "SELECT";
while ($row = mysql_fetch_row($result)) {
$gid = $row[0];
$pid = $row[0];
if ($select == "SELECT") {
$select .= " DISTINCT uid FROM grp_memb WHERE gid='$gid'";
$select .= " DISTINCT uid FROM proj_memb WHERE pid='$pid'";
} else {
$select .= " OR gid='$gid'";
$select .= " OR pid='$pid'";
}
}
if ($select=="SELECT") {
echo "<h3>You do not have Group Root permissions in any group.</h3>";
echo "<h3>You do not have Project Root permissions in any Project</h3>";
echo "</body></html>\n";
exit;
}
......@@ -102,8 +101,7 @@ if ( mysql_num_rows($found) == 0 ) {
<option value='later'>Postpone</option></select></td>
<td rowspan=2><select name=\"$uid-trust\">
<option value='user'>User</option>
<option value='local_root'>Local Root</option>";
#echo "<option value='group_root'>Group Root</option>";
<option value='local_root'>Root</option>";
echo "</select></td>
<td rowspan=2>&nbsp;$uid&nbsp;</td><td>&nbsp;$name&nbsp;</td><td>&nbsp;$title&nbsp;</td><td>&nbsp;$affil&nbsp;</td><td>&nbsp;$email&nbsp;</td><td>&nbsp;$phone&nbsp;</td></tr>
<tr><td>&nbsp;$addr&nbsp;</td><td>&nbsp;$addr2&nbsp;</td><td>&nbsp;city&nbsp;</td><td>&nbsp;$state&nbsp;</td><td>&nbsp;$zip&nbsp;</td>
......
......@@ -23,19 +23,19 @@ LOGGEDINORDIE($auth_usr);
echo "
<h1>Approving new users...</h1>
";
$query="SELECT gid FROM grp_memb WHERE uid='$auth_usr' and trust='group_root'";
$query="SELECT pid FROM proj_memb WHERE uid='$auth_usr' and trust='group_root'";
$result = mysql_db_query("tbdb", $query);
$select = "SELECT";
$group[0]="";
$project[0]="";
$n=0;
while ($row = mysql_fetch_row($result)) {
$gid = $row[0];
$group[$n]=$gid;
$pid = $row[0];
$project[$n]=$pid;
$n = $n + 1;
if ($select == "SELECT") {
$select .= " DISTINCT uid FROM grp_memb WHERE gid='$gid'";
$select .= " DISTINCT uid FROM proj_memb WHERE pid='$pid'";
} else {
$select .= " OR gid='$gid'";
$select .= " OR pid='$pid'";
}
}
$selected = mysql_db_query("tbdb", $select);
......@@ -54,14 +54,14 @@ while ($row = mysql_fetch_row($found)) {
$uid = $row[0];
$status=$row[1];
$email=$row[2];
$cmd = "select gid from grp_memb where uid='$uid' and trust='none' and (";
$cmd .= "gid='$group[0]'";
$cmd = "select pid from proj_memb where uid='$uid' and trust='none' and (";
$cmd .= "pid='$project[0]'";
$n=1;
while ( isset($group[$n]) ) { $cmd .= " or gid='$group[$n]'"; $n++; }
while ( isset($project[$n]) ) { $cmd .= " or pid='$project[$n]'"; $n++; }
$cmd .=")";
$result = mysql_db_query("tbdb",$cmd);
$row=mysql_fetch_row($result);
$gid=$row[0];
$pid=$row[0];
if (isset($$uid)) {
if ( $$uid == "approve") {
$trust=${"$uid-trust"};
......@@ -73,43 +73,39 @@ while ($row = mysql_fetch_row($found)) {
$cmd = "update users set status='$newstatus' where uid='$uid'";
$cmd .= "and status='$status'";
$result = mysql_db_query("tbdb",$cmd);
$cmd = "update grp_memb set trust='$trust' where uid='$uid'";
$cmd .= "and trust='none' and gid='$gid'";
$result = mysql_db_query("tbdb",$cmd);
#
# Bogus grp vs proj issue.
#
$cmd = "insert into proj_memb (uid, pid) values ('$uid', '$gid')";
$cmd = "update proj_memb set trust='$trust' where uid='$uid'";
$cmd .= "and trust='none' and pid='$pid'";
$result = mysql_db_query("tbdb",$cmd);
mail("$email","TESTBED: Group Approval",
mail("$email","TESTBED: Project Membership Approval",
"\nThis message is to notify you that you have been approved ".
"as a member of \nthe $gid group with $trust permissions.\n".
"as a member of \nthe $pid project with $trust permissions.\n".
"\nYour status as a Testbed user is now $newstatus.".
"\n\nThanks,\nTestbed Ops\nUtah Network Testbed\n",
"From: Testbed Ops <testbed-ops@flux.cs.utah.edu>\n".
"Cc: Testbed WWW <testbed-www@flux.cs.utah.edu>\n".
"Errors-To: Testbed WWW <testbed-www@flux.cs.utah.edu>");
echo "<h3><p>User $uid was changed to status $newstatus and ";
echo "granted $trust permissions for group $gid.</p></h3>\n";
echo "granted $trust permissions for project $pid.</p></h3>\n";
} elseif ( $$uid == "deny") {
# Delete all rows from grp memb that are for that person, no privs
# and one of the groups that the user is a leader of
$cmd = "delete from grp_memb where uid='$uid' and trust='none' and (";
$cmd .= "gid='$group[0]'";
# Delete all rows from proj_memb that are for that person, no privs
# and one of the projects that the user is a leader of
$cmd = "delete from proj_memb where uid='$uid' and trust='none' and (";
$cmd .= "pid='$project[0]'";
$n=1;
while ( isset($group[$n]) ) { $cmd .= " or gid='$group[$n]'"; $n++; }
while ( isset($project[$n]) ) { $cmd .= " or pid='$project[$n]'"; $n++; }
$cmd .=")";
$result = mysql_db_query("tbdb",$cmd);
mail("$email","TESTBED: Group Membership Denied",
mail("$email","TESTBED: Project Membership Denied",
"\nThis message is to notify you that you have been denied ".
"as a member of \nthe $gid group.\n".
"as a member of \nthe $pid project\n".
"\nYour status as a Testbed user is still $status.".
"\n\nThanks,\nTestbed Ops\nUtah Network Testbed\n",
"From: Testbed Ops <testbed-ops@flux.cs.utah.edu>\n".
"Cc: Testbed WWW <testbed-www@flux.cs.utah.edu>\n".
"Errors-To: Testbed WWW <testbed-www@flux.cs.utah.edu>");
echo "<h3><p>User $uid was denied membership in your group.</p></h3>\n";
echo "<h3><p>User $uid was denied membership in your project.</p>
</h3>\n";
} else {
echo "<h3><p>User $uid was postponed for later decision.</p></h3>\n";
}
......
......@@ -23,13 +23,13 @@ LOGGEDINORDIE($uid);
# See what projects the uid is a member of. Must be at least one!
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT gid FROM grp_memb WHERE uid=\"$uid\"");
"SELECT pid FROM proj_memb WHERE uid=\"$uid\"");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error finding project membership: $uid: $err\n", 1);
}
if (mysql_num_rows($query_result) == 0) {
USERERROR("You do not appear to be a member of an Projects!", 1);
USERERROR("You do not appear to be a member of any Projects!", 1);
}
?>
......@@ -66,7 +66,7 @@ echo "<tr>
<td>*Select Project:</td>";
echo " <td><select name=\"exp_pid\">";
while ($row = mysql_fetch_array($query_result)) {
$project = $row[gid];
$project = $row[pid];
echo "<option value=\"$project\">$project</option>\n";
}
echo " </select>";
......
......@@ -86,11 +86,8 @@ if ($row = mysql_fetch_row($query_result)) {
# Next, is this person a member of the project specified, and is the trust
# equal to group or local root?
#
# XXX Split across grp_memb and proj_memb. grp_memb needs to be flushed, but
# right now that has all the info we need.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT * FROM grp_memb WHERE gid=\"$exp_pid\" and uid=\"$uid\"");
"SELECT * FROM proj_memb WHERE pid=\"$exp_pid\" and uid=\"$uid\"");
if (($row = mysql_fetch_array($query_result)) == 0) {
USERERROR("You are not a member of Project $exp_pid, so you cannot begin ".
"an experiment in that project.", 1);
......
......@@ -23,12 +23,9 @@ LOGGEDINORDIE($uid);
# Show a menu of all experiments for all projects that this uid
# is a member of.
#
# XXX Split across grp_memb and proj_memb. grp_memb needs to be flushed, but
# right now that has all the info we need.
#
$groupmemb_result = mysql_db_query($TBDBNAME,
"SELECT * FROM grp_memb WHERE uid=\"$uid\"");
if (mysql_num_rows($groupmemb_result) == 0) {
$projmemb_result = mysql_db_query($TBDBNAME,
"SELECT * FROM proj_memb WHERE uid=\"$uid\"");
if (mysql_num_rows($projmemb_result) == 0) {
USERERROR("You are not a member of any Projects, so you cannot ".
"show any experiment information", 1);
}
......@@ -38,8 +35,8 @@ if (mysql_num_rows($groupmemb_result) == 0) {
# presenting a bogus option list.
#
$experiments = "";
while ($grprow = mysql_fetch_array($groupmemb_result)) {
$pid = $grprow[gid];
while ($projrow = mysql_fetch_array($projmemb_result)) {
$pid = $projrow[pid];
$exp_result = mysql_db_query($TBDBNAME,
"SELECT eid FROM experiments WHERE pid=\"$pid\"");
while ($exprow = mysql_fetch_array($exp_result)) {
......
......@@ -83,7 +83,7 @@ if (isset($uid)) {
$status = $row[0];
$query_result = mysql_db_query($TBDBNAME,
"SELECT trust FROM grp_memb WHERE uid='$uid'");
"SELECT trust FROM proj_memb WHERE uid='$uid'");
$row = mysql_fetch_row($query_result);
$trust = $row[0];
......@@ -127,11 +127,11 @@ if (isset($uid)) {
# Standard options for anyone.
#
if (isset($uid)) {
echo "<p><A href=\"addgrp.php3?$uid\">Start a Project</A>\n";
echo "<p><A href=\"newproject_form.php3?$uid\">Start a Project</A>\n";
echo "<p><A href=\"addusr.php3?$uid\">Join a Project</A>\n";
}
else {
echo "<p><A href=\"addgrp.php3\">Start a Project</A>\n";
echo "<p><A href=\"newproject_form.php3\">Start a Project</A>\n";
echo "<p><A href=\"addusr.php3\">Join a Project</A>\n";
}
echo "<hr>";
......
......@@ -162,7 +162,7 @@ if (mysql_num_rows($reserved_result)) {
# Lets dump the project information too.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT * FROM groups WHERE gid=\"$exp_pid\"");
"SELECT * FROM projects WHERE pid=\"$exp_pid\"");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error getting info for project $exp_pid: $err\n", 1);
......@@ -174,42 +174,41 @@ echo "<center>
</center>
<table align=center border=1>\n";
$gid = $row[gid];
$grp_created = $row[grp_created];
$grp_expires = $row[grp_expires];
$grp_name = $row[grp_name];
$grp_URL = $row[grp_URL];
$grp_affil = $row[grp_affil];
$grp_addr = $row[grp_addr];
$grp_head_uid = $row[grp_head_uid];
$cntrl_node = $row[cntrl_node];
$proj_created = $row[created];
$proj_expires = $row[expires];
$proj_name = $row[name];
$proj_URL = $row[URL];
$proj_affil = $row[affil];
$proj_addr = $row[addr];
$proj_head_uid = $row[head_uid];
$control_node = $row[control_node];
#
# Generate the table.
#
echo "<tr>
<td>Name: </td>
<td class=\"left\">$gid</td>
<td class=\"left\">$exp_pid</td>
</tr>\n";
echo "<tr>
<td>Long Name: </td>
<td class=\"left\">$grp_name</td>
<td class=\"left\">$proj_name</td>
</tr>\n";
echo "<tr>
<td>Project Head: </td>
<td class=\"left\">$grp_head_uid</td>
<td class=\"left\">$proj_head_uid</td>
</tr>\n";
echo "<tr>
<td>Created: </td>
<td class=\"left\">$grp_created</td>
<td class=\"left\">$proj_created</td>
</tr>\n";
echo "<tr>
<td>Expires: </td>
<td class=\"left\">$grp_expires</td>
<td class=\"left\">$proj_expires</td>
</tr>\n";
echo "</table>\n";
......
......@@ -23,12 +23,9 @@ LOGGEDINORDIE($uid);
# Show a menu of all experiments for all projects that this uid
# is a member of.
#
# XXX Split across grp_memb and proj_memb. grp_memb needs to be flushed, but
# right now that has all the info we need.
#
$groupmemb_result = mysql_db_query($TBDBNAME,
"SELECT * FROM grp_memb WHERE uid=\"$uid\"");
if (mysql_num_rows($groupmemb_result) == 0) {
$projmemb_result = mysql_db_query($TBDBNAME,
"SELECT * FROM proj_memb WHERE uid=\"$uid\"");
if (mysql_num_rows($projmemb_result) == 0) {
USERERROR("You are not a member of any Projects, so you cannot ".
"show any experiment information", 1);
}
......@@ -38,8 +35,8 @@ if (mysql_num_rows($groupmemb_result) == 0) {
# presenting a bogus option list.
#
$experiments = "";
while ($grprow = mysql_fetch_array($groupmemb_result)) {
$pid = $grprow[gid];
while ($projrow = mysql_fetch_array($projmemb_result)) {
$pid = $projrow[pid];
$exp_result = mysql_db_query($TBDBNAME,
"SELECT eid FROM experiments WHERE pid=\"$pid\"");
while ($exprow = mysql_fetch_array($exp_result)) {
......
......@@ -193,7 +193,7 @@ if (! $returning) {
# Don't try to join twice!
#
$query_result = mysql_db_query($TBDBNAME,
"select * from grp_memb where uid='$uid' and gid='$pid'");
"select * from proj_memb where uid='$uid' and pid='$pid'");
if (mysql_num_rows($query_result) > 0) {
die("<h3><br><br>".
"You have already applied for membership in project: $pid.".
......@@ -205,10 +205,12 @@ if (mysql_num_rows($query_result) > 0) {
# to upgrade the trust level, making the new user real.
#
$query_result = mysql_db_query($TBDBNAME,
"insert into grp_memb (uid,gid,trust) values ('$uid','$pid','none');");
"insert into proj_memb (uid,pid,trust) ".
"values ('$uid','$pid','none');");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error adding adding user $uid to group $pid: $err\n", 1);
TBERROR("Database Error adding adding user $uid to ".
"project $pid: $err\n", 1);
}
#
......@@ -216,23 +218,24 @@ if (! $query_result) {
# email message out of the database, of course.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT grp_head_uid FROM groups WHERE gid='$pid'");
"SELECT head_uid FROM projects WHERE pid='$pid'");
if (($row = mysql_fetch_row($query_result)) == 0) {
$err = mysql_error();
TBERROR("Database Error getting project leader for group $pid: $err\n", 1);
TBERROR("Database Error getting project leader for project $pid: $err\n",
1);
}
$group_leader_uid = $row[0];
$project_leader_uid = $row[0];
$query_result = mysql_db_query($TBDBNAME,
"SELECT usr_email FROM users WHERE uid='$group_leader_uid'");
"SELECT usr_email FROM users WHERE uid='$project_leader_uid'");
if (($row = mysql_fetch_row($query_result)) == 0) {
$err = mysql_error();
TBERROR("Database Error getting email address for group leader ".
"$group_leader_uid: $err\n", 1);
TBERROR("Database Error getting email address for project leader ".
"$project_leader_uid: $err\n", 1);
}
$group_leader_email = $row[0];
$project_leader_email = $row[0];
mail("$group_leader_email",
mail("$project_leader_email",
"TESTBED: New Project Member",
"\n$usr_name ($uid) is trying to join your project ($pid).\n".
"$usr_name has the\n".
......
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