[LON-CAPA-cvs] cvs: loncom /build add_domain_coordinator_privilege.pl
raeburn
raeburn@source.lon-capa.org
Mon, 28 Mar 2011 14:18:22 -0000
raeburn Mon Mar 28 14:18:22 2011 EDT
Modified files:
/loncom/build add_domain_coordinator_privilege.pl
Log:
- Clean up code.
- Call LONCAPA::locking_hash_untie for roles.db if user already has active DC
role for the domain.
Index: loncom/build/add_domain_coordinator_privilege.pl
diff -u loncom/build/add_domain_coordinator_privilege.pl:1.4 loncom/build/add_domain_coordinator_privilege.pl:1.5
--- loncom/build/add_domain_coordinator_privilege.pl:1.4 Thu Jan 3 21:16:11 2008
+++ loncom/build/add_domain_coordinator_privilege.pl Mon Mar 28 14:18:22 2011
@@ -14,7 +14,7 @@
# add_domain_coordinator_privilege.pl - Add domain coordinator to an
# exisiting user on a LON-CAPA system.
#
-# $Id: add_domain_coordinator_privilege.pl,v 1.4 2008/01/03 21:16:11 raeburn Exp $
+# $Id: add_domain_coordinator_privilege.pl,v 1.5 2011/03/28 14:18:22 raeburn Exp $
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
@@ -152,6 +152,8 @@
if (!$rolesref) {
die('unable to tie roles db: '."$udpath/roles.db");
}
+my $status;
+my $now = time;
if (exists($rolesref->{'/'.$add_domain.'/_dc'})) {
my ($role,$end,$start) = split('_',$rolesref->{'/'.$add_domain.'/_dc'});
print(&mt("[_1] already has a dc privilege for [_2].",
@@ -161,24 +163,34 @@
"\n");
if (!$end) {
print(&mt("No planned end date.")."\n");
- }
- if ($start < time() && (!$end || $end > time())) {
- print(&mt("It is currently active."));
- exit(0);
+ } else {
+ print(&mt("End date: [_1]",&Apache::lonlocal::locallocaltime($end)).
+ "\n");
+ }
+ if (($start <= $now) && (!$end || $end > $now)) {
+ print(&mt("It is currently active.")."\n");
+ $status = 'active';
}
} elsif ($end) {
print(&mt("End date: [_1]",&Apache::lonlocal::locallocaltime($end)).
"\n");
- if ($end > time()) {
+ if ($end > $now) {
print(&mt("It is currently active.")."\n");
- exit(0);
+ $status = 'active';
}
}
- if (!$start and !$end) {
+ if ((!$start) && (!$end)) {
print(&mt("It is currently active.")."\n");
- exit(0);
+ $status = 'active';
}
- print(&mt("It is currently not active. Proceeding to re-enable")."\n");
+ unless ($status eq 'active') {
+ print(&mt("It is currently not active. Proceeding to make role active now.")."\n");
+ }
+}
+
+if ($status eq 'active') {
+ &LONCAPA::locking_hash_untie($rolesref);
+ exit(0);
}
my $now = time;
@@ -221,7 +233,4 @@
# Output success message, and inform sysadmin about how to further proceed.
print("$username is now a domain coordinator for $add_domain\n");
-my $hostname=`hostname`; chomp($hostname); # Read in hostname.
-print("http://$hostname/adm/createuser will allow you to further define".
- " this user.\n"); # Output a suggested URL.