Commit aa02f499 authored by Leigh B Stoller's avatar Leigh B Stoller

Do not show announcments or any of the menu options to unapproved users,

except for the ability to modify their profile or start/join projects.
Show warning to users who are waiting for membership approval, and show a
Nag link to remind the PI. For PIs waiting for a project to be approved
show a message, with a mailto link to remind the Project Approval
Committee.
parent 31ed0a72
......@@ -144,3 +144,20 @@ window.APT_OPTIONS.announceDismiss = function (aid) {
window.APT_OPTIONS.announceClick = function (aid) {
APT_OPTIONS.CallServerMethod('', 'announcement', 'Click', {'aid': aid}, function(){});
};
window.APT_OPTIONS.nagPI = function (pid) {
APT_OPTIONS.CallServerMethod('', 'nag', 'NagPI', {"pid" : pid},
function(json) {
if (json.code) {
console.info("nagged", json);
if (json.code > 0) {
alert(json.value);
}
return;
}
alert("The Project Leader for project '" +
pid + "' " +
"has been sent a reminder message.");
});
return false;
};
......@@ -51,11 +51,9 @@ $optargs = OptionalPageArguments("asguest", PAGEARG_BOOLEAN,
#
if ($this_user) {
if ($CHECKLOGIN_STATUS & CHECKLOGIN_UNAPPROVED) {
USERERROR("Your account has not been approved yet! ".
"<br>Please wait till ".
"your account is approved (you will receive email) and then ".
"reload this page.",
1, HTTP_403_FORBIDDEN);
# Take them to the myaccount page, they will see a banner
# message there.
header("Location: $APTBASE/myaccount.php");
}
elseif (Instance::UserHasInstances($this_user)) {
header("Location: $APTBASE/user-dashboard.php");
......
......@@ -58,6 +58,7 @@ $PAGEERROR_HANDLER = function($msg, $status_code = 0) {
if (! $drewheader) {
SPITHEADER();
}
echo "<br>";
echo $msg;
echo "<script type='text/javascript'>\n";
echo " window.ISEMULAB = " . ($ISEMULAB ? "1" : "0") . ";\n";
......@@ -247,26 +248,32 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
<a href='$PORTAL_MANUAL' target='_blank'> ".
($ISEMULAB || $ISPNET ? "Wiki" : "Manual") . "</a></li>
<li class='visible-xs navbar-nav-shortcuts'>
<a href='logout.php'>Logout</a></li>
<li><a href='user-dashboard.php#profiles'>My Profiles</a></li>
<li><a href='user-dashboard.php#experiments'>My Experiments</a></li>
<a href='logout.php'>Logout</a></li>";
if ($login_user->IsActive()) {
echo " <li><a href='user-dashboard.php#profiles'>
My Profiles</a></li>
<li><a href='user-dashboard.php#experiments'>
My Experiments</a></li>
<li><a href='manage_profile.php'>Create Profile</a></li>
<li><a href='instantiate.php'>Start Experiment</a></li>
<li class='divider'></li>
<li><a href='getcreds.php'>Download Credentials</a></li>
<li><a href='ssh-keys.php'>Manage SSH Keys</a></li>
<li><a href='myaccount.php'>Manage Account</a></li>
<li><a href='signup.php'>Start/Join Project</a></li>
<li class='divider'></li>
<li><a href='ssh-keys.php'>Manage SSH Keys</a></li>";
}
echo " <li><a href='myaccount.php'>Manage Account</a></li>
<li><a href='signup.php'>Start/Join Project</a></li>";
if ($login_user->IsActive()) {
echo " <li class='divider'></li>
<li><a href='list-datasets.php'>List Datasets</a></li>
<li><a href='create-dataset.php'>Create Dataset</a></li>";
echo " <li class='divider'></li>\n";
$then = time() - (90 * 3600 * 24);
echo " <li><a href='activity.php?user=$login_uid&min=$then'>
echo " <li class='divider'></li>\n";
$then = time() - (90 * 3600 * 24);
echo " <li><a href='activity.php?user=$login_uid&min=$then'>
My History</a></li>\n";
echo " </ul>
}
echo " </ul>
</li>\n";
if (ISADMIN() || ISFOREIGN_ADMIN()) {
if ($login_user->IsActive() && (ISADMIN() || ISFOREIGN_ADMIN())) {
echo "<li id='quickvm_actions_menu' class='dropdown apt-left'>
<a href='#'
class='dropdown-toggle btn btn-quickvm-home navbar-btn'
......@@ -293,14 +300,15 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
echo " </ul>
</li>\n";
}
}
}
echo " </ul>
</div>
</div>\n";
# Put announcements, if any, right below the header.
if ($login_user && !($login_status & CHECKLOGIN_WEBONLY)) {
if ($login_user && $login_user->IsActive() &&
!($login_status & CHECKLOGIN_WEBONLY)) {
$announcements = GET_ANNOUNCEMENTS($login_user);
for ($i = 0; $i < count($announcements); $i++) {
$current = $announcements[$i];
......@@ -333,6 +341,42 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
}
if ($login_user) {
$pending = $login_user->PendingMembership();
if (count($pending)) {
# Just deal with the first, that is enough.
$unproj = $pending[0];
$leader = $unproj->GetLeader();
$pid = $unproj->pid();
$mailto = "mailto:" . $unproj->ApprovalEmailAddress() .
"?Subject=Pending Project $pid";
echo "<div class=alert-danger ";
echo " style='margin-bottom: 6px; margin-top: -10px'>";
echo "<center><span>";
if ($login_user->SameUser($leader)) {
echo "Your project application is still under review. ";
echo "<a href='$mailto' class=alert-link>";
echo "Contact the Review Committee.</a>";
}
else {
echo "Your request for membership in project '$pid' has not ";
echo "yet been approved by the project leader. ";
#
# Lets not nag the PI for at least a day.
#
$membership = $unproj->MemberShipInfo($login_user);
$applied = strtotime($membership["date_applied"]);
if (time() - $applied > 3600 * 18) {
echo "<a href='#' class=alert-link ";
echo " onclick=\"APT_OPTIONS.nagPI(" . "'$pid'" . ")\"";
echo " style='text-decoration: underline'>";
echo "Remind the Project Leader.</a>";
}
}
echo "</span></center></div>";
}
list($pcount, $phours) = Instance::CurrentUsage($login_user);
list($foo, $weeksusage) = Instance::WeeksUsage($login_user);
list($foo, $monthsusage) = Instance::MonthsUsage($login_user);
......
......@@ -329,6 +329,48 @@ function Do_SendTestMessage()
SPITAJAX_RESPONSE(1);
}
function Do_NagPI()
{
global $this_user, $ajax_args;
if (!isset($ajax_args["pid"])) {
SPITAJAX_ERROR(-1, "Missing project name");
return -1;
}
if (!TBvalid_pid($ajax_args["pid"])) {
SPITAJAX_ERROR(-1, "Invalid project name");
return -1;
}
$project = Project::Lookup($ajax_args["pid"]);
if (!$project) {
SPITAJAX_ERROR(-1, "No such project");
return -1;
}
$group = $project->DefaultGroup();
if (!$group) {
SPITAJAX_ERROR(-1, "Internal error getting group");
return -1;
}
$membership = $group->MemberShipInfo($this_user);
if ($membership["date_approved"]) {
SPITAJAX_ERROR(1, "You have already been approved, please refresh ".
"the page to see your updated status.");
return -1;
}
if ($membership["date_nagged"]) {
$nagged = strtotime($membership["date_nagged"]);
if (time() - $nagged < 3600 * 24) {
SPITAJAX_ERROR(1, "You recently reminded the project leader, ".
"lets give him/her a chance to respond before ".
"sending another reminder.");
return -1;
}
}
# Chalk an error up to a double click, do not bother to do anything.
$group->NewMemberNotify($this_user, true);
SPITAJAX_RESPONSE("nagged");
}
# Local Variables:
# mode:php
# End:
......
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