Commit a6c77efd authored by Leigh Stoller's avatar Leigh Stoller

Another round of uuid changes. I now have all of the group_membership

queries taken care of. Also, most of them have moved into group_defs.php.
parent 2e02dc9a
...@@ -8,9 +8,9 @@ include("defs.php3"); ...@@ -8,9 +8,9 @@ include("defs.php3");
include("showstuff.php3"); include("showstuff.php3");
# #
# No testbed header since we spit out a redirect. # Standard Testbed Header
# #
ignore_user_abort(1); PAGEHEADER("Edit Group Membership");
# #
# Only known and logged in users. # Only known and logged in users.
...@@ -46,7 +46,7 @@ if (! ($group = Group::LookupByPidGid($pid, $gid))) { ...@@ -46,7 +46,7 @@ if (! ($group = Group::LookupByPidGid($pid, $gid))) {
# #
# Verify permission. # Verify permission.
# #
if (! TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_EDITGROUP)) { if (! $group->AccessCheck($this_user, $TB_PROJECT_EDITGROUP)) {
USERERROR("You do not have permission to edit group $gid in ". USERERROR("You do not have permission to edit group $gid in ".
"project $pid!", 1); "project $pid!", 1);
} }
...@@ -55,7 +55,7 @@ if (! TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_EDITGROUP)) { ...@@ -55,7 +55,7 @@ if (! TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_EDITGROUP)) {
# See if user is allowed to add non-members to group. # See if user is allowed to add non-members to group.
# #
$grabusers = 0; $grabusers = 0;
if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_GROUPGRABUSERS)) { if ($group->AccessCheck($this_user, $TB_PROJECT_GROUPGRABUSERS)) {
$grabusers = 1; $grabusers = 1;
} }
...@@ -63,7 +63,7 @@ if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_GROUPGRABUSERS)) { ...@@ -63,7 +63,7 @@ if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_GROUPGRABUSERS)) {
# See if user is allowed to bestow group_root upon members of group. # See if user is allowed to bestow group_root upon members of group.
# #
$bestowgrouproot = 0; $bestowgrouproot = 0;
if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_BESTOWGROUPROOT)) { if ($group->AccessCheck($this_user, $TB_PROJECT_BESTOWGROUPROOT)) {
$bestowgrouproot = 1; $bestowgrouproot = 1;
} }
...@@ -72,11 +72,7 @@ if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_BESTOWGROUPROOT)) { ...@@ -72,11 +72,7 @@ if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_BESTOWGROUPROOT)) {
# removed! Do not include members that have not been approved to main # removed! Do not include members that have not been approved to main
# group either! This will force them to go through the approval page first. # group either! This will force them to go through the approval page first.
# #
$curmembers_result = $curmembers = $group->MemberList();
DBQueryFatal("select distinct m.uid, m.trust from group_membership as m ".
"left join groups as g on g.pid=m.pid and g.gid=m.gid ".
"where m.pid='$pid' and m.gid='$gid' and ".
" m.uid!=g.leader and m.trust!='none'");
# #
# Grab the user list from the project. These are the people who can be # Grab the user list from the project. These are the people who can be
...@@ -84,13 +80,7 @@ $curmembers_result = ...@@ -84,13 +80,7 @@ $curmembers_result =
# include members that have not been approved to main group either! This # include members that have not been approved to main group either! This
# will force them to go through the approval page first. # will force them to go through the approval page first.
# #
$nonmembers_result = $nonmembers = $group->NonMemberList();
DBQueryFatal("select m.uid from group_membership as m ".
"left join group_membership as a on ".
" a.uid=m.uid and a.pid=m.pid and a.gid='$gid' ".
"where m.pid='$pid' and m.gid=m.pid and a.uid is NULL ".
" and m.trust!='none'");
# #
# First pass does checks. Second pass does the real thing. # First pass does checks. Second pass does the real thing.
...@@ -102,11 +92,11 @@ $nonmembers_result = ...@@ -102,11 +92,11 @@ $nonmembers_result =
# from the group membership. Otherwise, look to see if the trust level # from the group membership. Otherwise, look to see if the trust level
# has been changed. # has been changed.
# #
if (mysql_num_rows($curmembers_result)) { if (count($curmembers)) {
while ($row = mysql_fetch_array($curmembers_result)) { foreach ($curmembers as $target_user) {
$user = $row[0]; $target_uid = $target_user->uid();
$oldtrust = $row[1]; $oldtrust = $target_user->GetTempData();
$foo = "change_$user"; $foo = "change_$target_uid";
# #
# Is member to be deleted? # Is member to be deleted?
...@@ -116,25 +106,21 @@ if (mysql_num_rows($curmembers_result)) { ...@@ -116,25 +106,21 @@ if (mysql_num_rows($curmembers_result)) {
continue; continue;
} }
if (! ($target_user = User::Lookup($user))) {
TBERROR("Could not find user object for $user", 1);
}
# #
# There should be a corresponding trust variable in the POST vars. # There should be a corresponding trust variable in the POST vars.
# Note that we construct the variable name and indirect to it. # Note that we construct the variable name and indirect to it.
# #
$foo = "$user\$\$trust"; $foo = "$target_uid\$\$trust";
$newtrust = $$foo; $newtrust = $$foo;
if (!$newtrust || strcmp($newtrust, "") == 0) { if (!$newtrust || strcmp($newtrust, "") == 0) {
TBERROR("Error finding trust for $user in editgroup.php3", 1); TBERROR("Error finding trust for $target_uid in editgroup", 1);
} }
if (strcmp($newtrust, "user") && if (strcmp($newtrust, TBDB_TRUSTSTRING_USER) &&
strcmp($newtrust, "local_root") && strcmp($newtrust, TBDB_TRUSTSTRING_LOCALROOT) &&
strcmp($newtrust, "group_root")) { strcmp($newtrust, TBDB_TRUSTSTRING_GROUPROOT)) {
TBERROR("Invalid trust $newtrust for $user in editgroup.php3.", 1); TBERROR("Invalid trust $newtrust for $target_uid in editgroup", 1);
} }
# #
...@@ -143,7 +129,7 @@ if (mysql_num_rows($curmembers_result)) { ...@@ -143,7 +129,7 @@ if (mysql_num_rows($curmembers_result)) {
# permitted. # permitted.
# #
if (strcmp($newtrust, $oldtrust) && if (strcmp($newtrust, $oldtrust) &&
!strcmp($newtrust, "group_root") && !strcmp($newtrust, TBDB_TRUSTSTRING_GROUPROOT) &&
!$bestowgrouproot) { !$bestowgrouproot) {
USERERROR("You do not have permission to bestow group root". USERERROR("You do not have permission to bestow group root".
"trust to users in $pid/$gid!", 1 ); "trust to users in $pid/$gid!", 1 );
...@@ -151,6 +137,7 @@ if (mysql_num_rows($curmembers_result)) { ...@@ -151,6 +137,7 @@ if (mysql_num_rows($curmembers_result)) {
$group->CheckTrustConsistency($target_user, $newtrust, 1); $group->CheckTrustConsistency($target_user, $newtrust, 1);
} }
reset($curmembers);
} }
# #
...@@ -160,44 +147,38 @@ if (mysql_num_rows($curmembers_result)) { ...@@ -160,44 +147,38 @@ if (mysql_num_rows($curmembers_result)) {
# Only do this if user has permission to grab users. # Only do this if user has permission to grab users.
# #
if ($grabusers && !$defaultgroup && mysql_num_rows($nonmembers_result)) { if ($grabusers && !$defaultgroup && count($nonmembers)) {
while ($row = mysql_fetch_array($nonmembers_result)) { foreach ($nonmembers as $target_user) {
$user = $row[0]; $target_uid = $target_user->uid();
$foo = "add_$user"; $foo = "add_$target_uid";
if (isset($$foo)) { if (isset($$foo)) {
# #
# There should be a corresponding trust variable in the POST vars. # There should be a corresponding trust variable in the POST vars.
# Note that we construct the variable name and indirect to it. # Note that we construct the variable name and indirect to it.
# #
$bar = "$user\$\$trust"; $bar = "$target_uid\$\$trust";
$newtrust = $$bar; $newtrust = $$bar;
if (!$newtrust || strcmp($newtrust, "") == 0) { if (!$newtrust || strcmp($newtrust, "") == 0) {
TBERROR("Error finding trust for $user in editgroup.php3", TBERROR("Error finding trust for $target_uid", 1);
1);
} }
if (strcmp($newtrust, "user") && if (strcmp($newtrust, TBDB_TRUSTSTRING_USER) &&
strcmp($newtrust, "local_root") && strcmp($newtrust, TBDB_TRUSTSTRING_LOCALROOT) &&
strcmp($newtrust, "group_root")) { strcmp($newtrust, TBDB_TRUSTSTRING_GROUPROOT)) {
TBERROR("Invalid trust $newtrust for $user in editgroup.php3.", TBERROR("Invalid trust $newtrust for $target_uid", 1);
1);
} }
if (!strcmp($newtrust, "group_root") if (!strcmp($newtrust, TBDB_TRUSTSTRING_GROUPROOT)
&& !$bestowgrouproot) { && !$bestowgrouproot) {
USERERROR("You do not have permission to bestow group root". USERERROR("You do not have permission to bestow group root".
"trust to users in $pid/$gid!", 1 ); "trust to users in $pid/$gid!", 1 );
} }
if (! ($target_user = User::Lookup($user))) {
TBERROR("Could not find user object for $user", 1);
}
$group->CheckTrustConsistency($target_user, $newtrust, 1); $group->CheckTrustConsistency($target_user, $newtrust, 1);
} }
} }
reset($nonmembers);
} }
# #
...@@ -205,7 +186,9 @@ if ($grabusers && !$defaultgroup && mysql_num_rows($nonmembers_result)) { ...@@ -205,7 +186,9 @@ if ($grabusers && !$defaultgroup && mysql_num_rows($nonmembers_result)) {
# #
# Grab the unix GID for running scripts. # Grab the unix GID for running scripts.
# #
TBGroupUnixInfo($pid, $pid, $unix_gid, $unix_name); $unix_gid = $group->unix_gid();
STARTBUSY("Applying group membership changes");
# #
# Go through the list of current members. For each one, check to see if # Go through the list of current members. For each one, check to see if
...@@ -213,28 +196,28 @@ TBGroupUnixInfo($pid, $pid, $unix_gid, $unix_name); ...@@ -213,28 +196,28 @@ TBGroupUnixInfo($pid, $pid, $unix_gid, $unix_name);
# from the group membership. Otherwise, look to see if the trust level # from the group membership. Otherwise, look to see if the trust level
# has been changed. # has been changed.
# #
if (mysql_num_rows($curmembers_result)) { if (count($curmembers)) {
mysql_data_seek($curmembers_result, 0); foreach ($curmembers as $target_user) {
$target_uid = $target_user->uid();
while ($row = mysql_fetch_array($curmembers_result)) { $oldtrust = $target_user->GetTempData();
$user = $row[0]; $foo = "change_$target_uid";
$oldtrust = $row[1];
$foo = "change_$user";
if (!$defaultgroup && !isset($$foo)) { if (!$defaultgroup && !isset($$foo)) {
SUEXEC($uid, $unix_gid, "webmodgroups -r $pid:$gid $user", 1); SUEXEC($uid, $unix_gid, "webmodgroups -r $pid:$gid $target_uid",
SUEXEC_ACTION_DIE);
continue; continue;
} }
# #
# There should be a corresponding trust variable in the POST vars. # There should be a corresponding trust variable in the POST vars.
# Note that we construct the variable name and indirect to it. # Note that we construct the variable name and indirect to it.
# #
$foo = "$user\$\$trust"; $foo = "$target_uid\$\$trust";
$newtrust = $$foo; $newtrust = $$foo;
if (strcmp($oldtrust,$newtrust)) { if (strcmp($oldtrust,$newtrust)) {
SUEXEC($uid, $unix_gid, SUEXEC($uid, $unix_gid,
"webmodgroups -m $pid:$gid:$newtrust $user", 1); "webmodgroups -m $pid:$gid:$newtrust $target_uid",
SUEXEC_ACTION_DIE);
} }
} }
} }
...@@ -245,32 +228,36 @@ if (mysql_num_rows($curmembers_result)) { ...@@ -245,32 +228,36 @@ if (mysql_num_rows($curmembers_result)) {
# to the group membership, with the trust level specified. # to the group membership, with the trust level specified.
# #
if ($grabusers && !$defaultgroup && mysql_num_rows($nonmembers_result)) { if ($grabusers && !$defaultgroup && count($nonmembers)) {
mysql_data_seek($nonmembers_result, 0); foreach ($nonmembers as $target_user) {
$target_uid = $target_user->uid();
while ($row = mysql_fetch_array($nonmembers_result)) { $foo = "add_$target_uid";
$user = $row[0];
$foo = "add_$user";
if (isset($$foo)) { if (isset($$foo)) {
# #
# There should be a corresponding trust variable in the POST vars. # There should be a corresponding trust variable in the POST vars.
# Note that we construct the variable name and indirect to it. # Note that we construct the variable name and indirect to it.
# #
$bar = "$user\$\$trust"; $bar = "$target_uid\$\$trust";
$newtrust = $$bar; $newtrust = $$bar;
SUEXEC($uid, $unix_gid, SUEXEC($uid, $unix_gid,
"webmodgroups -a $pid:$gid:$newtrust $user", 1); "webmodgroups -a $pid:$gid:$newtrust $target_uid",
SUEXEC_ACTION_DIE);
} }
} }
} }
STOPBUSY();
# #
# Spit out a redirect so that the history does not include a post # Spit out a redirect so that the history does not include a post
# in it. The back button skips over the post and to the form. # in it. The back button skips over the post and to the form.
# #
header("Location: showgroup.php3?pid=$pid&gid=$gid"); PAGEREPLACE("showgroup.php3?pid=$pid&gid=$gid");
# No Testbed footer. #
# Standard Testbed Footer
#
PAGEFOOTER();
?> ?>
...@@ -46,7 +46,7 @@ if (! ($group = Group::LookupByPidGid($pid, $gid))) { ...@@ -46,7 +46,7 @@ if (! ($group = Group::LookupByPidGid($pid, $gid))) {
# #
# Verify permission. # Verify permission.
# #
if (! TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_EDITGROUP)) { if (! $group->AccessCheck($this_user, $TB_PROJECT_EDITGROUP)) {
USERERROR("You do not have permission to edit group $gid in ". USERERROR("You do not have permission to edit group $gid in ".
"project $pid!", 1); "project $pid!", 1);
} }
...@@ -55,7 +55,7 @@ if (! TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_EDITGROUP)) { ...@@ -55,7 +55,7 @@ if (! TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_EDITGROUP)) {
# See if user is allowed to add non-members to group. # See if user is allowed to add non-members to group.
# #
$grabusers = 0; $grabusers = 0;
if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_GROUPGRABUSERS)) { if ($group->AccessCheck($this_user, $TB_PROJECT_GROUPGRABUSERS)) {
$grabusers = 1; $grabusers = 1;
} }
...@@ -63,7 +63,7 @@ if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_GROUPGRABUSERS)) { ...@@ -63,7 +63,7 @@ if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_GROUPGRABUSERS)) {
# See if user is allowed to bestow group_root upon members of group. # See if user is allowed to bestow group_root upon members of group.
# #
$bestowgrouproot = 0; $bestowgrouproot = 0;
if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_BESTOWGROUPROOT)) { if ($group->AccessCheck($this_user, $TB_PROJECT_BESTOWGROUPROOT)) {
$bestowgrouproot = 1; $bestowgrouproot = 1;
} }
...@@ -74,24 +74,15 @@ if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_BESTOWGROUPROOT)) { ...@@ -74,24 +74,15 @@ if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_BESTOWGROUPROOT)) {
# to main group either! This will force them to go through the approval # to main group either! This will force them to go through the approval
# page first. # page first.
# #
$curmembers_result = $curmembers = $group->MemberList();
DBQueryFatal("select m.uid,m.trust from group_membership as m ".
"left join groups as g on g.pid=m.pid and g.gid=m.gid ".
"where m.pid='$pid' and m.gid='$gid' and ".
" m.uid!=g.leader and m.trust!='none'");
# #
# Grab the user list from the project. These are the people who can be # Grab the user list from the project. These are the people who can be
# added. Do not include people in the above list, obviously! Do not # added. Do not include people in the above list, obviously! Do not
# include members that have not been approved to main group either! This # include members that have not been approved to main group either! This
# will force them to go through the approval page first. # will force them to go through the approval page first.
# #
$nonmembers_result = $nonmembers = $group->NonMemberList();
DBQueryFatal("select m.uid from group_membership as m ".
"left join group_membership as a on ".
" a.uid=m.uid and a.pid=m.pid and a.gid='$gid' ".
"where m.pid='$pid' and m.gid=m.pid and a.uid is NULL ".
" and m.trust!='none'");
# #
# We do not allow the actual group info to be edited. Just the membership. # We do not allow the actual group info to be edited. Just the membership.
...@@ -104,14 +95,14 @@ echo "<br><center> ...@@ -104,14 +95,14 @@ echo "<br><center>
<a href='docwrapper.php3?docname=groups.html'>Groups Tutorial</a>. <a href='docwrapper.php3?docname=groups.html'>Groups Tutorial</a>.
</center>\n"; </center>\n";
if (mysql_num_rows($curmembers_result) || if (count($curmembers) ||
($grabusers && mysql_num_rows($nonmembers_result))) { ($grabusers && count($nonmembers))) {
echo "<br> echo "<br>
<form action='editgroup.php3?pid=$pid&gid=$gid' method=post> <form action='editgroup.php3?pid=$pid&gid=$gid' method=post>
<table align=center border=1>\n"; <table align=center border=1>\n";
} }
if (mysql_num_rows($curmembers_result)) { if (count($curmembers)) {
if ($defaultgroup) { if ($defaultgroup) {
echo "<tr><td align=center colspan=2 nowrap=1> echo "<tr><td align=center colspan=2 nowrap=1>
<br> <br>
...@@ -131,33 +122,30 @@ if (mysql_num_rows($curmembers_result)) { ...@@ -131,33 +122,30 @@ if (mysql_num_rows($curmembers_result)) {
</td></tr>\n"; </td></tr>\n";
} }
while ($row = mysql_fetch_array($curmembers_result)) { foreach ($curmembers as $target_user) {
$user = $row[0]; $target_uid = $target_user->uid();
$trust = $row[1]; $trust = $target_user->GetTempData();
$showurl = CreateURL("showuser", $target_user);
if (! ($target_user = User::Lookup($user))) {
TBERROR("Could not look up user object for $user", 1);
}
$showurl = CreateURL("showuser", $target_user);
if ($defaultgroup) { if ($defaultgroup) {
echo "<tr> echo "<tr>
<td> <td>
<input type=hidden name='change_$user' value=permit> <input type=hidden name='change_$target_uid'
<A href='$showurl'>$user &nbsp</A> value=permit>
<A href='$showurl'>$target_uid &nbsp</A>
</td>\n"; </td>\n";
} }
else { else {
echo "<tr> echo "<tr>
<td> <td>
<input checked type=checkbox value=permit <input checked type=checkbox value=permit
name='change_$user'> name='change_$target_uid'>
<A href='$showurl'>$user &nbsp</A> <A href='$showurl'>$target_uid &nbsp</A>
</td>\n"; </td>\n";
} }
echo " <td align=center> echo " <td align=center>
<select name='$user\$\$trust'>\n"; <select name='$target_uid\$\$trust'>\n";
# #
# We want to have the current trust value selected in the menu. # We want to have the current trust value selected in the menu.
...@@ -188,9 +176,10 @@ if (mysql_num_rows($curmembers_result)) { ...@@ -188,9 +176,10 @@ if (mysql_num_rows($curmembers_result)) {
</td>\n"; </td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
reset($curmembers);
} }
if ($grabusers && mysql_num_rows($nonmembers_result)) { if ($grabusers && count($nonmembers)) {
echo "<tr><td align=center colspan=2 nowrap=1> echo "<tr><td align=center colspan=2 nowrap=1>
<br> <br>
<font size=+1><b>Add Group Members</b></font>[<b>1</b>]. <font size=+1><b>Add Group Members</b></font>[<b>1</b>].
...@@ -198,24 +187,20 @@ if ($grabusers && mysql_num_rows($nonmembers_result)) { ...@@ -198,24 +187,20 @@ if ($grabusers && mysql_num_rows($nonmembers_result)) {
Select the ones you would like to add.<br> Select the ones you would like to add.<br>
Be sure to select the appropriate trust level. Be sure to select the appropriate trust level.
</td></tr>\n"; </td></tr>\n";
while ($row = mysql_fetch_array($nonmembers_result)) { foreach ($nonmembers as $target_user) {
$user = $row[0]; $target_uid = $target_user->uid();
$trust = $row[1]; $trust = $target_user->GetTempData();
$showurl = CreateURL("showuser", $target_user);
if (! ($target_user = User::Lookup($user))) {
TBERROR("Could not look up user object for $user", 1);
}
$showurl = CreateURL("showuser", $target_user);
echo "<tr> echo "<tr>
<td> <td>
<input type=checkbox value=permit name='add_$user'> <input type=checkbox value=permit name='add_$target_uid'>
<A href='$showurl'>$user &nbsp</A> <A href='$showurl'>$target_uid &nbsp</A>
</td>\n"; </td>\n";
echo " <td align=center> echo " <td align=center>
<select name='$user\$\$trust'>\n"; <select name='$target_uid\$\$trust'>\n";
if ($group->CheckTrustConsistency($target_user, if ($group->CheckTrustConsistency($target_user,
TBDB_TRUSTSTRING_USER, 0)) { TBDB_TRUSTSTRING_USER, 0)) {
...@@ -239,10 +224,11 @@ if ($grabusers && mysql_num_rows($nonmembers_result)) { ...@@ -239,10 +224,11 @@ if ($grabusers && mysql_num_rows($nonmembers_result)) {
</td>\n"; </td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
reset($nonmembers);
} }
if (mysql_num_rows($curmembers_result) || if (count($curmembers) ||
($grabusers && mysql_num_rows($nonmembers_result))) { ($grabusers && count($nonmembers))) {
echo "<tr> echo "<tr>
<td align=center colspan=2> <td align=center colspan=2>
<b><input type=submit value=Submit></b> <b><input type=submit value=Submit></b>
......
...@@ -53,7 +53,7 @@ class Experiment ...@@ -53,7 +53,7 @@ class Experiment
$foo = Experiment::LookupByPidEid($pid, $eid); $foo = Experiment::LookupByPidEid($pid, $eid);
if ($foo->IsValid()) if ($foo && $foo->IsValid())
return $foo; return $foo;
} }
return null; return null;
......
...@@ -430,6 +430,77 @@ class Group ...@@ -430,6 +430,77 @@ class Group
return 1; return 1;
} }
#
# Return list of approved members in this group.
#
function MemberList($exclude_leader = 1) {
$gid_idx = $this->gid_idx();
$pid_idx = $this->pid_idx();
$trust_none = TBDB_TRUSTSTRING_NONE;
$leader = $this->GetLeader();
$result = array();
$query_result =
DBQueryFatal("select m.uid_idx,m.trust ".
" from group_membership as m ".
"left join groups as g on ".
" g.pid=m.pid and g.gid=m.gid ".
"where m.pid_idx='$pid_idx' and ".
" m.gid_idx='$gid_idx' and ".
" m.trust!='$trust_none'");
while ($row = mysql_fetch_array($query_result)) {
$uid_idx = $row["uid_idx"];
$trust = $row["trust"];
if ($exclude_leader && $leader->uid_idx() == $uid_idx)
continue;
if (! ($user =& User::Lookup($uid_idx))) {
TBERROR("Group::MemberList: ".
"Could not load user $uid_idx!", 1);
}
# So caller can get this.
$user->SetTempData($trust);
$result[] =& $user;
}
return $result;
}
#
# Grab the user list from the project. These are the people who can be
# added. Do not include people in the above list, obviously! Do not
# include members that have not been approved to main group either! This
# will force them to go through the approval page first.
#
function NonMemberList() {
$gid_idx = $this->gid_idx();
$pid_idx = $this->pid_idx();
$trust_none = TBDB_TRUSTSTRING_NONE;
$result = array();
$query_result =
DBQueryFatal("select m.uid_idx from group_membership as m ".
"left join group_membership as a on ".
" a.uid_idx=m.uid_idx and ".
" a.pid_idx=m.pid_idx and a.gid_idx='$gid_idx' ".
"where m.pid_idx='$pid_idx' and ".
" m.gid_idx=m.pid_idx and a.uid_idx is NULL ".
" and m.trust!='$trust_none'");
while ($row = mysql_fetch_array($query_result)) {
$uid_idx = $row["uid_idx"];
if (! ($user =& User::Lookup($uid_idx))) {
TBERROR("Group::NonMemberList: ".
"Could not load user $uid_idx!", 1);
}
$result[] =& $user;
}
return $result;
}
# #
# Change the leader for a group. # Change the leader for a group.
# #
......
...@@ -83,11 +83,13 @@ function SPITFORM($formfields, $errors) ...@@ -83,11 +83,13 @@ function SPITFORM($formfields, $errors)
"order by osid"); "order by osid");
} }
else { else {
$uid_idx = $this_user->uid_idx();
$osid_result = $osid_result =
DBQueryFatal("select distinct o.* from os_info as o ". DBQueryFatal("select distinct o.* from os_info as o ".
"left join group_membership as m ". "left join group_membership as m ".
" on m.pid=o.pid ". " on m.pid=o.pid ".
"where m.uid='$uid' and ". "where m.uid_idx='$uid_idx' and ".
" (path='' or path is NULL) and ". " (path='' or path is NULL) and ".
" version!='' and version is not NULL ". " version!='' and version is not NULL ".
"order by o.pid,o.osid"); "order by o.pid,o.osid");
......
...@@ -76,13 +76,15 @@ if ($isadmin) { ...@@ -76,13 +76,15 @@ if ($isadmin) {
"order by o.osid"); "order by o.osid");
} }
else { else {
$uid_idx = $this_user->uid_idx();