--- loncom/interface/domainprefs.pm 2009/08/08 00:36:00 1.101 +++ loncom/interface/domainprefs.pm 2009/08/11 23:24:29 1.102 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.101 2009/08/08 00:36:00 raeburn Exp $ +# $Id: domainprefs.pm,v 1.102 2009/08/11 23:24:29 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -297,7 +297,9 @@ sub handler { {text => 'Request creation of courses', help => 'Domain_Configuration_Request_Courses', header => [{col1 => 'User affiliation', - col2 => 'Availability/Processing of requests',}], + col2 => 'Availability/Processing of requests',}, + {col1 => 'Setting', + col2 => 'Value'}], }, 'coursecategories' => { text => 'Cataloging of courses', @@ -423,7 +425,7 @@ sub print_config_box { $rowtotal ++; if (($action eq 'autoupdate') || ($action eq 'rolecolors') || ($action eq 'usercreation') || ($action eq 'usermodification') || - ($action eq 'coursecategories')) { + ($action eq 'coursecategories') || ($action eq 'requestcourses')) { my $colspan = ''; if (($action eq 'rolecolors') || ($action eq 'coursecategories')) { $colspan = ' colspan="2"'; @@ -445,6 +447,8 @@ sub print_config_box { $output .= &print_usermodification('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'coursecategories') { $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal); + } elsif ($action eq 'requestcourses') { + $output .= &print_quotas($dom,$settings,\$rowtotal,$action); } else { $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal); } @@ -492,6 +496,8 @@ sub print_config_box { $rowtotal ++; } elsif ($action eq 'coursecategories') { $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); + } elsif ($action eq 'requestcourses') { + $output .= &print_courserequestmail($dom,$settings,\$rowtotal); } else { $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).' @@ -575,8 +581,6 @@ sub print_config_box { $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'serverstatuses') { $output .= &print_serverstatuses($dom,$settings,\$rowtotal); - } elsif ($action eq 'requestcourses') { - $output .= &print_quotas($dom,$settings,\$rowtotal,$action); } } $output .= ' @@ -1446,6 +1450,84 @@ sub print_quotas { return $datatable; } +sub print_courserequestmail { + my ($dom,$settings,$rowtotal) = @_; + my ($now,$datatable,%dompersonnel,@domcoord,@currapprove,$rows); + $now = time; + $rows = 0; + %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now); + 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); + } + } + } + if (ref($settings) eq 'HASH') { + if (ref($settings->{'notify'}) eq 'HASH') { + if ($settings->{'notify'}{'approval'} ne '') { + @currapprove = split(',',$settings->{'notify'}{'approval'}); + } + } + } + if (@currapprove) { + foreach my $dc (@currapprove) { + unless (grep(/^\Q$dc\E$/,@domcoord)) { + push(@domcoord,$dc); + } + } + } + @domcoord = sort(@domcoord); + my $numinrow = 4; + my $numdc = @domcoord; + my $css_class = 'class="LC_odd_row"'; + $datatable = ''. + ' '.&mt('Receive notification of course requests requiring approval.'). + ' '. + ' '; + if (@domcoord > 0) { + $datatable .= ''; + for (my $i=0; $i<$numdc; $i++) { + my $rem = $i%($numinrow); + if ($rem == 0) { + if ($i > 0) { + $datatable .= ''; + } + $datatable .= ''; + $rows ++; + } + my $check = ' '; + if (grep(/^\Q$domcoord[$i]\E$/,@currapprove)) { + $check = ' checked="checked" '; + } + my ($uname,$udom) = split(':',$domcoord[$i]); + my $fullname = &Apache::loncommon::plainname($uname,$udom); + if ($i == $numdc-1) { + my $colsleft = $numinrow-$rem; + if ($colsleft > 1) { + $datatable .= ''; + } + $datatable .= '
'; + } else { + $datatable .= ''; + } + } else { + $datatable .= ''; + } + $datatable .= '
'; + } else { + $datatable .= &mt('There are no active Domain Coordinators'); + $rows ++; + } + $datatable .=''; + $$rowtotal += $rows; + return $datatable; +} + sub print_autoenroll { my ($dom,$settings,$rowtotal) = @_; my $autorun = &Apache::lonnet::auto_run(undef,$dom), @@ -1682,7 +1764,8 @@ sub print_contacts { my $datatable; my @contacts = ('adminemail','supportemail'); my (%checked,%to,%otheremails); - my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail'); + my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail', + 'requestsmail'); foreach my $type (@mailings) { $otheremails{$type} = ''; } @@ -1713,6 +1796,7 @@ sub print_contacts { $checked{'packagesmail'}{'adminemail'} = ' checked="checked" '; $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" '; $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" '; + $checked{'requestsmail'}{'adminemail'} = ' checked="checked" '; } my ($titles,$short_titles) = &contact_titles(); my $rownum = 0; @@ -1758,6 +1842,7 @@ sub contact_titles { 'packagesmail' => 'Package update alerts to be e-mailed to', 'helpdeskmail' => 'Helpdesk requests to be e-mailed to', 'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)', + 'requestsmail' => 'E-mail from course requests requiring approval', ); my %short_titles = &Apache::lonlocal::texthash ( adminemail => 'Admin E-mail address', @@ -3715,7 +3800,26 @@ sub modify_quotas { } } } - unless ($context eq 'requestcourses') { + if ($context eq 'requestcourses') { + my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify'); + @approvalnotify = sort(@approvalnotify); + $confhash{'notify'}{'approval'} = join(',',@approvalnotify); + if (ref($domconfig{$action}) eq 'HASH') { + if (ref($domconfig{$action}{'notify'}) eq 'HASH') { + if ($domconfig{$action}{'notify'}{'approval'} ne $confhash{'notify'}{'approval'}) { + $changes{'notify'}{'approval'} = 1; + } + } else { + if ($domconfig{$action}{'notify'}{'approval'}) { + $changes{'notify'}{'approval'} = 1; + } + } + } else { + if ($domconfig{$action}{'notify'}{'approval'}) { + $changes{'notify'}{'approval'} = 1; + } + } + } else { $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'}; } foreach my $item (@usertools) { @@ -3885,6 +3989,19 @@ sub modify_quotas { $resulttext .= ''; } } + if ($action eq 'requestcourses') { + if (ref($changes{'notify'}) eq 'HASH') { + if ($changes{'notify'}{'approval'}) { + if (ref($confhash{'notify'}) eq 'HASH') { + if ($confhash{'notify'}{'approval'}) { + $resulttext .= '
  • '.&mt('Notification of requests requiring approval will be sent to: ').$confhash{'notify'}{'approval'}.'
  • '; + } else { + $resulttext .= '
  • '.&mt('No Domain Coordinators will receive notification of course requests requiring approval.').'
  • '; + } + } + } + } + } $resulttext .= ''; if (keys(%newenv)) { &Apache::lonnet::appenv(\%newenv); @@ -4277,7 +4394,8 @@ sub modify_contacts { } my (%others,%to); my @contacts = ('supportemail','adminemail'); - my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail'); + my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail', + 'requestsmail'); foreach my $type (@mailings) { @{$newsetting{$type}} = &Apache::loncommon::get_env_multiple('form.'.$type); @@ -4323,6 +4441,7 @@ sub modify_contacts { $default{'packagesmail'} = 'adminemail'; $default{'helpdeskmail'} = 'supportemail'; $default{'lonstatusmail'} = 'adminemail'; + $default{'requestsmail'} = 'adminemail'; foreach my $item (@contacts) { if ($to{$item} ne $default{$item}) { $changes{$item} = 1;