--- loncom/interface/lonpopulate.pm 2006/05/18 01:08:51 1.43 +++ loncom/interface/lonpopulate.pm 2006/07/27 23:24:19 1.44 @@ -1,5 +1,5 @@ # automated enrollment configuration handler -# $Id: lonpopulate.pm,v 1.43 2006/05/18 01:08:51 raeburn Exp $ +# $Id: lonpopulate.pm,v 1.44 2006/07/27 23:24:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -479,6 +479,8 @@ ENDTWO } elsif ($action eq "notify") { my $notifycount = 0; my @notified = split(/,/,$enrollvar{notifylist}); + my @domcoord; + my @showdom; for (my $i=0; $i<@notified; $i++) { if ($notified[$i] !~ /:/) { $notified[$i] =~ s/\@/:/; @@ -491,7 +493,15 @@ ENDTWO } else { $noteset = "OFF"; } - + my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']); + foreach my $server (keys %dompersonnel) { + foreach my $user (sort(keys %{$dompersonnel{$server}})) { + my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user); + if (!grep/^$uname:$udom$/,@domcoord) { + push(@domcoord,$uname.':'.$udom); + } + } + } $r->print("

@@ -521,113 +531,135 @@ ENDTWO "); - my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$dom,$crs); - my @ccs = (); - my @oldccs = (); - my %pname = (); - my %notifystate = (); - foreach (@coursepersonnel) { - my @roleinfo = split/:/,$_; - if ($roleinfo[0] eq 'cc') { - unless (grep/^$roleinfo[1]\:$roleinfo[2]/,@ccs) { - my $active_cc = &Apache::loncommon::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc'); - if ($active_cc eq 'active') { - push @ccs, $roleinfo[1].':'.$roleinfo[2]; - $pname{$roleinfo[1].':'.$roleinfo[2]} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]); - if (grep/^$roleinfo[1]\:$roleinfo[2]$/,@notified) { - $notifystate{$roleinfo[1].':'.$roleinfo[2]} = 1; - } else { - $notifystate{$roleinfo[1].':'.$roleinfo[2]} = 0; - } + my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$dom,$crs); + my @ccs; + my %pname; + my %notifystate; + my %status; + my $now = time; + foreach my $person (sort(keys(%coursepersonnel))) { + my $match = 0; + my ($role,$user,$usec) = ($person =~ /^([^:]+):([^:]+:[^:]+):([^:]*)/); + $user =~ s/:$//; + my ($end,$start) = split(/:/,$coursepersonnel{$person}); + if ($end == -1 || $start == -1) { + next; + } + if ($role eq 'cc') { + unless (grep/^$user$/,@ccs) { + if ($end && $end < $now) { + $status{$user} = 'previous'; + } elsif ($start > $now) { + $status{$user} = 'future'; } else { - push @oldccs, $roleinfo[1].':'.$roleinfo[2]; + $status{$user} = 'active'; + } + push(@ccs,$user); + my ($uname,$udom) = split(/:/,$user); + $pname{$user} = + &Apache::loncommon::plainname($uname,$udom); + if (grep/^$user$/,@notified) { + $notifystate{$user} = 1; + } else { + $notifystate{$user} = 0; } } } } - if ($notifycount > 0) { - foreach my $person (@notified) { - unless ( (grep/^$person$/,@ccs) || ($person eq '') || (grep/^$person$/,@oldccs) ) { - push @ccs, $person; - my ($puname,$pdom) = split/:/,$person; - $pname{$person} = &Apache::loncommon::plainname($puname,$pdom); - $notifystate{$person} = 1; - } - } - } - my $viewer = $env{'user.name'}.':'.$env{'user.domain'}; - unless ( (grep/^$viewer$/,@ccs) || ($viewer eq '') ) { - push @ccs,$viewer; - $pname{$viewer} = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); - $notifystate{$viewer} = 0; - } - my $notifyshow = @ccs; - + my %lt = &Apache::lonlocal::texthash( + name => 'Name', + usnm => 'username:domain', + coac => 'Course Access', + curn => 'Current notification status', + notf => 'Notification?', + ntac => 'Notification active', + ntin => 'Notification inactive', + ); if (@ccs > 0) { @ccs = sort @ccs; $r->print(" - "); + } else { $r->print(" - - - - - "); - $r->print(&Apache::loncommon::end_data_table_row()); - for (my $i=0; $i<@ccs; $i++) { - $r->print(&Apache::loncommon::start_data_table_row()); - $r->print(" - - - "); + + + "); + } + my $viewer = $env{'user.name'}.':'.$env{'user.domain'}; + my $showalldc = 0; + if (grep(/^$viewer$/,@domcoord)) { + $showalldc = 1; + } + foreach my $dc (@domcoord) { + if (!grep(/^$dc$/,@ccs)) { + if (grep(/^$dc$/,@notified)) { + $notifystate{$dc} = 1; } else { - $r->print(""); + $notifystate{$dc} = 0; + if (!$showalldc) { + next; + } } - $r->print(&Apache::loncommon::end_data_table_row()); + my ($dcuname,$dcdom) = split(/:/,$dc); + $pname{$dc} = &Apache::loncommon::plainname($dcuname,$dcdom); + push(@showdom,$dc); } - $r->print(&Apache::loncommon::end_data_table()); + } + my $showdomnum = scalar(@showdom); + if ($showdomnum) { $r->print(" -
-
The table below contains a list of course coordinators in this course. Uncheck the 'Notification?' checkbox for each person who is to be removed from the list of recipients who are currently informed of roster changes whenever any adds or drops occur during the nightly enrollment check. To include individuals who are not currently recipients, simply check the 'Notification?' checkbox. Click 'Go' to store your changes. + ".&mt('The table below contains a list of [_1]s in this course.',&Apache::lonnet::plaintext('cc'))."
"); - $r->print(&Apache::loncommon::start_data_table()); - $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(¬ifier_tables('cc',\%lt,\@ccs,\%status,\%notifystate, + \%pname,\$notifyshow)); + $r->print("
Nameusername:domainCurrent statusNotification?$pname{$ccs[$i]}$ccs[$i] - "); - if ($notifystate{$ccs[$i]} == 1) { - $r->print("Notification active"); - } else { - $r->print("Notification inactive"); - } - if ($notifystate{$ccs[$i]} == 1) { - $r->print("
". + &mt('No [_1]s found.',&Apache::lonnet::plaintext('cc'))." +
- - - -
- -
+ +   + + "); + if ($showalldc) { + $r->print(&mt("The table below contains a list of [_1]s from this course's domain who are not also [_2]s.",&Apache::lonnet::plaintext('dc'),&Apache::lonnet::plaintext('cc'))); + } else { + $r->print(&mt("The table below contains a list of [_1] from this course's domain who currently receive notification, and are not also [_2]s.",&Apache::lonnet::plaintext('dc'),&Apache::lonnet::plaintext('cc'))); + } + $r->print(" - "); - } else { - $r->print(" - - No course coordinators found. - - "); + "); + $r->print(¬ifier_tables('dc',\%lt,\@showdom,\%status,\%notifystate, + \%pname,\$notifyshow)); + $r->print(" + + "); + } + if ($notifycount || @showdom > 0) { + $r->print(" ". + &mt("Uncheck the 'Notification?' checkbox for each person who is to be removed from the list of recipients who are currently informed of roster changes whenever any adds or drops occur during the nightly enrollment check.").' '.&mt("To include individuals who are not currently recipients, simply check the 'Notification?' checkbox. Click 'Go' to store your changes.")." +
+ + + + +
+ +
+ + + "); } $r->print(" - - - - -
+ + + + + "); } elsif ($action eq "crosslist") { my @xlists; @@ -881,16 +913,22 @@ your changes. my ($result,$perm_reqd)=&Apache::lonnet::auto_photo_permission($crs,$dom); my $can_enable = 1; my $institution = $Apache::lonnet::domaindescription{$dom}; + my $user; + if ($enrollvar{'courseowner'} =~ /^[^:]+:[^:]+$/) { + $user = $env{'user.name'}.':'.$env{'user.domain'}; + } else { + $user = $env{'user.name'}; + } if ($result eq 'ok') { if ($perm_reqd eq 'yes') { if (!($enrollvar{'photopermission'} eq 'yes')) { $can_enable = 0; } else { - if ($env{'user.name'} eq $enrollvar{'courseowner'}) { + if ($user eq $enrollvar{'courseowner'}) { $r->print(' '. -&mt('Previously the owner of this course agreed to the conditions of use of digital student photos required by [_1].', $institution).'
'.&mt('As a result Course Coordinators can choose to automatically import student photos into this course.').'
+&mt('Previously the owner of this course agreed to the conditions of use of digital student photos required by [_1].', $institution).'
'.&mt('As a result [_1]s can choose to automatically import student photos into this course.',&Apache::lonnet::plaintext('cc')).'
'); @@ -919,7 +957,7 @@ your changes. '); } else { - if ($env{'user.name'} eq $enrollvar{'courseowner'}) { + if ($user eq $enrollvar{'courseowner'}) { $r->print(' '. @@ -937,7 +975,7 @@ your changes. $r->print(' '. -&mt('The policies of your institution [_1] require that the course owner [_2] must indicate acceptance of the conditions of use of digital photos of registered students, before they may be made available for use in a course.',$institution,$ownername).'

'.&mt('Please direct the course owner [_1] to visit the "Student photos" page in the Automated Enrollment Manager to indicate acceptance of these conditions of use.',$emailstr).'

+&mt('The policies of your institution ([_1]) require that the course owner ([_2]) must indicate acceptance of the conditions of use of digital photos of registered students, before they may be made available for use in a course.',$institution,$ownername).'

'.&mt('Please direct the course owner [_1] to visit the "Student photos" page in the Automated Enrollment Manager to indicate acceptance of these conditions of use.',$emailstr).'

@@ -1133,6 +1171,44 @@ END } } +sub notifier_tables { + my ($role,$lt,$users,$status,$notifystate,$pname,$notifyshow) = @_; + my $output = &Apache::loncommon::start_data_table(); + $output .= &Apache::loncommon::start_data_table_header_row(); + $output .= "$$lt{name} + $$lt{usnm}"; + if ($role eq 'cc') { + $output .= "$$lt{coac}"; + } + $output .= "$$lt{curn} + $$lt{notf}"; + $output .= &Apache::loncommon::end_data_table_header_row(); + for (my $i=0; $i<@{$users}; $i++) { + $output .= &Apache::loncommon::start_data_table_row(); + $output .= ''.$$pname{$$users[$i]}.''. + ''.$$users[$i].''; + if ($role eq 'cc') { + $output .= ''.$$status{$$users[$i]}.''; + } + $output .= ''; + if ($$notifystate{$$users[$i]} == 1) { + $output .= $$lt{ntac}; + } else { + $output .= $$lt{ntin}; + } + $output .= ' not enabled as no [_1]s were selected as recipients.
',&Apache::lonnet::plaintext('cc')); } } else { if ($currcount) { @@ -2287,8 +2363,12 @@ function agreement_result(caller) { '; } else { - my ($ownername,$owneremail) = &get_oenerinfo($dom,$courseowner); - $response = &mt('The policies of your institution [_1] require that the course owner [_2] must indicate acceptance of the conditions of use of digital photos of registered students, before they may be made available for use in a course.',$institution,$ownername).'

'.&mt('Please direct the course owner (e-mail: [_1]) to visit the "Student photos" page in the Automated Enrollment Manager to indicate acceptance of these conditions of use',$owneremail); + my ($ownername,$owneremail) = &get_ownerinfo($dom,$courseowner); + my $emailstr; + if ($owneremail) { + $emailstr = "(e-mail: $owneremail)"; + } + $response = &mt('The policies of your institution [_1] require that the course owner [_2] must indicate acceptance of the conditions of use of digital photos of registered students, before they may be made available for use in a course.',$institution,$ownername).'

'.&mt('Please direct the course owner [_1] to visit the "Student photos" page in the Automated Enrollment Manager to indicate acceptance of these conditions of use',$emailstr); } &print_reply($r,$response,$$tasktitleref{$action}); } @@ -2426,11 +2506,19 @@ function photowindow(photolink) { sub get_ownerinfo { my ($dom,$owner) = @_; - my ($ownername,$owneremail); + my ($ownername,$owneremail,$own_uname,$own_udom); if ($owner) { - $ownername=&Apache::loncommon::plainname($owner,$dom,'firstname'); + if ($owner =~ /^([^:]+):([^:]+)$/) { + $own_uname = $1; + $own_udom = $2; + } else { + $own_uname = $owner; + $own_udom = $dom; + } + $ownername=&Apache::loncommon::plainname($own_uname,$own_udom, + 'firstname'); my %ownerinfo = &Apache::lonnet::get('environment',['permanentemail'], - $dom,$owner); + $own_udom,$own_uname); $owneremail = $ownerinfo{'permanentemail'}; } return ($ownername,$owneremail);