Skip to content

Commit

Permalink
Issue GENI-NSF#1641: refactor join a project to not filter out projec…
Browse files Browse the repository at this point in the history
…ts you are in or have requested to join. Fewer queries so faster. Also get the project details before showing the page header.
  • Loading branch information
ahelsing committed Nov 12, 2015
1 parent 567d8a8 commit 82eb2ee
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
* `get_project` uses wrong variable name for result. `lookup_project_details`
should bail when given empty list of projet UIDs.
([#1639](https://github.com/GENI-NSF/geni-portal/issues/1639))
* Refactor Join a Project page.
* Do not filter out projects you are in or have requested to join,
relying on join-this-project to do so.
* Get project details and project lead names before showing page header.
([#1641](https://github.com/GENI-NSF/geni-portal/issues/1641))

# [Release 3.7](https://github.com/GENI-NSF/geni-portal/milestones/3.7)

Expand Down
49 changes: 27 additions & 22 deletions portal/www/portal/join-project.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,31 @@ function project_name_compare($p1, $p2)
}
include("tool-lookupids.php");

$mpids = get_projects_for_member($sa_url, $user, $user->account_id, false);
// Used to only get project the user is not in
// Now get all projects and let next page warn if you are already in the project
// $mpids = get_projects_for_member($sa_url, $user, $user->account_id, false);
$pids = get_projects($sa_url, $user);

// // Filter out projects for which this user has not already requested to join (nothing pending)
// $rs = get_requests_by_user($sa_url, $user, $user->account_id, CS_CONTEXT_TYPE::PROJECT, null, RQ_REQUEST_STATUS::PENDING);
// $rpids = array();
// foreach ($rs as $request) {
// $rpids[] = $request[RQ_REQUEST_TABLE_FIELDNAME::CONTEXT_ID];
// }

// $pids = array_diff($mpids, $rpids);

$jointhis_url = "join-this-project.php?project_id=";
$project_details = lookup_project_details($sa_url, $user, $pids);
usort($project_details, "project_name_compare");
// error_log("PROJ_DETAILS = " . print_r($project_details, true));

$ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY);
$member_names = lookup_member_names_for_rows($ma_url, $user,
$project_details,
PA_PROJECT_TABLE_FIELDNAME::LEAD_ID);
// error_log("MEMBER_DETAILS = " . print_r($member_names, true));

// Filter out projects for which this user has not already requested to join (nothing pending)
$rs = get_requests_by_user($sa_url, $user, $user->account_id, CS_CONTEXT_TYPE::PROJECT, null, RQ_REQUEST_STATUS::PENDING);
$rpids = array();
foreach ($rs as $request) {
$rpids[] = $request[RQ_REQUEST_TABLE_FIELDNAME::CONTEXT_ID];
}

$pids = array_diff($mpids, $rpids);
show_header('GENI Portal: Projects');

include("tool-breadcrumbs.php");
Expand Down Expand Up @@ -85,9 +100,9 @@ function project_name_compare($p1, $p2)

if (! isset($pids) || is_null($pids) || count($pids) < 1) {
print "<p><i>There are no more projects for you to join.</i></p>\n";
if (count($rpids) > 0) {
print "<p>You have " . count($rpids) . " open <a href='dashboard.php#projects'>request(s) to join a project</a>.</p>";
}
// if (count($rpids) > 0) {
// print "<p>You have " . count($rpids) . " open <a href='dashboard.php#projects'>request(s) to join a project</a>.</p>";
// }

} else {

Expand All @@ -106,16 +121,6 @@ function project_name_compare($p1, $p2)
print "<table id=\"projects\" class=\"display\">\n";
print "<thead>\n";
print "<tr><th>Project</th><th>Purpose</th><th>Project Lead</th><th>Join</th></tr>\n";
$jointhis_url = "join-this-project.php?project_id=";
$project_details = lookup_project_details($sa_url, $user, $pids);
usort($project_details, "project_name_compare");
// error_log("PROJ_DETAILS = " . print_r($project_details, true));

$ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY);
$member_names = lookup_member_names_for_rows($ma_url, $user,
$project_details,
PA_PROJECT_TABLE_FIELDNAME::LEAD_ID);
// error_log("MEMBER_DETAILS = " . print_r($member_names, true));

print "</thead><tbody>\n";

Expand Down

0 comments on commit 82eb2ee

Please sign in to comment.