File:  [LON-CAPA] / loncom / interface / lonwhatsnew.pm
Revision 1.98.2.1: download - view: text, annotated - select for diffs
Mon Dec 14 22:24:31 2009 UTC (14 years, 6 months ago) by raeburn
Branches: GCI_3
- Customization for GCI_3.
  CCs in GCI Concept Test Course:
    - No toggle first item shown
    - Only four items shown: course messages and enrollment changes.

    1: #
    2: # $Id: lonwhatsnew.pm,v 1.98.2.1 2009/12/14 22:24:31 raeburn Exp $
    3: #
    4: # Copyright Michigan State University Board of Trustees
    5: #
    6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    7: #
    8: # LON-CAPA is free software; you can redistribute it and/or modify
    9: # it under the terms of the GNU General Public License as published by
   10: # the Free Software Foundation; either version 2 of the License, or
   11: # (at your option) any later version.
   12: #
   13: # LON-CAPA is distributed in the hope that it will be useful,
   14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16: # GNU General Public License for more details.
   17: #
   18: # You should have received a copy of the GNU General Public License
   19: # along with LON-CAPA; if not, write to the Free Software
   20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   21: #
   22: # /home/httpd/html/adm/gpl.txt
   23: #
   24: # http://www.lon-capa.org/
   25: #
   26: 
   27: 
   28: package Apache::lonwhatsnew;
   29: 
   30: use strict;
   31: use lib qw(/home/httpd/lib/perl);
   32: use Apache::lonnet;
   33: use Apache::loncommon();
   34: use Apache::lonhtmlcommon();
   35: use Apache::lonlocal;
   36: use Apache::loncoursedata();
   37: use Apache::lonnavmaps();
   38: use Apache::lonuserstate;
   39: use Apache::lonuserutils; 
   40: use Apache::Constants qw(:common :http);
   41: use Time::Local;
   42: use GDBM_File;
   43: use lib '/home/httpd/lib/perl/';
   44: use LONCAPA;
   45: use HTML::Entities;
   46: 
   47: #----------------------------
   48: # handler
   49: #
   50: #----------------------------
   51: 
   52: sub handler {
   53:     my $r = shift;
   54:     if ($r->header_only) {
   55:         &Apache::loncommon::content_type($r,'text/html');
   56:         $r->send_http_header;
   57:         return OK;
   58:     }
   59:     &Apache::loncommon::get_unprocessed_cgi(
   60:                                    $ENV{'QUERY_STRING'},['command','refpage']);
   61: 
   62:     my $command = $env{'form.command'};
   63:     my $refpage = $env{'form.refpage'};
   64: 
   65:     my %checkallowed = ( coursenormalmail => 1,
   66: 			 coursecritmail => 1, );
   67:     foreach my $perm_check (['whn','whatsnew',1],
   68: 			    ['pch','coursediscussion',1],
   69: 			    ['mgr','handgrading',1],
   70: 			    ['vgr','abovethreshold',1],
   71: 			    ['opa','haserrors',1],
   72: 			    ['mdc','versionchanges',0],
   73:                             ['vcl','newroles',1],
   74:                             ['vcl','oldroles',1],
   75: 			    ) {
   76: 	my ($perm,$key,$check_section) = @{ $perm_check };
   77: 	my $scope = $env{'request.course.id'};
   78: 	if (!($checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope))) {
   79: 	    $scope .= '/'.$env{'request.course.sec'};
   80: 	    if ( $check_section ) {
   81: 		$checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope);
   82: 	    }
   83: 	    if ($checkallowed{$key}) {
   84: 		$checkallowed{$key.'_section'} = $env{'request.course.sec'};
   85: 	    }
   86: 	}
   87:     }
   88: 
   89:     if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) {
   90:         # Not in a course, or no whn priv in course
   91:         $env{'user.error.msg'}="/adm/whatsnew::whn:0:0:Cannot display what's new page";
   92:         return HTTP_NOT_ACCEPTABLE;
   93:     }
   94: 
   95:     &Apache::loncommon::content_type($r,'text/html');
   96:     $r->send_http_header;
   97: 
   98:     $r->print(&display_header($command,\%checkallowed));
   99: 
  100:     &Apache::lonhtmlcommon::clear_breadcrumbs();
  101:     &Apache::lonhtmlcommon::add_breadcrumb
  102:             ({href=>'/adm/whatsnew',
  103:               text=>"What's New?"});
  104:     if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) {
  105:         &Apache::lonhtmlcommon::add_breadcrumb
  106:             ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage,
  107:               text=>"Change thresholds"});
  108:         $r->print(&Apache::lonhtmlcommon::breadcrumbs
  109:             ("What's New?",#'Course_Action_Items_Thresholds'
  110: 	     ));
  111:     } elsif (($command eq 'chginterval') && $checkallowed{'versionchanges'} ) {
  112:         &Apache::lonhtmlcommon::add_breadcrumb
  113:             ({href=>'/adm/whatsnew?command=chginterval&refpage='.$refpage,
  114:               text=>"Change interval"});
  115:         $r->print(&Apache::lonhtmlcommon::breadcrumbs
  116:             ("What's New?",#'Course_Action_Items_Intervals'
  117: 	     ));
  118:     } elsif (($command eq 'chgdisc') && $checkallowed{'coursediscussion'}) {
  119:         &Apache::lonhtmlcommon::add_breadcrumb
  120:             ({href=>'/adm/whatsnew?command=chgdisc&refpage='.$refpage,
  121:               text=>"Change discussion display"});
  122:         $r->print(&Apache::lonhtmlcommon::breadcrumbs
  123:             ("What's New?",#'Course_Action_Items_Intervals'
  124: 	     ));
  125:     } elsif ($command eq 'courseinit') {
  126:         &Apache::lonhtmlcommon::add_breadcrumb
  127:             ({href=>'/adm/whatsnew?command=courseinit&refpage='.$refpage,
  128:               text=>"Course initialization preference"});
  129:         $r->print(&Apache::lonhtmlcommon::breadcrumbs
  130:             ("What's New?",#'Course_Action_Items_Initialization'
  131: 	     ));
  132:     } elsif ($command eq 'chgoldroleinterval' && $checkallowed{'oldroles'}) {
  133:         &Apache::lonhtmlcommon::add_breadcrumb
  134:             ({href=>'/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage,
  135:               text=>"Change interval"});
  136:         $r->print(&Apache::lonhtmlcommon::breadcrumbs
  137:             ("What's New?",#'Course_Action_Items_Intervals'
  138:              ));
  139:     } elsif ($command eq 'chgnewroleinterval' && $checkallowed{'newroles'}) {
  140:         &Apache::lonhtmlcommon::add_breadcrumb
  141:             ({href=>'/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage,
  142:               text=>"Change interval"});
  143:         $r->print(&Apache::lonhtmlcommon::breadcrumbs
  144:             ("What's New?",#'Course_Action_Items_Intervals'
  145:              ));
  146:     } else {
  147:         $r->print(&Apache::lonhtmlcommon::breadcrumbs
  148:             ("What's New?",#'Course_Action_Items_Display'
  149: 	     ));
  150:     }
  151:     &display_main_box($r,$command,$refpage,\%checkallowed);
  152:     return OK;
  153: }
  154: 
  155: #------------------------------
  156: # display_main_box
  157: #
  158: # Display all the elements within the main box
  159: #------------------------------
  160:                                                                                 
  161: sub display_main_box {
  162:     my ($r,$command,$refpage,$checkallowed) = @_;
  163:     my $domain=&Apache::loncommon::determinedomain();
  164:     my $function = &Apache::loncommon::get_users_function();
  165:     my $lctype = lc(&Apache::loncommon::course_type());
  166:     $r->print('<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td width="100%">');
  167: 
  168:     my %threshold_titles = &Apache::lonlocal::texthash (
  169:                          av_attempts => 'Average number of attempts',
  170:                          degdiff => 'Degree of difficulty',
  171:                          numstudents => 'Total number of students with submissions',
  172:     );
  173:     my %versions = (
  174:                        -1 => "version changes since start of $lctype",
  175:                   2592000 => 'version changes since last month',
  176:                    604800 => 'version changes since last week',
  177:                     86400 => 'version changes since yesterday',
  178:                    );
  179:     my %newroles = (
  180:                        -1 => "roles which have become active since start of $lctype",
  181:                   2592000 => 'roles which have become active since last month',
  182:                    604800 => 'roles which have become active since last week',
  183:                     86400 => 'roles which have become active since yesterday',
  184:                    );
  185:     my %oldroles = (
  186:                        -1 => "roles which expired since start of $lctype",
  187:                   2592000 => 'roles which expired since last month',
  188:                    604800 => 'roles which expired since last week',
  189:                     86400 => 'roles which expired since yesterday',
  190:                    );
  191:     my %interval_titles = (
  192:         versions => \%versions,
  193:         newroles => \%newroles,
  194:         oldroles => \%oldroles,
  195:     );
  196:     my %initpage = &Apache::lonlocal::texthash (
  197:                      firstres => "first resource in the $lctype",
  198:                      whatsnew => "What's New Page",
  199:                      userpref => 'your general user preferences',
  200:                      coursespecific => "specific setting for this $lctype",
  201:                    );
  202:     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
  203:     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
  204: 
  205:     if (($command eq 'chgthreshold') 
  206: 	&& $checkallowed->{'abovethreshold'}) {
  207:         &display_threshold_config($r,$refpage,\%threshold_titles,
  208:                                                                    $cdom,$crs);
  209:     } elsif (($command eq 'chginterval') 
  210: 	     && $checkallowed->{'versionchanges'}) {
  211:         &display_interval_config($r,$refpage,\%interval_titles,'versions');
  212:     } elsif (($command eq 'chgdisc') 
  213: 	     && $checkallowed->{'coursediscussion'}) {
  214:         &display_discussion_config($r,$refpage);
  215:     } elsif ($command eq 'courseinit') {
  216:         &courseinit_config($r,$refpage,\%initpage);
  217:     } elsif (($command eq 'chgnewroleinterval')
  218:              && $checkallowed->{'newroles'}) {
  219:         &display_interval_config($r,$refpage,\%interval_titles,'newroles');
  220:     } elsif (($command eq 'chgoldroleinterval')
  221:              && $checkallowed->{'oldroles'}) {
  222:         &display_interval_config($r,$refpage,\%interval_titles,'oldroles');
  223:     } else {
  224:         &display_actions_box($r,$command,$refpage,\%threshold_titles,
  225:                         \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
  226:     }
  227:     my $end_page = &Apache::loncommon::end_page();
  228:     $r->print(<<END_OF_BLOCK);
  229:   </td>
  230:  </tr>
  231: </table><br />
  232: $end_page
  233: END_OF_BLOCK
  234: }
  235: 
  236: #-------------------------------
  237: # display_header
  238: #
  239: # Display the header information and set
  240: # up the HTML
  241: #-------------------------------
  242: 
  243: sub display_header {
  244:     my ($command,$checkallowed) = @_;
  245:     
  246:     my $scripttag;
  247:     unless ($command eq 'chgthreshold' || $command eq 'chginterval' || 
  248:             $command eq 'chgoldroleinterval' || $command eq 'chgnewroleinterval') {
  249:        $scripttag = <<"END";
  250: <script type="text/javascript">
  251: function change_display(caller,change) {
  252:     caller.value = change;
  253:     document.visible.submit();
  254: }
  255: 
  256: function changeAll(change) {
  257: END
  258:         foreach my $item (keys(%{$checkallowed})) {
  259: 	    if ($item =~ /_section$/) { next; }
  260:             if ($$checkallowed{$item}) {
  261:                 $scripttag.='document.visible.display_'.$item.'.value=change'.
  262:                             "\n";
  263:             }
  264:         }
  265:         $scripttag.='document.visible.submit();
  266: }
  267: </script>
  268: ';
  269:     }
  270:     my $course_type=&Apache::loncommon::course_type();
  271:     return &Apache::loncommon::start_page("What's New?",
  272: 					  $scripttag);
  273: }
  274: 
  275: #-------------------------------
  276: # display_actions_box
  277: #
  278: # Display the action items
  279: #
  280: #-------------------------------
  281:                                                                                 
  282: sub display_actions_box {
  283:     my ($r,$command,$refpage,$threshold_titles,$interval_titles,$initpage,
  284:         $cdom,$crs,$checkallowed) = @_;
  285:     my $custommenu = &Apache::loncommon::needs_gci_custom();
  286:     my $udom = $env{'user.domain'};
  287:     my $uname = $env{'user.name'};
  288:     my $cid = $env{'request.course.id'};
  289:     my $crstype = &Apache::loncommon::course_type();
  290:     my $lctype = lc($crstype);
  291:     my %stulabel = (
  292:                     'Course' => 'students',
  293:                     'Community' => 'members',
  294:                    );
  295:     my %lt = &Apache::lonlocal::texthash(
  296:                  'yacc' => 'You are accessing an invalid course',
  297:                  'gtfr' => 'Go to first resource',
  298:                  'hial' => 'Hide all',
  299:                  'shal' => 'Show all',
  300:     );
  301: 
  302:     my %unread = ();
  303:     my %ungraded = ();
  304:     my %bombed = ();
  305:     my %triggered = ();
  306:     my %changed = ();
  307:     my @newmsgs = ();
  308:     my @critmsgs = ();
  309:     my @newdiscussions = ();
  310:     my @tograde = ();
  311:     my @bombs = ();
  312:     my @warnings = ();
  313:     my $msgcount = 0;
  314:     my $critmsgcount = 0;
  315:     my $expirecount;
  316:     my %expired;
  317:     my $activecount;
  318:     my %activated;
  319:     my %res_title = ();
  320:     my %show = ();
  321:     my $needitems = 0;
  322:     my $boxcount = 0;
  323: 
  324:     my $result;
  325:     if ($command eq 'newcourseinit') {
  326:         $result = &store_courseinit_setting($uname,$udom,$cid,$initpage);
  327:     }
  328: 
  329:     my %threshold = ();
  330:     my %pagedesc = &Apache::lonlocal::texthash (
  331:                      firstres => 'First resource',
  332:                      whatsnew => "What's New Page",
  333:                      userpref => 'user preference',
  334:                      coursespecific => $lctype.' only',
  335:                      default => 'default',
  336:                    );
  337: 
  338:     my ($initcontrol,$initdisp) = &curr_courseinit();
  339:     my $currinit = $pagedesc{$initdisp}.' ('.$pagedesc{$initcontrol}.')';
  340: 
  341:     unless ($cid) {
  342:         $r->print('<p><span style="text-align: center; font-weight: bold;">'.$lt{'yacc'}.'</span></p>');
  343:         return;
  344:     }
  345: 
  346:     my $header = '';
  347:     if (($refpage eq 'start') && (!$custommenu)) {
  348:         if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
  349:             &GDBM_READER(),0640)) {
  350:             my $furl=&HTML::Entities::encode($bighash{'first_url'},'"<>&');
  351:             untie(%bighash);
  352:             $header .= '<b><a href="'.$furl.'">'.$lt{'gtfr'}.
  353:                   '</a></b><br />';
  354:         }
  355:     }
  356:     unless ($custommenu) {
  357:         $header .= &mt('Page set to be displayed after you have selected a role in this '.$lctype).'.'
  358:               .' <span class="LC_nobreak">'
  359:               .&mt('Currently: [_1].','<i>'.$currinit.'</i>')
  360:               .'&nbsp;&nbsp;'
  361:               .&mt('[_1]Change[_2] for just [_3]this '.$lctype.'[_4] or for [_5]all your courses/communities[_6].'
  362:                   ,'<b>'
  363:                   ,'</b>'
  364:                   ,'<a href="/adm/whatsnew?command=courseinit&amp;refpage='.$refpage.'">'
  365:                   ,'</a>'
  366:                   ,'<a href="/adm/preferences?action=changecourseinit&amp;refpage='.$refpage.'">'
  367:                   ,'</a>')
  368:               .' </span>';
  369: 
  370:         $r->print(&Apache::loncommon::head_subbox($header));
  371:     }
  372: 
  373:     if ($command eq 'reset') {
  374:         $result = &process_reset($cdom,$crs);
  375:     } elsif ($command eq 'update') {
  376:         $result = &process_update($uname,$udom,$threshold_titles);
  377:     } elsif ($command eq 'newinterval') {
  378:         $result = &store_interval_setting($uname,$udom,$cid,$interval_titles);
  379:     } elsif ($command eq 'newdiscconf') {
  380:         $result = &store_discussion_setting($uname,$udom,$cid);
  381:     }
  382: 
  383:     my $store_result=&store_display_settings($uname,$udom,$cid,$checkallowed);
  384: 
  385:     unless ($store_result eq 'ok') { 
  386:         &Apache::lonnet::logthis('Error saving whatsnew settings: '.
  387:             $store_result.' for '.'user '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
  388:         $result .= '<span class="LC_error">'
  389:                   .&mt('Unable to save visibility settings due to [_1]',
  390:                        $store_result)
  391:                   .'</span>';
  392:     }
  393: 
  394:     if ($result) {
  395:         $r->print($result.'<hr />');
  396:     }
  397:     $r->rflush();
  398: 
  399:     my (%timediff,%interval);
  400:     my %display_settings = &get_display_settings($uname,$udom,$cid);
  401:     $timediff{'versions'} = $display_settings{$cid.':interval'};
  402:     unless (defined($timediff{'versions'})) { $timediff{'versions'} = 604800; } 
  403:     $interval{'versions'} = $interval_titles->{'versions'}->{$timediff{'versions'}};
  404: 
  405:     my %headings = &Apache::lonlocal::texthash(
  406:                 coursediscussion => 'Unread '.$lctype.' discussion posts',
  407:                 handgrading      => 'Problems requiring handgrading',
  408:                 haserrors        => 'Problems with errors',
  409:                 coursenormalmail => 'New '.$lctype.' messages',
  410:                 coursecritmail   => 'New critical messages in '.$lctype,
  411:     );
  412: 
  413:     if ($timediff{'versions'} == -1) {
  414:         $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since start of '.$lctype);
  415:     } elsif ($timediff{'versions'} == 2592000) {
  416:         $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last month');
  417:     } elsif ($timediff{'versions'} == 604800) {
  418:         $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last week');
  419:     } elsif ($timediff{'versions'} == 86400) {
  420:         $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since yesterday');
  421:     }
  422: 
  423:     $timediff{'oldroles'} = $display_settings{$cid.':oldroleinterval'};
  424:     unless (defined($timediff{'oldroles'})) { $timediff{'oldroles'} = 604800; }
  425:     $interval{'oldroles'} = $interval_titles->{'oldroles'}->{$timediff{'oldroles'}};
  426: 
  427:     if ($timediff{'oldroles'} == -1) {
  428:         $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since start of '.$lctype);
  429:     } elsif ($timediff{'oldroles'} == 2592000) {
  430:         $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last month');
  431:     } elsif ($timediff{'oldroles'} == 604800) {
  432:         $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last week');
  433:     } elsif ($timediff{'oldroles'} == 86400) {
  434:         $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since yesterday');
  435:     }
  436: 
  437:     $timediff{'newroles'} = $display_settings{$cid.':newroleinterval'};
  438:     unless (defined($timediff{'newroles'})) { $timediff{'newroles'} = 604800; }
  439:     $interval{'newroles'} = $interval_titles->{'newroles'}->{$timediff{'newroles'}};
  440: 
  441:     if ($timediff{'newroles'} == -1) {
  442:         $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since start of '.$lctype);
  443:     } elsif ($timediff{'newroles'} == 2592000) {
  444:         $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last month');
  445:     } elsif ($timediff{'newroles'} == 604800) {
  446:         $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last week');
  447:     } elsif ($timediff{'newroles'} == 86400) {
  448:         $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since yesterday');
  449:     }
  450: 
  451:     my $now = time;
  452:     if ($timediff{'versions'} == -1) {
  453:         $timediff{'versions'} = time;
  454:     }
  455:     my $starttime = $now - $timediff{'versions'};
  456: 
  457:     if ($timediff{'newroles'} == -1) {
  458:         $timediff{'newroles'} = time;
  459:     }
  460:     my $activatedstart = $now - $timediff{'newroles'};
  461: 
  462:     if ($timediff{'oldroles'} == -1) {
  463:         $timediff{'oldroles'} = time;
  464:     }
  465:     my $expiredstart = $now - $timediff{'oldroles'};
  466: 
  467:     my $countunread = $display_settings{$cid.':countunread'};
  468:     unless (defined($countunread)) {
  469:         $countunread = 'on';
  470:     }
  471:     if ($$checkallowed{'abovethreshold'}) {
  472:         &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
  473:     }
  474: 
  475:     $headings{'abovethreshold'} = 
  476: 	&mt('(Problems with av. attempts &ge; [_1] or deg. difficulty &ge; [_2]) [_3] and total number of '.$stulabel{$crstype}.' with submissions &ge; [_4]',
  477: 	    $threshold{'av_attempts'},$threshold{'degdiff'},
  478: 	    '<br />',$threshold{'numstudents'});
  479: 
  480:     my @actionorder;
  481:     if ($custommenu) {
  482:         @actionorder = ('coursenormalmail','coursecritmail','newroles','oldroles');
  483:     } else {
  484:         @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles');
  485:     }
  486: 
  487:     foreach my $key (keys(%{$checkallowed})) {
  488: 	if ($key =~ /_section$/) { next; }
  489:         $show{$key} = 0;
  490:         if ($$checkallowed{$key}) {
  491:             unless ($display_settings{$cid.':'.$key} eq 'hide') {
  492:                 $show{$key} = 1;
  493:             }
  494:         }
  495:     }
  496: 
  497:     foreach my $item (@actionorder) {
  498:         unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail' ||
  499:                 $item eq 'newroles' || $item eq 'oldroles') {
  500:             if ($show{$item}) {
  501:                 $needitems = 1;
  502:                 last;
  503:             }
  504:         }
  505:     }
  506: 
  507:     my $itemserror;
  508:     if ($needitems) {
  509:         $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread);
  510:     }
  511:     if ($show{'coursenormalmail'}) {
  512:         $msgcount = &getnormalmail(\@newmsgs);
  513:     }
  514:     if ($show{'coursecritmail'}) {
  515:         $critmsgcount = &getcritmail(\@critmsgs);
  516:     }
  517:     if ($show{'oldroles'}) {
  518:         $expirecount = &getexpired(\%expired,$expiredstart,'previous');
  519:     }
  520:     if ($show{'newroles'}) {
  521:         $activecount = &getactivated(\%activated,$activatedstart,'active');
  522:     }
  523:     $r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a>
  524:      &nbsp;&nbsp;<a href="javascript:changeAll('show');">$lt{'shal'}</a>
  525:      <form method="post" name="visible" action="/adm/whatsnew">\n|);
  526:     foreach my $item (keys(%{$checkallowed})) {
  527: 	if ($item =~ /_section$/) { next; }
  528:         if ($$checkallowed{$item}) {
  529:             $r->print('<input type="hidden" name="display_'.$item.'" />'."\n");
  530:         }
  531:     }
  532: 
  533:     $r->print('<input type="hidden" name="refpage" value="'.$refpage.'" /></form><table class="LC_double_column"><tr><td class="LC_left_col">');
  534: 
  535:     my $displayed = 0;
  536:     my $totalboxes = 0;
  537:     foreach my $key (keys(%{$checkallowed})) {
  538: 	if ($key =~ /_section$/) { next; }
  539: 	if ($key eq 'whatsnew' ) { next; } # whatsnew check creates no box
  540:         if ($$checkallowed{$key}) {
  541:             $totalboxes ++;
  542:         }
  543:     }
  544:     my $halfway = 4;
  545: #    my $halfway = int($totalboxes/2) + $totalboxes%2;
  546:     if ($custommenu) {
  547:         $halfway = 2;
  548:     }
  549:     foreach my $actionitem (@actionorder) {
  550:         if ($$checkallowed{$actionitem}) {
  551:             if ($displayed == $halfway) {
  552:                 $r->print('</td><td>&nbsp;</td><td class="LC_right_col" >');
  553:             }
  554:             &display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,\%interval,$countunread,\%expired,$expirecount,\%activated,$activecount,$crstype,$itemserror);
  555:             $displayed ++; 
  556:         }
  557:     }
  558:     $r->print('
  559:       </td>
  560:     </tr>
  561:    </table>
  562: ');
  563: }
  564: 
  565: #-------------------------------
  566: # display_threshold_config
  567: #
  568: # Display the threshold setting screen 
  569: #
  570: #-------------------------------
  571:                                                                                 
  572: sub display_threshold_config {
  573:     my ($r,$refpage,$threshold_titles,$cdom,$crs) = @_;
  574:     my $uname = $env{'user.name'};
  575:     my $udom = $env{'user.dom'};
  576:     my $cid = $env{'request.course.id'};
  577:     my %threshold = ();
  578:     my $rowColor1 = "#ffffff";
  579:     my $rowColor2 = "#eeeeee";
  580:     my $rowColor;
  581: 
  582:     my @thresholditems = ("av_attempts","degdiff","numstudents");
  583:     my %threshold_titles = &Apache::lonlocal::texthash(
  584:                          av_attempts => 'Average number of attempts',
  585:                          degdiff => 'Degree of difficulty',
  586:                          numstudents => 'Total number of students with submissions',
  587:                          );
  588:     &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
  589: 
  590:     $r->print('<br /><form name="thresholdform" method="post" action="/adm/whatsnew">'.
  591:               &Apache::loncommon::start_data_table().
  592:               &Apache::loncommon::start_data_table_header_row().
  593:              '<th>'.&mt('Threshold Name').'</th>'."\n".
  594:              '<th>'.&mt('Current value').'</th>'."\n".
  595:              '<th>'.&mt('Change?').'</th>'."\n".
  596:               &Apache::loncommon::end_data_table_header_row());
  597:     foreach my $type (@thresholditems) {
  598:         my $parameter = $env{'request.course.id'}.':threshold_'.$type;
  599: # onchange is javascript to automatically check the 'Set' button.
  600:         my $onchange = 'onFocus="javascript:window.document.forms'.
  601:               "['thresholdform'].elements['".$parameter."_setparmval']".
  602:               '.checked=true;"';
  603:         $r->print(&Apache::loncommon::start_data_table_row()."\n".
  604:                  '<td>'.$threshold_titles{$type}.'</td>'."\n".
  605:                  '<td>'.&Apache::lonhtmlcommon::textbox($parameter.'_value',
  606:                                             $threshold{$type},
  607:                                             10,$onchange).'</td>'."\n".
  608:                  '<td>'.
  609:                  &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
  610:                  '</td>'."\n".
  611:                  &Apache::loncommon::end_data_table_row());
  612:     }
  613:     $r->print(&Apache::loncommon::end_data_table()."\n".
  614:           '<br /><input type="submit" name="threshold" value="'.&mt('Save').'" />
  615:                  <input type="hidden" name="command" value="update" />
  616:                  <input type="hidden" name="refpage" value="'.$refpage.'" />
  617:                </form>');
  618: }
  619: 
  620: #-------------------------------
  621: # display_interval_config
  622: #
  623: # Display the interval setting screen
  624: #
  625: #-------------------------------
  626:                                                                                    
  627: sub display_interval_config {
  628:     my ($r,$refpage,$interval_titles,$context) = @_;
  629:     my $setting = 'interval';
  630:     if ($context eq 'oldroles') {
  631:         $setting = 'oldroleinterval';
  632:     } elsif ($context eq 'newroles') {
  633:         $setting = 'newroleinterval'; 
  634:     }
  635:     my $lctype = lc(&Apache::loncommon::course_type());
  636:     my $current = &get_current($env{'user.name'},$env{'user.domain'},
  637:                                 $env{'request.course.id'},$setting);
  638:     if ($context eq 'oldroles') {
  639:         $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').'<br />');
  640:     } elsif ($context eq 'newroles') {
  641:         $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').'<br />');
  642:     } else {
  643:         $r->print('<br />'.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').'<br />');
  644:     }
  645:     unless ($current eq '') {
  646:         if (ref($interval_titles->{$context}) eq 'HASH') {
  647:             $r->print(' '.&mt('Current value is "[_1]".','<b>'.
  648:                       $interval_titles->{$context}->{$current}.'</b>').'<br />');
  649:         }
  650:     }
  651:     $r->print('<br />
  652: <form method="post" name="intervalswitch" action="/adm/whatsnew">
  653: <input type="hidden" name="command" value="newinterval" />
  654: <input type="hidden" name="intervaltype" value="'.$context.'" />
  655: <input type="hidden" name="refpage" value="'.$refpage.'" />'.
  656: &mt('Display:').' 
  657: <select name="interval">
  658: <option value="" selected="selected">'.&mt('Select').'</option>
  659: ');
  660:     if (ref($interval_titles) eq 'HASH') {
  661:         if (ref($interval_titles->{$context}) eq 'HASH') {
  662:             foreach my $key (reverse sort ({$a cmp $b} (keys(%{$interval_titles->{$context}})))) {
  663:                 $r->print('<option value="'.$key.'">'.&mt($interval_titles->{$context}->{$key}).
  664:                           '</option>'."\n");
  665:             }
  666:         }
  667:     }
  668:     $r->print('</select>&nbsp;&nbsp;
  669:                <input type="submit" name="display" value="'.
  670:                &mt('Save').'" /></form>');
  671:     return;
  672: }
  673: 
  674: #----------------------------------------------
  675: # display_discussion_config
  676: #
  677: # Display the discussion display setting screen
  678: #
  679: #----------------------------------------------
  680:                                                                                   
  681: sub display_discussion_config {
  682:     my ($r,$refpage) = @_;
  683:     my $current = &get_current($env{'user.name'},$env{'user.domain'},
  684:                                 $env{'request.course.id'},'countunread');
  685:     if ($current eq '') {
  686:         $current = 'on';
  687:     }
  688:     my %opposite = ( 
  689:                       'on' => 'off',
  690:                       'off' => 'on',
  691:                     );
  692:     $r->print('<script type="text/javascript">
  693: function toggle_countunread(choice) {
  694:     if (choice == "unchanged") {
  695:         document.discussionswitch.command.value = "";
  696:     }
  697:     document.discussionswitch.submit();
  698: }
  699: </script>');
  700:     $r->print('<br />'
  701:              .&mt('Choose whether or not to display a count of the number of new posts for each resource or discussion board which has unread posts.')
  702:              .'<br />'
  703:              .&mt("This can increase the time taken to gather data for the [_1]What's New Page[_2] by a few seconds.",'<i>','</i>')
  704:              .'&nbsp;&nbsp;'
  705:              .&mt('Currently set to [_1].','<b>'.$current.'</b>.')
  706:     );
  707:     $r->print('<br /><br />
  708: <form method="post" name="discussionswitch" action="/adm/whatsnew">
  709: <input type="hidden" name="command" value="newdiscconf" />
  710: <input type="hidden" name="refpage" value="'.$refpage.'" />
  711: <input type="hidden" name="countunread" value="'.$opposite{$current}.'" />
  712: ');
  713:     $r->print('<br/>
  714:                <input type="button" name="display" value="'.
  715:                &mt('Change to [_1]',&mt($opposite{$current})).'" 
  716:                onclick="javascript:toggle_countunread('."'change'".')" />'.
  717:                ('&nbsp;' x7).
  718:                '<input type="button" name="nochange" value="'.
  719:                &mt("No change").'" 
  720:                onclick="javascript:toggle_countunread('."'unchanged'".')" />
  721:                </form>');
  722:     return;
  723: }
  724: 
  725: #---------------------------------------------------
  726: # courseinit_config
  727: #
  728: # Set page displayed when course loads after 
  729: # selecting a role in the course from the roles page. 
  730: #
  731: #---------------------------------------------------
  732: 
  733: sub courseinit_config {
  734:     my ($r,$refpage,$initpage) = @_;
  735:     my ($control,$current) = &curr_courseinit();
  736:     my @chgstate = ('userpref','coursespecific');
  737:     my @chgentry = ('firstres','whatsnew');
  738:     my $lctype = lc(&Apache::loncommon::course_type());
  739:     my %lt = &Apache::lonlocal::texthash(
  740:                              'chwp' => "Choose which page will be displayed when you enter this $lctype after selecting a role.",
  741:                              'cuva' => 'Current value is determined by',
  742:                              'anis' => 'and is set to display',
  743:                              'padc' => 'Page display controlled by',
  744:                              'chce' => 'Choose '.$lctype.' entry',
  745:                              'moce' => 'Save',
  746:     );
  747:     $r->print(<<"END"); 
  748: <br />$lt{'chwp'}
  749: <br />$lt{'cuva'}: <b>
  750: $$initpage{$control}</b> $lt{'anis'} <b>
  751: $$initpage{$current}</b>.<br /><br />
  752: <form method="post" name="courseinitswitch" action="/adm/whatsnew">
  753: <input type="hidden" name="command" value="newcourseinit" />
  754: <input type="hidden" name="refpage" value="$refpage" />
  755: $lt{'padc'}:&nbsp;&nbsp;
  756: END
  757:     foreach my $choice (@chgstate) {
  758:         my $chkstring;
  759:         if ($choice eq $control) {
  760:             $chkstring = ' checked="checked" ';
  761:         }  
  762:         $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_control" value="'.
  763:                    $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
  764:                    '&nbsp;&nbsp;</label></span>');
  765:     }
  766:     $r->print('<br /><br />'.&mt('If').' '.$$initpage{'coursespecific'}.
  767:               ' - <br />'.$lt{'chce'}.": \n");
  768:     foreach my $choice (@chgentry) {
  769:         my $chkstring;
  770:         if (($choice eq $current) && ($control eq 'coursespecific')) {
  771:             $chkstring = ' checked="checked" ';
  772:         }
  773:         $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_page" value="'.
  774:                   $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
  775:                   '&nbsp;&nbsp;</label></span>');
  776:     }
  777:     $r->print('<br /><br /><input type="submit" name="display" value="'.
  778:                $lt{'moce'}.'" /></form>');
  779:     return;
  780: }
  781: 
  782: sub curr_courseinit {
  783:     my $current = &get_current($env{'user.name'},$env{'user.domain'},
  784:                                 $env{'request.course.id'},'courseinit');
  785:     my $control;
  786:     if ($current) {
  787:         $control = 'coursespecific';
  788:     } else {
  789:         $control = 'userpref';
  790:         my %userenv = &Apache::lonnet::get('environment',
  791:                                                       ['course_init_display']);
  792:         if (exists($userenv{'course_init_display'})) {
  793:             $current = $userenv{'course_init_display'};
  794:         }
  795:         unless ($current) {
  796:             $current = 'whatsnew';
  797:         }
  798:     }
  799:     return ($control,$current);
  800: }
  801: 
  802: sub display_launcher {
  803:     my ($r,$action,$refpage,$checkallowed,$show,$headings,$res_title,
  804:         $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered,
  805:         $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs,
  806:         $interval,$countunread,$expired,$expirecount,$activated,$activecount,
  807:         $crstype,$itemserror) = @_;
  808: 
  809:     if ($$checkallowed{$action}) {
  810:         &start_box($r,$show,$headings,$action,$refpage,$action);
  811:         if ($$show{$action}) {
  812:             if ($action eq 'handgrading') {    # UNGRADED ITEMS
  813:                 &display_handgrade($r,$tograde,$ungraded,$itemserror);
  814:             } elsif ($action eq 'haserrors') { # BOMBS
  815:                 &display_haserrors($r,$bombs,$bombed,$res_title,$itemserror);
  816:             } elsif ($action eq 'versionchanges') { # VERSION CHANGES
  817:                 &display_versionchanges($r,$changed,$res_title,$interval->{'versions'},$itemserror);
  818:             } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS
  819:                 &display_abovethreshold($r,$refpage,$warnings,$triggered,
  820: 					$res_title,$itemserror);
  821:             } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
  822:                 &display_coursediscussion($r,$newdiscussions,$unread,
  823:                                 $countunread,$res_title,$itemserror);
  824:             } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES
  825:                 &display_coursenormalmail($r,$msgcount,$newmsgs);
  826:             } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES
  827:                 &display_coursecritmail($r,$critmsgcount,$critmsgs);
  828:             } elsif ($action eq 'newroles') { # ACTIVATED ROLES
  829:                 &display_rolechanges($r,$activecount,$activated,$interval->{'newroles'},
  830:                                      $crstype);
  831:             } elsif ($action eq 'oldroles') { # EXPIRED ROLES
  832:                 &display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'},
  833:                                      $crstype);
  834:             }
  835:         }
  836:         &end_box($r);
  837:     }
  838:     return;
  839: }
  840: 
  841: sub getitems {
  842:     my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions,
  843:         $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show,
  844:         $starttime,$countunread) = @_;
  845:     my $navmap = Apache::lonnavmaps::navmap->new();
  846:     if (!defined($navmap)) {
  847:         my $itemserror = '<span class="LC_warning">'.&mt('An error occurred retrieving information about the course.').'<br />'.&mt('It is recommended that you [_1]re-select the course[_2].','<a href="/adm/roles">','</a>').'</span>';
  848:         return $itemserror;
  849:     }
  850:     # force retrieve Resource to seed the part id cache we'll need it later
  851:     my @allres=$navmap->retrieveResources(undef,
  852:                      sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;});
  853:     my %resourcetracker;
  854:     my $discussiontime;
  855: 
  856: # Resource version changes
  857:     if ($$show{'versionchanges'}) {
  858:         &checkversions($cdom,$crs,$navmap,$changed,$starttime);
  859:     }
  860: 
  861:     if ($$show{'abovethreshold'}) {
  862:         %resourcetracker =  &Apache::lonnet::dump('nohist_resourcetracker',
  863:                                                                    $cdom,$crs);
  864:     }
  865: 
  866:     foreach my $resource (@allres) {
  867:         my $result = '';
  868:         my $applies = 0;
  869:         my $symb = $resource->symb();
  870:         %{$$bombed{$symb}} = ();
  871:         %{$$ungraded{$symb}} = ();
  872:         %{$$triggered{$symb}} = ();
  873:         $$triggered{$symb}{numparts} = 0;
  874:         if ($resource->encrypted()) {
  875:             $$triggered{$symb}{'enclink'} = $resource->link();
  876:             $$triggered{$symb}{'encsymb'} = $resource->shown_symb();
  877:         }
  878:         my $title = $resource->compTitle();
  879:         $$res_title{$symb} = $title;
  880:         my $ressymb = $resource->wrap_symb();
  881: 
  882: # Check if there are unread discussion postings
  883:         if ($$show{'coursediscussion'}) {
  884:             &check_discussions($resource,$symb,$ressymb,$title,
  885: 			       $newdiscussions,$unread,$countunread);
  886:         }
  887: 
  888: # Check for ungraded problems
  889:         if ($resource->is_problem()) {
  890:             if ($$show{'handgrading'}) {
  891:                 &check_handgraded($resource,$symb,$title,$cdom,$crs,$ungraded,
  892:                                                                      $tograde);
  893:             }
  894:         }
  895: 
  896: # Check for bombs
  897:         if ($$show{'haserrors'}) {
  898:             &check_bombed($resource,$symb,$title,$bombs,$bombed);
  899:         }
  900: 
  901: # Maxtries and degree of difficulty for problem parts, unless handgradeable
  902:         if ($$show{'abovethreshold'}) {  
  903:             &check_thresholds($resource,$symb,\%resourcetracker,
  904: 			      $triggered,$threshold,$warnings);
  905:         }
  906: 
  907:     }
  908:     return; 
  909: }
  910: 
  911: sub check_discussions {
  912:     my ($resource,$symb,$ressymb,$title,$newdiscussions,$unread,
  913: 	$countunread) = @_;
  914: 
  915:     if (!$resource->hasDiscussion()) { return; }
  916: 
  917:     %{$$unread{$ressymb}} = ();
  918:     $$unread{$ressymb}{'title'} = $title;
  919:     $$unread{$ressymb}{'symb'} = $symb;
  920:     if ($resource->encrypted()) {
  921:         $$unread{$ressymb}{'enclink'} = $resource->link();
  922:         $$unread{$ressymb}{'encsymb'} = $resource->shown_symb();
  923:     }
  924:     push(@{$newdiscussions}, $ressymb);
  925:     
  926:     $$unread{$ressymb}{'lastpost'} = $resource->last_post_time();
  927:     
  928:     if ($countunread eq 'on') {
  929: 	$$unread{$ressymb}{'unreadcount'} = 
  930:                             $resource->discussion_info('unread');
  931:     }
  932: }
  933: 
  934: sub check_handgraded {
  935:     my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
  936:     if ($resource->is_problem()) {
  937:         my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
  938:         my $partlist=$resource->parts();
  939:         my $handgradeable;
  940:         foreach my $part (@$partlist) {
  941:             if ($resource->handgrade($part) eq 'yes') {
  942:                 $handgradeable=1; last;
  943:             }
  944:         }
  945:         if ($handgradeable) {
  946:             my @ungraded = &Apache::bridgetask::get_queue_symb_status(
  947:                                              'gradingqueue',$symb,$cdom,$cnum);
  948:             if (@ungraded > 0) {
  949:                 $$ungraded{$symb}{count} = scalar(@ungraded);
  950:                 $$ungraded{$symb}{title} = $title;
  951:                 if ($resource->encrypted()) {
  952:                     $$ungraded{$symb}{'enclink'} = $resource->link();
  953:                     $$ungraded{$symb}{'encsymb'} = $resource->shown_symb();
  954:                 }
  955:                 push(@{$tograde},$symb);
  956:             }
  957:         }
  958:     }
  959: }
  960: 
  961: sub check_bombed {
  962:     my ($resource,$symb,$title,$bombs,$bombed) = @_;
  963:     if ($resource->getErrors()) {
  964:         my $errors = $resource->getErrors();
  965:         $errors =~ s/^,//;
  966:         my @bombs = split(/,/, $errors);
  967:         my $errorcount = scalar(@bombs);
  968:         my $errorlink = '<a href="/adm/email?display='.
  969:                         &escape($bombs[0]).'">'.
  970:                         $title.'</a>';
  971:         $$bombed{$symb}{errorcount} = $errorcount;
  972:         $$bombed{$symb}{errorlink} = $errorlink;
  973:         push(@{$bombs}, $symb);
  974:     }
  975: }
  976: 
  977: sub check_thresholds {
  978:     my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings) = @_;
  979: # Compile maxtries and degree of difficulty for problem parts, unless handgradeable
  980:     my @parts = @{$resource->parts()};
  981:     my %stats;
  982:     my %lastreset = ();
  983:     my $warning = 0;
  984:     foreach my $part (@parts) {
  985:         if ($resource->handgrade($part) eq 'yes') {
  986:             next;
  987:         }
  988:         if ($resource->is_survey($part)) {
  989:             next;
  990:         }
  991:         %{$stats{$part}} = ();
  992:         my ($attempts,$users,$corrects,$degdiff,$av_attempts);
  993:         if (exists($$resourcetracker{$symb."\0".$part."\0attempts"})) {
  994:             $attempts = $$resourcetracker{$symb."\0".$part."\0attempts"};
  995:         }
  996:         if (exists($$resourcetracker{$symb."\0".$part."\0users"})) {
  997:             $users = $$resourcetracker{$symb."\0".$part."\0users"};
  998:         }
  999:         if (exists($$resourcetracker{$symb."\0".$part."\0correct"})) {
 1000:             $corrects = $$resourcetracker{$symb."\0".$part."\0correct"};
 1001:         }
 1002:         if ($attempts > 0) {
 1003:             $degdiff =  1 - ($corrects/$attempts);
 1004:             $degdiff = sprintf("%.2f",$degdiff);
 1005:         }
 1006:         if ($users > 0) {
 1007:             $av_attempts = $attempts/$users;
 1008:             $av_attempts = sprintf("%.2f",$av_attempts);
 1009:         }
 1010:         if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
 1011:             $stats{$part}{degdiff} = $degdiff;
 1012:             $stats{$part}{attempts} = $av_attempts;
 1013:             $stats{$part}{users} = $users;
 1014:             $lastreset{$part} = $$resourcetracker{$symb."\0".$part."\0resettime"};
 1015:             if ($lastreset{$part}) {
 1016:                 $lastreset{$part} = &Apache::lonnavmaps::timeToHumanString($lastreset{$part});
 1017:             }
 1018:             $warning = 1;
 1019:         }
 1020:     }
 1021:     if ($warning) {
 1022:         $$triggered{$symb}{title} = $resource->title;
 1023:         my $partcount = 0;
 1024:         @{$$triggered{$symb}{text}} = ();
 1025:         foreach my $part (@parts) {
 1026:             if (exists($stats{$part}{users})) {
 1027:                 my $resetname = 'reset_'.&escape($symb."\0".$part);
 1028:                 my $resettitle = 'title_'.&escape($symb."\0".$part);
 1029:                 if (@parts > 1) {
 1030:                     $$triggered{$symb}{text}[$partcount] = '
 1031:                      <td>'.&mt('part - ').$part.'</td>';
 1032:                 } else {
 1033:                     $$triggered{$symb}{text}[$partcount] = '
 1034:                      <td>'.&mt('single part').'</td>';
 1035:                 }
 1036:                 $$triggered{$symb}{text}[$partcount] .= '
 1037:                      <td>'.$stats{$part}{users}.'</td>
 1038:                      <td>'.$stats{$part}{attempts}.'</td>
 1039:                      <td>'.$stats{$part}{degdiff}.'</td>
 1040:                      <td>'.$lastreset{$part}.'</td>
 1041:                      <td><input type="checkbox" name="'.$resetname.'" /><input type="hidden" name="'.$resettitle.'" value="'.&escape($$triggered{$symb}{title}).'" /></td>';
 1042:                 $partcount ++;
 1043:             }
 1044:             $$triggered{$symb}{numparts} = $partcount;
 1045:         }
 1046:         push(@{$warnings},$symb);
 1047:     }
 1048: }
 1049: 
 1050: 
 1051: sub get_curr_thresholds {
 1052:     my ($threshold,$uname,$udom,$cid,$cdom,$crs) = @_;
 1053:     # set default values
 1054:     %$threshold = (av_attempts => 2,
 1055:                   degdiff => 0.5,
 1056:                   numstudents => 2
 1057:                   );
 1058:     my %thresholdsettings = &Apache::lonnet::dump('nohist_whatsnew',$udom,
 1059:                                                      $uname,$cid.':threshold');
 1060:     my $thresholdcount = 0;
 1061:     my ($tmp) = %thresholdsettings;
 1062:     unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
 1063:         foreach my $item (keys %{$threshold}) { 
 1064:             if (exists($thresholdsettings{$cid.':threshold_'.$item})) {
 1065:                 $$threshold{$item} = 
 1066:                              $thresholdsettings{$cid.':threshold_'.$item};
 1067:                 $thresholdcount ++;
 1068:             }
 1069:         }
 1070:     }
 1071:     if ($thresholdcount == 3) {
 1072:         return;
 1073:     }
 1074:     my %coursesettings = &Apache::lonnet::dump('environment',
 1075:                                               $cdom,$crs,'internal.threshold');
 1076:     my ($temp) = %coursesettings;
 1077:     unless ($temp =~ /^(con_lost|error|no_such_host)/i) {  
 1078:         foreach my $item (keys %{$threshold}) {
 1079:             unless (exists($thresholdsettings{$cid.':threshold_'.$item})) {
 1080:                 if (exists($coursesettings{'internal.threshold_'.$item})) {
 1081:                     $$threshold{$item} = 
 1082:                              $coursesettings{'internal.threshold_'.$item};
 1083:                 }
 1084:             }
 1085:         }
 1086:     }
 1087:     return;
 1088: }
 1089: 
 1090: sub get_current {
 1091:     my ($uname,$udom,$cid,$caller) = @_;
 1092:     my $currvalue;
 1093:     my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid.
 1094:                                                                 ':'.$caller);
 1095:     my ($tmp) = %settings;
 1096:     unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
 1097:         $currvalue = $settings{$cid.':'.$caller};
 1098:     }
 1099:     return $currvalue;
 1100: }
 1101: 
 1102: sub process_reset {
 1103:     my ($dom,$crs) = @_;
 1104:     my $result = '<b>'.&mt('Counters reset for following problems (and parts):').
 1105:                            '</b><br />';
 1106:     my @agg_types = ('attempts','users','correct');
 1107:     my %agg_titles = &Apache::lonlocal::texthash (
 1108:                      attempts => 'Number of submissions',
 1109:                      users => 'Students with submissions',
 1110:                      correct => 'Number of correct submissions',
 1111:                      );
 1112:     my @resets = ();
 1113:     my %titles = ();
 1114:     foreach my $key (keys(%env)) {
 1115:         next if ($key !~ /^form\.reset_(.+)$/);
 1116:         my $title = &unescape($env{'form.title_'.$1});
 1117:         my $reset_item = &unescape($1);
 1118:         my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
 1119:         my %aggregates = ();
 1120:         my ($symb,$part) = split(/\0/,$reset_item);
 1121:         foreach my $type (@agg_types) {
 1122:             $aggregates{$reset_item."\0".$type} = 0;
 1123:         }  
 1124: 	$aggregates{$reset_item."\0".'resettime'} = time;
 1125:         my $putresult = &Apache::lonnet::put('nohist_resourcetracker',\%aggregates,
 1126:                           $dom,$crs);
 1127:         if ($putresult eq 'ok') {
 1128:             $result .= $title.' -part '.$part.': ';
 1129:             my %new_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
 1130:             foreach my $type (@agg_types) {
 1131:                 $result .= $agg_titles{$type}.' = '.$new_aggregates{$reset_item."\0".$type}.'; ';
 1132:             }
 1133:             $result =~ s/; $//;
 1134:             $result .= '<br />';
 1135:         } else {
 1136:             $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to [_1]',$putresult).'.<br />'."\n";
 1137:         }
 1138:     }
 1139:     return $result;
 1140: }
 1141: 
 1142: sub process_update {
 1143:     my ($uname,$udom,$threshold_titles) = @_;
 1144:     my $setoutput = '<b>'.&mt('Changes to threshold(s) for problem tracking:').'</b><br />';
 1145:     foreach (keys %env) {
 1146:         next if ($_!~/^form\.(.+)\_setparmval$/);
 1147:         my $name  = $1;
 1148:         my $value = $env{'form.'.$name.'_value'};
 1149:         if ($name && defined($value) && ($value ne '')) {
 1150:             my $put_result = &Apache::lonnet::put('nohist_whatsnew',
 1151:                                                   {$name=>$value},$udom,$uname);
 1152:            
 1153:             my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/);
 1154:             if ($put_result eq 'ok') {
 1155:                 $setoutput.=&mt('Set threshold for [_1] to [_2]',
 1156: 				'<b>'.$$threshold_titles{$shortname}.'</b>',
 1157: 				'<b>'.$value.'</b>').'<br />';
 1158: 	    } else {
 1159:                 $setoutput.=&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
 1160: 				'<b>'.$name.'</b>','<b>'.$value.'</b>',
 1161: 				'<tt>'.$put_result.'</tt>').'<br />';
 1162:             }
 1163:         }
 1164:     }
 1165:     return $setoutput;
 1166: }
 1167: 
 1168: sub getnormalmail {
 1169:     my ($newmsgs) = @_;
 1170: # Check for unread mail in course
 1171:     my $msgcount = 0;
 1172: 
 1173:     my @messages = sort(&Apache::lonnet::getkeys('nohist_email'));
 1174:     foreach my $message (@messages) {
 1175: 	my $msgid=&escape($message);
 1176:         my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
 1177:             &Apache::lonmsg::unpackmsgid($msgid);
 1178:         if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
 1179:             if (defined($sendtime) && $sendtime!~/error/) {
 1180:                 my $numsendtime = $sendtime;
 1181:                 if ($status eq 'new') {
 1182:                 $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
 1183: 		    $msgcount ++;
 1184:                     if ($shortsubj eq '') {
 1185:                         $shortsubj = &mt('No subject');
 1186:                     }
 1187:                     push(@{$newmsgs}, {
 1188:                         msgid    => $msgid,
 1189:                         sendtime => $sendtime,
 1190:                         shortsub => $shortsubj,
 1191:                         from     => $fromname,
 1192:                         fromdom  => $fromdom
 1193:                         });
 1194:                 }
 1195:             }
 1196:         }
 1197:     }
 1198:     return $msgcount;
 1199: }
 1200: 
 1201: sub getcritmail {
 1202:     my ($critmsgs) = @_; 
 1203: # Check for critical messages in course
 1204:     my %what=&Apache::lonnet::dump('critical');
 1205:     my $result = '';
 1206:     my $critmsgcount = 0;
 1207:     foreach my $msgid (sort(keys(%what))) {
 1208:         my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
 1209:             &Apache::lonmsg::unpackmsgid($msgid);
 1210:         if (($fromcid) && ($fromcid eq  $env{'request.course.id'})) {
 1211:             if (defined($sendtime) && $sendtime!~/error/) {
 1212:                 my $numsendtime = $sendtime;
 1213:                 $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
 1214:                 $critmsgcount ++;
 1215:                 if ($shortsubj eq '') {
 1216:                     $shortsubj = &mt('No subject');
 1217:                 }
 1218:                 push(@{$critmsgs}, {
 1219:                         msgid    => $msgid,
 1220:                         sendtime => $sendtime,
 1221:                         shortsub => $shortsubj,
 1222:                         from     => $fromname,
 1223:                         fromdom  => $fromdom
 1224:                         });
 1225:             }
 1226:         }
 1227:     }
 1228:     return $critmsgcount;
 1229: }
 1230: 
 1231: sub getexpired {
 1232:     my ($rolechgs,$rolechgtime,$status) = @_;
 1233:     my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status);
 1234:     return $expirecount;
 1235: }
 1236: 
 1237: sub getactivated {
 1238:     my ($rolechgs,$rolechgtime,$status) = @_;
 1239:     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 1240:     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
 1241:     my $now = time();
 1242:     my $context = 'course';
 1243:     my ($permission,$allowed) =
 1244:         &Apache::lonuserutils::get_permission($context);
 1245:     my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
 1246:     my %changes=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
 1247:     my (%stucounted,%advcounted);
 1248:     my $activatedcount = 0;
 1249:     if (keys(%changes) > 0) {
 1250:         foreach my $chg (sort { $b <=> $a } (keys(%changes))) {
 1251:             if (ref($changes{$chg}) eq 'HASH') {
 1252:                 my $timestamp = $changes{$chg}{'exe_time'};
 1253:                 if ($timestamp) {
 1254:                     if ($rolechgtime > 0) {
 1255:                         if ($timestamp < $rolechgtime) {
 1256:                             last;
 1257:                         }
 1258:                     }
 1259:                     if (ref($changes{$chg}{'logentry'}) eq 'HASH') {
 1260:                         next if ($changes{$chg}{'delflag'});
 1261:                         my $start = $changes{$chg}{'logentry'}{'start'};
 1262:                         my $end = $changes{$chg}{'logentry'}{'end'};
 1263:                         my $section = $changes{$chg}{'logentry'}{'section'};
 1264:                         my $role = $changes{$chg}{'logentry'}{'role'};
 1265:                         my $uname = $changes{$chg}{'uname'};
 1266:                         my $udom = $changes{$chg}{'udom'};
 1267:                         next if ($end && $end <= $now);
 1268:                         if (($viewablesec ne '') && ($section ne '')) {
 1269:                             next if ($viewablesec ne $section);
 1270:                         }
 1271:                         next if ($start >= $timestamp);
 1272:                         if ($role eq 'st') {
 1273:                             $stucounted{$uname.':'.$udom.':'.$section} = $start.':'.$end;
 1274:                         } else {
 1275:                             $advcounted{$uname.':'.$udom.':'.$role.':'.$section} = $start.':'.$end;
 1276:                         }
 1277:                         my %chginfo = (
 1278:                                        'section' => $section,
 1279:                                        'uname'   => $uname,
 1280:                                        'udom'    => $udom,
 1281:                                        'role'    => $role,
 1282:                                        'status'  => $status,
 1283:                         );
 1284:                         $activatedcount ++;
 1285:                         push (@{$rolechgs->{$timestamp}},\%chginfo);
 1286:                     }
 1287:                 }
 1288:             }
 1289:         }
 1290:     }
 1291:     $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,\%stucounted,\%advcounted);
 1292:     return $activatedcount;
 1293: }
 1294: 
 1295: sub getrolechanges {
 1296:     my ($rolechgs,$rolechgtime,$status,$stucountref,$advcountref) = @_;
 1297:     my (%stucounted,%advcounted);
 1298:     if (ref($stucountref) eq 'HASH') {
 1299:         %stucounted = %{$stucountref};
 1300:     }
 1301:     if (ref($advcountref) eq 'HASH') {
 1302:         %advcounted = %{$advcountref};
 1303:     }
 1304:     my $withsec = 1;
 1305:     my $hidepriv = 1;
 1306:     my $context = 'course';
 1307:     my @statuses = ($status);
 1308:     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 1309:     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
 1310:     my $now = time();
 1311:     my ($permission,$allowed) =
 1312:         &Apache::lonuserutils::get_permission($context);
 1313:     my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
 1314:     my $classlist = &Apache::loncoursedata::get_classlist();
 1315:     my $secidx = &Apache::loncoursedata::CL_SECTION();
 1316:     my $startidx = &Apache::loncoursedata::CL_START();
 1317:     my $endidx = &Apache::loncoursedata::CL_END();
 1318:     my $rolechgcount = 0;
 1319:     foreach my $key (keys(%{$classlist})) {
 1320:         my ($userstatus,$eventtime);   
 1321:         my $student = $classlist->{$key};
 1322:         if (ref($student) eq 'ARRAY') {
 1323:             my $start = $student->[$startidx];
 1324:             my $end = $student->[$endidx];
 1325:             my $sec = $student->[$secidx]; 
 1326:             my ($stuname,$studom) = split(/:/,$key);
 1327:             if ($status eq 'active') {
 1328:                 if (exists($stucounted{$key.':'.$sec})) {
 1329:                     next;
 1330:                 }
 1331:             }
 1332:             if (($end == 0) || ($end > $start)) {
 1333:                 if ($start <= $now) {
 1334:                     if ($end && $end < $now) {
 1335:                         if ($rolechgtime > 0) {
 1336:                             if ($end > $rolechgtime) {
 1337:                                 $userstatus = 'previous';
 1338:                             }
 1339:                         } else {
 1340:                             $userstatus = 'previous';
 1341:                         }
 1342:                     } else {
 1343:                         if ($rolechgtime > 0) {
 1344:                             if ($start >= $rolechgtime) {
 1345:                                 $userstatus = 'active';
 1346:                             }
 1347:                         } else {
 1348:                             $userstatus = 'active';
 1349:                         }
 1350:                     }
 1351:                 }
 1352:             }
 1353:             next if ($userstatus ne $status);
 1354:             if ($status eq 'active') {
 1355:                 $eventtime = $start;
 1356:             } else {
 1357:                 $eventtime = $end;
 1358:             }
 1359:             if (($viewablesec ne '') && ($sec ne '')) {
 1360:                 next if ($viewablesec ne $sec);
 1361:             }
 1362:             my %chginfo = (
 1363:                             'section' => $sec,
 1364:                             'uname'   => $stuname,
 1365:                             'udom'    => $studom,
 1366:                             'role'    => 'st', 
 1367:                             'status'  => $userstatus,
 1368:                           );
 1369:             $rolechgcount ++;
 1370:             push (@{$rolechgs->{$eventtime}},\%chginfo);
 1371:         }
 1372:     }
 1373:     my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
 1374:                               \@statuses,undef,undef,$withsec,$hidepriv);
 1375:     foreach my $item (keys(%advrolehash)) {
 1376:         my ($userstatus,$eventtime);
 1377:         my ($uname,$udom,$role,$section) = split(/:/,$item,-1);
 1378:         my ($start,$end) = split(/:/,$advrolehash{$item});
 1379:         if ($start eq '-1' && $end eq '-1') {
 1380:             next;
 1381:         } else {
 1382:             if ($status eq 'active') {
 1383:                 if (exists($advcounted{$item})) {
 1384:                     next;
 1385:                 }
 1386:             }
 1387:             if (($end == 0) || ($end > $start)) {
 1388:                 if ($start <= $now) {
 1389:                     if ($end && $end < $now) {
 1390:                         if ($rolechgtime > 0) {
 1391:                             if ($end > $rolechgtime) {
 1392:                                 $userstatus = 'previous';
 1393:                             }
 1394:                         } else {
 1395:                             $userstatus = 'previous';
 1396:                         }
 1397:                     } else {
 1398:                         if ($rolechgtime > 0) {
 1399:                             if ($start >= $rolechgtime) {
 1400:                                 $userstatus = 'active';
 1401:                             }
 1402:                         } else {
 1403:                             $userstatus = 'active';
 1404:                         }
 1405:                     }
 1406:                 }
 1407:             }
 1408:             next if ($userstatus ne $status);
 1409:             if ($status eq 'active') {
 1410:                 $eventtime = $start;
 1411:             } else {
 1412:                 $eventtime = $end;
 1413:             }
 1414:         }
 1415:         if (($viewablesec ne '') && ($section ne '')) {
 1416:             next if ($viewablesec ne $section);
 1417:         }
 1418:         my %chginfo = ( 
 1419:                         'section' => $section,
 1420:                         'uname'   => $uname,
 1421:                         'udom'    => $udom,
 1422:                         'role'    => $role,
 1423:                         'status'  => $userstatus,    
 1424:                       );
 1425:         $rolechgcount ++; 
 1426:         push (@{$rolechgs->{$eventtime}},\%chginfo); 
 1427:     }
 1428:     return $rolechgcount;
 1429: }
 1430: 
 1431: sub checkversions {
 1432:     my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
 1433:     my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
 1434:     my ($tmp) = keys(%changes);
 1435:     unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
 1436:         if (keys(%changes) > 0) {
 1437:             foreach my $key (sort(keys(%changes))) {
 1438:                 if ($changes{$key} > $starttime) {
 1439:                     my $version;
 1440:                     my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
 1441:                     my $currentversion=&Apache::lonnet::getversion($key);
 1442:                     my $revdate = 
 1443:                           &Apache::lonnet::metadata($root.'.'.$extension,
 1444:                                                      'lastrevisiondate');
 1445:                     $revdate =  &Apache::lonlocal::locallocaltime($revdate);
 1446:                     my $linkurl=&Apache::lonnet::clutter($key);
 1447:                     my $usedversion=$navmap->usedVersion('version_'.$linkurl);
 1448:                     my @resources = $navmap->getResourceByUrl($linkurl,1);
 1449:                     if (($usedversion) && ($usedversion ne 'mostrecent')) {
 1450:                         $version = $usedversion;     
 1451:                     } else {
 1452:                         $version = $currentversion;
 1453:                     }
 1454:                     foreach my $res (@resources) {
 1455:                          if (ref($res) eq 'Apache::lonnavmaps::resource') { 
 1456:                             my $symb = $res->symb();
 1457:                             %{$$changed{$symb}} = (
 1458:                                                 current => $currentversion,
 1459:                                                 version => $version,
 1460:                                                 revdate => $revdate,
 1461:                             );
 1462:                         }
 1463:                     }
 1464:                 }
 1465:             }
 1466:         }
 1467:     }
 1468:     return;
 1469: }
 1470: 
 1471: sub display_handgrade {
 1472:     my ($r,$tograde,$ungraded,$itemserror) = @_;
 1473:     my %lt = &Apache::lonlocal::texthash(
 1474:                         'prna' => 'Problem Name',
 1475:                         'nmun' => 'Number ungraded',
 1476:                         'nopr' => 'No problems require handgrading',
 1477:     );
 1478:     if (@{$tograde} > 0) {
 1479:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 1480:                   $lt{'prna'}.'</td><td class="LC_right_item">'.
 1481:                   $lt{'nmun'}.'</td></tr>');
 1482:         my $rowNum = 0;
 1483:         foreach my $res (@{$tograde}) {
 1484:             $rowNum ++;
 1485:             my $css_class = $rowNum%2?' class="LC_odd_row"':'';
 1486:             my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
 1487:             my $linkurl=&Apache::lonnet::clutter($url);
 1488:             $linkurl .= '?symb='.&escape($res);
 1489:             if ($$ungraded{$res}{'enclink'}) {
 1490:                 $linkurl = 
 1491:                     $$ungraded{$res}{'enclink'}.'?symb='.$$ungraded{$res}{'encsymb'};
 1492:             } 
 1493:             $r->print('<tr'.$css_class.'><td><a href="'.$linkurl.'">'.$$ungraded{$res}{title}.'</a></td><td class="LC_right_item">'.$$ungraded{$res}{count}.'</td></tr>');
 1494:         }
 1495:     } elsif ($itemserror) {
 1496:         $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
 1497:     } else {
 1498:         $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
 1499:     }
 1500: }
 1501: 
 1502: sub display_haserrors {
 1503:     my ($r,$bombs,$bombed,$res_title,$itemserror) = @_;
 1504:     my $bombnum = 0;
 1505:     my %lt = &Apache::lonlocal::texthash(
 1506:                                    reso => 'Resource',
 1507:                                    nmer => 'Number of errors',
 1508:                                    noer => 'No problems with errors',
 1509:     );
 1510:     if (@{$bombs} > 0) {
 1511:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 1512:                   $lt{'reso'}.'</td><td class="LC_right_item">'.
 1513:                   $lt{'nmer'}.'</td></tr>');
 1514:         @{$bombs} = sort { &cmp_title($a,$b,$res_title) } @{$bombs};
 1515:         foreach my $bomb (@{$bombs}) {
 1516:             $bombnum ++;
 1517:             my $css_class = $bombnum%2?' class="LC_odd_row"':'';
 1518:             $r->print('<tr'.$css_class.'><td>'.$$bombed{$bomb}{errorlink}.
 1519:                       '</td><td class="LC_right_item">'.
 1520:                       $$bombed{$bomb}{errorcount}.'</td></tr>');
 1521:         }
 1522:     } elsif ($itemserror) {
 1523:         $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
 1524:     } else {
 1525:         $r->print('<tr class="LC_empty_row"><td>'.$lt{'noer'}.'</td></tr>');
 1526:     }
 1527:     return;
 1528: }
 1529: 
 1530: sub display_abovethreshold {
 1531:     my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror) = @_;
 1532:     my %lt = &Apache::lonlocal::texthash(
 1533:                  reso => 'Resource',
 1534:                  part => 'Part',
 1535:                  nust => 'Num. students',
 1536:                  avat => 'Av. Attempts',
 1537:                  dedi => 'Deg. Diff',
 1538:                  lare => 'Last Reset',
 1539:                  reco => 'Reset Count?',
 1540:                  rese => 'Reset counters to 0',
 1541:                  nopr => 'No problems satisfy threshold criteria',
 1542:     );
 1543:     if (@{$warnings} > 0) {
 1544:         @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
 1545:         $r->print('<form name="reset_tracking" method="post" action="/adm/whatsnew">'.
 1546:                 ' <input type="hidden" name="command" value="reset" />'."\n".
 1547:                 ' <input type="hidden" name="refpage" value="'.$refpage.'" />'.
 1548:                 "\n");
 1549:         $r->print('<tr class="LC_info_row">'.
 1550: 		  '<td class="LC_left_item">'.$lt{'reso'}.'</td>'.
 1551: 		  '<td>'.$lt{'part'}.'</td><td>'.$lt{'nust'}.'</td>'.
 1552: 		  '<td>'.$lt{'avat'}.'</td><td>'.$lt{'dedi'}.'</td>'.
 1553: 		  '<td>'.$lt{'lare'}.'</td><td  class="LC_right_item">'.
 1554:                   $lt{'reco'}.'</td></tr>');
 1555: 	my $row;
 1556:         foreach my $res (@{$warnings}) {
 1557: 	    $row++;
 1558:             my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
 1559:             my $linkurl=&Apache::lonnet::clutter($url);
 1560:             my $rowspan;
 1561:             if ($$triggered{$res}{numparts} > 1) {
 1562:                 $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
 1563:             }
 1564:             $linkurl .= '?symb='.&escape($res);
 1565:             if ($$triggered{$res}{'enclink'}) {
 1566:                 $linkurl = 
 1567:                   $$triggered{$res}{'enclink'}.'?symb='.$$triggered{$res}{'encsymb'};
 1568:             }
 1569:             my $css_class = $row%2?' class="LC_odd_row"':'';
 1570:             $r->print('<tr'.$css_class.'>'.
 1571: 		      '<td class="LC_first_item" '.$rowspan.'><a href="'.$linkurl.'">'.
 1572: 		      $$triggered{$res}{title}.'</a></td>');
 1573:                       if (ref($$triggered{$res}{text}) eq 'ARRAY') {
 1574: 		          $r->print($$triggered{$res}{text}[0]);
 1575:                       }
 1576:                       $r->print('</tr>');
 1577:             if (ref($$triggered{$res}{text}) eq 'ARRAY') {
 1578:                 if (@{$$triggered{$res}{text}} > 1) {
 1579:                     for (my $i=1; $i<@{$$triggered{$res}{text}}; $i++) {
 1580:                         $r->print('<tr class="'.$css_class.'">'.
 1581:                                   $$triggered{$res}{text}[$i].'</tr>');
 1582:                     }
 1583:                 }
 1584:             }
 1585:         }
 1586:         $r->print('<tr class="LC_info_row"><td colspan="7" class="LC_right_item"><br /><input type="submit" name="counters" value="'.$lt{'rese'}.'" /></td></tr></form>');
 1587:     } elsif ($itemserror) {
 1588:         $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
 1589:     } else {
 1590:         $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
 1591:     }
 1592: }
 1593: 
 1594: sub display_versionchanges {
 1595:     my ($r,$changed,$res_title,$interval,$itemserror) = @_;
 1596:     my %lt = &Apache::lonlocal::texthash(
 1597:         'reso' => 'Resource',
 1598:         'revd' => 'Last revised',
 1599:         'newv' => 'New version',
 1600:         'veru' => 'Version used',
 1601:     );
 1602:     if (keys(%{$changed}) > 0) {
 1603:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 1604:                   $lt{'reso'}.'</td><td>'.$lt{'revd'}.'</td><td>'.
 1605:                   $lt{'newv'}.'</td><td class="LC_right_item">'.
 1606:                   $lt{'veru'}.'</td></tr>');
 1607:         my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
 1608:         my $changenum = 0;
 1609:         foreach my $item (@changes) {
 1610:             $changenum ++;
 1611:             my $css_class = $changenum%2?' class="LC_odd_row"':'';
 1612:             my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
 1613:             my $linkurl=&Apache::lonnet::clutter($url);
 1614:             $linkurl .= '?symb='.&escape($item);
 1615: 
 1616:             $r->print('<tr'.$css_class.'><td><a href="'.$linkurl.'">'.
 1617:                       $$res_title{$item}.'</a></td><td>'.
 1618:                       $$changed{$item}{'revdate'}.'</td><td>'.
 1619:                       $$changed{$item}{'current'}.'</td><td>'.
 1620:                       $$changed{$item}{'version'}.'</td></tr>');
 1621:         }
 1622:     } elsif ($itemserror) {
 1623:         $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
 1624:     } else {
 1625:         $r->print('<tr class="LC_empty_row"><td>'
 1626:                  .&mt('No '.$interval).'</td></tr>');
 1627:     }
 1628:     return;
 1629: }
 1630: 
 1631: sub display_rolechanges {
 1632:     my ($r,$chgcount,$changed,$interval,$crstype) = @_;
 1633:     my $now = time();
 1634:     my %lt = &Apache::lonlocal::texthash(
 1635:         'user'  => 'User',
 1636:         'tich'  => 'Time of change',
 1637:         'role'  => 'Role',
 1638:         'sec'   => 'Section',
 1639:         'status'  => 'Status',
 1640:     );
 1641:     if ($chgcount) {
 1642:         $r->print('<tr class="LC_info_row">'.
 1643:                   '<td class="LC_left_item">'.$lt{'tich'}.'</td>'.
 1644:                   '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
 1645:                   '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
 1646:                   '<td class="LC_left_item">'.$lt{'sec'}.'</td>'.
 1647:                   '<td class="LC_left_item">'.$lt{'status'}.'</td></tr>');
 1648:         if (ref($changed) eq 'HASH') {
 1649:             my @changes = sort { $b <=> $a } (keys(%{$changed}));
 1650:             my $changenum = 0;
 1651:             foreach my $item (@changes) {
 1652:                 if (ref($changed->{$item}) eq 'ARRAY') {
 1653:                     foreach my $chg (@{$changed->{$item}}) {
 1654:                         if (ref($chg) eq 'HASH') {
 1655:                             my $section;
 1656:                             my $role = 
 1657:                                 &Apache::lonnet::plaintext($chg->{'role'},$crstype);
 1658:                             my $status = &mt($chg->{'status'});
 1659:                             if ($chg->{'section'} eq '') {
 1660:                                 $section = &mt('none');
 1661:                             } else {
 1662:                                 $section = $chg->{'section'};
 1663:                             }
 1664:                             my $uname = $chg->{'uname'};
 1665:                             my $udom = $chg->{'udom'};
 1666:                             $changenum ++;
 1667:                             my $css_class = $changenum%2?' class="LC_odd_row"':'';
 1668:                             my $link = 
 1669:                                 &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom);
 1670:                             $r->print('<tr'.$css_class.'>'.
 1671:                                       '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'.
 1672:                                       '<td>'.$link.'</td>'.
 1673:                                       '<td>'.$role.'</td>'.
 1674:                                       '<td>'.$section.'</td>'.
 1675:                                       '<td>'.$status.'</td></tr>');
 1676:                         }
 1677:                     }
 1678:                 }
 1679:             }
 1680:         }
 1681:     } else {
 1682:         $r->print('<tr class="LC_empty_row"><td>'
 1683:                  .&mt('There are no '.$interval).'</td></tr>');
 1684:     }
 1685:     return;
 1686: }
 1687:  
 1688: sub display_coursediscussion {
 1689:     my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_;
 1690:     my $lctype = lc(&Apache::loncommon::course_type());
 1691:     my %lt = &Apache::lonlocal::texthash(
 1692:                 'loca' => 'Location',
 1693:                 'type' => 'Type',
 1694:                 'numn' => 'Number of new posts',
 1695:                 'noun' => 'No unread posts in '.$lctype.' discussions',
 1696:                 'tmlp' => 'Time of last post', 
 1697:     );
 1698:     if (@{$newdiscussions} > 0) {
 1699:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 1700:                   $lt{'loca'}.'</td><td>'.
 1701:                   $lt{'type'}.'</td>');
 1702:         if ($countunread eq 'on') {
 1703:             $r->print('<td>'.$lt{'tmlp'}.'</td>'.
 1704:                       '<td class="LC_right_item">'.$lt{'numn'}.'</td>');
 1705:         } else {
 1706:             $r->print('<td class="LC_right_item">'.$lt{'tmlp'}.'</td>');
 1707:         }
 1708:         $r->print("</tr>\n");
 1709:         @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
 1710:                                                             @{$newdiscussions};
 1711:         my $rowNum = 0;
 1712:         foreach my $ressymb (@{$newdiscussions}) {
 1713:             $rowNum ++;
 1714:             my $forum_title = $$unread{$ressymb}{'title'};
 1715:             my $type = 'Resource';
 1716:             my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
 1717:             my $disclink = $feedurl.'?symb='.$$unread{$ressymb}{symb};
 1718:             if ($feedurl =~ /bulletinboard/) {
 1719:                 $type = 'Discussion Board';
 1720:             }
 1721:             if ($$unread{$ressymb}{'enclink'}) {
 1722:                 $disclink = $$unread{$ressymb}{'enclink'}.'?symb='.$$unread{$ressymb}{'encsymb'};
 1723:             }
 1724:             my $css_class = $rowNum%2?' class="LC_odd_row"':'';
 1725:             my $lastpost = &Apache::lonnavmaps::timeToHumanString(
 1726:                                                $$unread{$ressymb}{'lastpost'});
 1727:             $r->print('<tr'.$css_class.'><td><a href="'.$disclink.'">'.$forum_title.'</a>&nbsp;</td><td>'.&mt($type).'&nbsp;</td>');
 1728:             if ($countunread eq 'on') {
 1729:                 my $unreadnum = $$unread{$ressymb}{'unreadcount'};
 1730:                 $r->print('<td>'.$lastpost.'</td><td class="LC_right_item">'.
 1731:                           $unreadnum.'&nbsp;</td>');
 1732:             } else {
 1733:                 $r->print('<td class="LC_right_item">'.$lastpost.'</td>');
 1734:             }
 1735:             $r->print("</tr>\n");
 1736:         }
 1737:     } elsif ($itemserror) {
 1738:         $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
 1739:     } else {
 1740:         $r->print('<tr class="LC_empty_row"><td>'.$lt{'noun'}.'</td></tr>');
 1741:     }
 1742: }
 1743: 
 1744: sub display_coursenormalmail {
 1745:     my ($r,$msgcount,$newmsgs) = @_;
 1746:     my $lctype = lc(&Apache::loncommon::course_type());
 1747:     if ($msgcount > 0) {
 1748:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 1749:                   &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
 1750:                   &mt('Sender').'</td><td class="LC_right_item">'.
 1751:                   &mt('Date/Time').'</td></tr>');
 1752:         my $mailcount = 0;
 1753:         foreach my $msg (@{$newmsgs}) {
 1754:             $mailcount ++;
 1755:             my $css_class = $mailcount%2?' class="LC_odd_row"':'';
 1756:             $r->print('<tr'.$css_class.'><td>'.$mailcount
 1757:                       .'.&nbsp;</td><td><a href="/adm/email?display='
 1758:                       .$msg->{'msgid'}.'">'
 1759:                       .$msg->{'shortsub'}.'</a>&nbsp;&nbsp;</td><td>&nbsp;'
 1760:                       .$msg->{'from'}.':'.$msg->{'fromdom'}.'&nbsp;</td><td>'
 1761:                       .$msg->{'sendtime'}.'</td></tr>');
 1762:         }
 1763:     } else {
 1764:         $r->print('<tr class="LC_empty_row"><td>'.
 1765:                   &mt('No new '.$lctype.' messages').'</td></tr>');
 1766:     }
 1767: }
 1768: 
 1769: sub display_coursecritmail {
 1770:     my ($r,$critmsgcount,$critmsgs) = @_;
 1771:     my $lctype = lc(&Apache::loncommon::course_type());
 1772:     if ($critmsgcount > 0) {
 1773:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 1774:                   &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
 1775:                   &mt('Sender').'</td><td class="LC_right_item">'.
 1776:                   &mt('Date/Time').'</td></tr>');
 1777:         my $mailcount = 0;
 1778:         foreach my $msg (@{$critmsgs}) {
 1779:             $mailcount ++;
 1780:             my $css_class = $mailcount%2?' class="LC_odd_row"':'';
 1781:             $r->print('<tr'.$css_class.'><td>'.$mailcount.
 1782:                       '. &nbsp;</td><td><a href="/adm/email?folder=critical">'.
 1783:                       $msg->{'shortsub'}.'</a>&nbsp; &nbsp;</td><td>&nbsp;'.
 1784:                       $msg->{'from'}.':'.$msg->{'fromdom'}.'&nbsp;</td><td>'.
 1785:                       $msg->{'sendtime'}.'</td></tr>');
 1786:         }
 1787:     } else {
 1788:         $r->print('<tr class="LC_empty_row"><td>'.
 1789:                   &mt('No unread critical messages in '.$lctype).
 1790:                   '</td></tr>');
 1791:     }
 1792: }
 1793: 
 1794: sub cmp_title {
 1795:     my ($a,$b,$res_title) = @_;
 1796:     my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
 1797:     $atitle=~s/^\s*//;
 1798:     $btitle=~s/^\s*//;
 1799:     return $atitle cmp $btitle;
 1800: }
 1801: 
 1802: sub get_display_settings {
 1803:     my ($uname,$udom,$cid) = @_;
 1804:     my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid); 
 1805:     my ($tmp) = keys(%settings);
 1806:     if ($tmp=~ /^(con_lost|error|no_such_host)/i) {
 1807:         %settings = ();
 1808:         unless ($tmp =~ /^error: 2 /) {
 1809: 	    my $lctype = lc(&Apache::loncommon::course_type());
 1810:             &Apache::lonnet::logthis('Error retrieving whatsnew settings: '.
 1811:             $tmp.' for '.$uname.':'.$udom.' for '.$lctype.': '.$cid);
 1812:         }
 1813:     }
 1814:     return %settings;
 1815: }
 1816: 
 1817: sub store_display_settings {
 1818:     my ($uname,$udom,$cid,$checkallowed) = @_;
 1819:     my %whatsnew_settings;
 1820:     my $result;
 1821:     foreach my $key (keys(%{$checkallowed})) {
 1822: 	if ($key =~ /_section$/) { next; }
 1823:         if (exists($env{'form.display_'.$key})) {
 1824:             unless ($env{'form.display_'.$key} eq '') {
 1825:                 $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
 1826:             }
 1827:         }
 1828:     }
 1829:     if (keys(%whatsnew_settings)) {
 1830:         $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
 1831:                                                                  $udom,$uname);
 1832:     } else {
 1833:         $result = 'ok';
 1834:     }
 1835:     return $result;
 1836: }
 1837: 
 1838: sub store_interval_setting {
 1839:     my ($uname,$udom,$cid,$interval_titles) = @_;
 1840:     my %interval_settings = ();
 1841:     my $result;
 1842:     my $context = $env{'form.intervaltype'};
 1843:     if ($env{'form.interval'} ne '') {
 1844:         if ($context eq 'oldroles') {
 1845:             $interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'};
 1846:         } elsif ($context eq 'newroles') {
 1847:             $interval_settings{$cid.':newroleinterval'} = $env{'form.interval'};
 1848:         } else {
 1849:             $interval_settings{$cid.':interval'} = $env{'form.interval'};
 1850:         }
 1851:         my $outcome = &Apache::lonnet::put('nohist_whatsnew',
 1852:                                              \%interval_settings,$udom,$uname);
 1853:         if ($outcome eq 'ok') {
 1854:             if (ref($interval_titles->{$context}) eq 'HASH') {
 1855:                 $result = &mt('New filter setting: [_1].','<b>'. 
 1856:                               $interval_titles->{$context}->{$env{'form.interval'}}.'</b>').'<br />';
 1857:             }
 1858:         } else {
 1859: 	    my $lctype = lc(&Apache::loncommon::course_type());
 1860:             &Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'.
 1861:                 ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
 1862:             $result = &mt('Unable to set interval to [_1] due to [_2].',
 1863:                          '<b>'.$interval_titles->{$context}->{$env{'form.interval'}}.'</b>',
 1864:                          '<tt>'.$outcome.'</tt>.<br />');
 1865:         }
 1866:     }
 1867:     return $result;
 1868: }
 1869: 
 1870: sub store_discussion_setting {
 1871:     my ($uname,$udom,$cid) = @_;
 1872:     my %discussion_settings;
 1873:     my $result;
 1874:     if (defined($env{'form.countunread'})) {
 1875:         $discussion_settings{$cid.':countunread'} = $env{'form.countunread'};
 1876:         my $outcome = &Apache::lonnet::put('nohist_whatsnew',
 1877:                                              \%discussion_settings,$udom,$uname);
 1878:         if ($outcome eq 'ok') {
 1879:             $result = &mt('Count unread posts in discussions display set to [_1]',
 1880:                   '<b>'.&mt($env{'form.countunread'}).'</b>').'<br />';
 1881:                                                                                   
 1882:         } else {
 1883: 	    my $lctype = lc(&Apache::loncommon::course_type());
 1884:             &Apache::lonnet::logthis('Error saving whatsnew countunread setting'.
 1885:                 ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
 1886:             $result = &mt('Unable to set "number unread posts display" to [_1]'.
 1887:                           ' due to [_2].',
 1888:                          '<b>'.&mt($env{'form.countunread'}).'</b>',
 1889:                          '<tt>'.$outcome.'</tt>.<br />');
 1890:         }
 1891:     }
 1892:     return $result;
 1893: }
 1894: 
 1895: sub store_courseinit_setting {
 1896:     my ($uname,$udom,$cid,$initpage) = @_;
 1897:     my %courseinit_settings;
 1898:     my $page_control;
 1899:     my $result;
 1900:     if (defined($env{'form.courseinit_control'})) {
 1901:         if ($env{'form.courseinit_control'} eq 'userpref') {
 1902:             $courseinit_settings{$cid.':courseinit'} = '';
 1903:             $page_control = 'global preferences';
 1904:         } else {
 1905:             if (defined($env{'form.courseinit_page'})) {
 1906:                 $courseinit_settings{$cid.':courseinit'} = 
 1907:                                                   $env{'form.courseinit_page'};
 1908:                 $page_control = 'course specific setting';
 1909:             }
 1910:         }
 1911:         if ($page_control) {
 1912: 	    my $lctype = lc(&Apache::loncommon::course_type());
 1913:             my $outcome = &Apache::lonnet::put('nohist_whatsnew',
 1914:                                            \%courseinit_settings,$udom,$uname);
 1915:             if ($outcome eq 'ok') {
 1916:                 if ($page_control eq 'global preferences') {
 1917:                     $result = &mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'<b>','</b>');
 1918:                 } else {
 1919:                     $result = &mt('Page displayed after role selection in this '.$lctype.' set to [_1].'
 1920:                                  ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>');
 1921:                 }
 1922:             } else {
 1923:                 &Apache::lonnet::logthis('Error saving whatsnew courseinit '.
 1924:                                          'setting: '.$outcome.' for '.$uname.
 1925:                                          ':'.$udom.' in '.$lctype.' '.$cid);
 1926:                 if ($page_control eq 'global preferences') {
 1927:                     $result = &mt('Unable to set control of page display to [_1]'.
 1928:                           ' due to [_2].',
 1929:                          '<b>'.$page_control.'</b>',
 1930:                          '<tt>'.$outcome.'</tt>.<br />');
 1931:                 } else {
 1932:                     $result = &mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].'
 1933:                                  ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'
 1934:                                  ,'<tt>'.$outcome.'</tt>')
 1935:                              .'<br />';
 1936:                 }
 1937:             }
 1938:         }
 1939:     }
 1940:     return $result;
 1941: }
 1942: 
 1943: sub start_box {
 1944:     my ($r,$show,$heading,$caller,$refpage) = @_;
 1945:     my %lt = &Apache::lonlocal::texthash( 
 1946:                        chth => 'Change thresholds?',
 1947:                        chin => 'Change interval?',
 1948:                        chop => 'Change options?',
 1949:     );
 1950:     my $showhide;
 1951:     if ($$show{$caller}) {
 1952:         $showhide = '<b><a href="javascript:change_display(document.visible.'.
 1953:                                'display_'.$caller.",'hide'".');">'.
 1954:                                &mt('Hide').'</a></b>';
 1955:    
 1956:     } else {
 1957:         $showhide = '<b><a href="javascript:change_display(document.visible.'.
 1958:                                'display_'.$caller.",'show'".');">'.
 1959:                                &mt('Show').'</a></b>';
 1960:     }
 1961:     
 1962:     $r->print('
 1963:          <table class="LC_nested_outer">
 1964:           <tr>
 1965:            <th class="LC_left_item">'.$$heading{$caller}.'</th>
 1966:            <th class="LC_right_item">'.$showhide.'</th>
 1967:           </tr>');
 1968:      if (($caller eq 'abovethreshold') && ($$show{$caller})) {
 1969:          if ($$show{$caller}) {
 1970:              $r->print('
 1971:               <tr>
 1972:                 <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgthreshold&amp;refpage='.$refpage.'">'.$lt{'chth'}.'</a></td>
 1973:               </tr>');
 1974:          }
 1975:      } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
 1976:          if ($$show{$caller}) {
 1977:              $r->print('
 1978:               <tr>
 1979:                 <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chginterval&amp;refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
 1980:               </tr>');
 1981:          }
 1982:      } elsif ($caller eq 'coursediscussion') {
 1983:          if ($$show{$caller}) {
 1984:              $r->print('
 1985:               <tr>
 1986:                 <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgdisc&amp;refpage='.$refpage.'">'.$lt{'chop'}.'</a></td>
 1987:               </tr>');
 1988:          }
 1989:      } elsif (($caller eq 'newroles') && ($$show{$caller})) {
 1990:          if ($$show{$caller}) {
 1991:              $r->print('
 1992:               <tr>
 1993:                 <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgnewroleinterval&amp;refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
 1994:               </tr>');
 1995:          }
 1996:      } elsif (($caller eq 'oldroles') && ($$show{$caller})) {
 1997:          if ($$show{$caller}) {
 1998:              $r->print('
 1999:               <tr>
 2000:                 <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&amp;refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
 2001:               </tr>');
 2002:          }
 2003:      }
 2004:     $r->print('
 2005:               <tr>
 2006:                <td colspan="2">
 2007:                 <table class="LC_nested">
 2008: ');
 2009:     return;
 2010: }
 2011: 
 2012: sub end_box {
 2013:     my ($r) = shift;
 2014:     $r->print('
 2015:    </table>
 2016:   </td>
 2017:  </tr>
 2018: </table><br />');
 2019:     return;
 2020: }
 2021: 
 2022: 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>