Skip to content
Snippets Groups Projects
Commit 3f2d40c7 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

As per Jay's request, send a join request to new leader for old

leader, when changing the leader of a project when its created.
parent a10e8b3d
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ sub usage() ...@@ -26,7 +26,7 @@ sub usage()
my $optlist = "qsh:m:f:"; my $optlist = "qsh:m:f:";
my $quiet = 0; my $quiet = 0;
my $silent = 0; my $silent = 0;
my $leader_uid; my $newleader_uid;
my $message; my $message;
my $mfilename; my $mfilename;
my $pid; my $pid;
...@@ -40,7 +40,9 @@ sub fatal($); ...@@ -40,7 +40,9 @@ sub fatal($);
my $TB = "@prefix@"; my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@"; my $TBOPS = "@TBOPSEMAIL@";
my $TBAPPROVAL = "@TBAPPROVALEMAIL@"; my $TBAPPROVAL = "@TBAPPROVALEMAIL@";
my $TBAUDIT = "@TBAUDITEMAIL@";
my $TBBASE = "@TBBASE@"; my $TBBASE = "@TBBASE@";
my $TBWWW = "@TBWWW@";
my $MKGROUP = "$TB/sbin/mkgroup"; my $MKGROUP = "$TB/sbin/mkgroup";
my $MODGROUPS = "$TB/sbin/modgroups"; my $MODGROUPS = "$TB/sbin/modgroups";
my $MKACCT = "$TB/sbin/tbacct add"; my $MKACCT = "$TB/sbin/tbacct add";
...@@ -93,7 +95,7 @@ my $CVSREPOS = "$PROJROOT/cvsrepos"; ...@@ -93,7 +95,7 @@ my $CVSREPOS = "$PROJROOT/cvsrepos";
# Locals # Locals
my $leader; my $leader;
my $projhead; my $oldleader;
# #
# We do not want to run this script unless its the real version. # We do not want to run this script unless its the real version.
...@@ -134,7 +136,7 @@ if (defined($options{"f"})) { ...@@ -134,7 +136,7 @@ if (defined($options{"f"})) {
if (! -e $mfilename); if (! -e $mfilename);
} }
if (defined($options{"h"})) { if (defined($options{"h"})) {
$leader_uid = $options{"h"}; $newleader_uid = $options{"h"};
} }
usage() usage()
if (! @ARGV); if (! @ARGV);
...@@ -201,10 +203,10 @@ if (defined($mfilename)) { ...@@ -201,10 +203,10 @@ if (defined($mfilename)) {
# leader. Note that this is allowed *only* for projects that have not # leader. Note that this is allowed *only* for projects that have not
# been approved yet. # been approved yet.
# #
if (defined($leader_uid)) { if (defined($newleader_uid)) {
$leader = User->Lookup($leader_uid); $leader = User->Lookup($newleader_uid);
if (!defined($leader)) { if (!defined($leader)) {
fatal("Could not map user $leader_uid to its object!"); fatal("Could not map user $newleader_uid to its object!");
} }
# See if already did this; is so skip the following checks. # See if already did this; is so skip the following checks.
my $curleader = $target_project->GetLeader(); my $curleader = $target_project->GetLeader();
...@@ -215,11 +217,14 @@ if (defined($leader_uid)) { ...@@ -215,11 +217,14 @@ if (defined($leader_uid)) {
fatal("Not allowed to change the leader of an approved project!") fatal("Not allowed to change the leader of an approved project!")
if ($target_project->approved()); if ($target_project->approved());
# Save for email below.
$oldleader = $curleader;
# Update the project structure with the new leader. We are going # Update the project structure with the new leader. We are going
# to set the approved bit below, so this is the last chance to do # to set the approved bit below, so this is the last chance to do
# this until we have code in place to change it later. # this until we have code in place to change it later.
$target_project->ChangeLeader($leader) == 0 or $target_project->ChangeLeader($leader) == 0 or
fatal("Could not change project leader for $pid to $leader_uid!"); fatal("Could not change leader for $pid to $newleader_uid!");
} }
} }
else { else {
...@@ -481,6 +486,28 @@ if (!$silent) { ...@@ -481,6 +486,28 @@ if (!$silent) {
"Testbed Operations\n", "Testbed Operations\n",
"$TBAPPROVAL", "$TBAPPROVAL",
"Bcc: $TBAPPROVAL"); "Bcc: $TBAPPROVAL");
#
# If the leader was switched, then generate a second message to the
# new leader telling him to approve the original leader to the project.
#
if (defined($oldleader)) {
my $oldleader_uid = $oldleader->uid();
my $oldleader_name = $oldleader->name();
SENDMAIL("$leader_name <$leader_email>",
"$oldleader_uid $pid Project Join Request",
"$oldleader_name wants to join project $pid.\n".
"\n".
"Please return to $TBWWW,\n".
"log in, select the 'New User Approval' page, and enter\n".
"your decision regarding ${oldleader_name}'s membership.\n".
"\n".
"Thanks,\n".
"Testbed Operations\n",
"$TBAPPROVAL",
"Bcc: $TBAUDIT");
}
} }
print "Project Creation Completed!\n"; print "Project Creation Completed!\n";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment