--- loncom/build/add_domain_coordinator_privilege.pl 2008/01/03 21:16:11 1.4 +++ loncom/build/add_domain_coordinator_privilege.pl 2011/03/28 14:18:22 1.5 @@ -14,7 +14,7 @@ exisiting user on a LON-CAPA system. # 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 @@ my $rolesref=&LONCAPA::locking_hash_tie( 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 @@ if (exists($rolesref->{'/'.$add_domain.' "\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 @@ by going to http://MACHINENAME/adm/creat # 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.