--- loncom/interface/lonwhatsnew.pm 2008/12/12 15:48:05 1.83 +++ loncom/interface/lonwhatsnew.pm 2010/01/28 22:37:18 1.99.2.2 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.83 2008/12/12 15:48:05 raeburn Exp $ +# $Id: lonwhatsnew.pm,v 1.99.2.2 2010/01/28 22:37:18 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,6 +42,7 @@ use Time::Local; use GDBM_File; use lib '/home/httpd/lib/perl/'; use LONCAPA; +use HTML::Entities; #---------------------------- # handler @@ -99,7 +100,7 @@ sub handler { &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/whatsnew', - text=>"Display Action Items"}); + text=>"What's New?"}); if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) { &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage, @@ -194,7 +195,7 @@ sub display_main_box { ); my %initpage = &Apache::lonlocal::texthash ( firstres => "first resource in the $lctype", - whatsnew => "what's new? page", + whatsnew => "What's New Page", userpref => 'your general user preferences', coursespecific => "specific setting for this $lctype", ); @@ -267,7 +268,7 @@ END '; } my $course_type=&Apache::loncommon::course_type(); - return &Apache::loncommon::start_page($course_type.' Action Items', + return &Apache::loncommon::start_page("What's New?", $scripttag); } @@ -288,7 +289,7 @@ sub display_actions_box { my $lctype = lc($crstype); my %stulabel = ( 'Course' => 'students', - 'Group' => 'members', + 'Community' => 'members', ); my %lt = &Apache::lonlocal::texthash( 'yacc' => 'You are accessing an invalid course', @@ -327,7 +328,7 @@ sub display_actions_box { my %threshold = (); my %pagedesc = &Apache::lonlocal::texthash ( firstres => 'First resource', - whatsnew => "What's New? page", + whatsnew => "What's New Page", userpref => 'user preference', coursespecific => $lctype.' only', default => 'default', @@ -341,10 +342,11 @@ sub display_actions_box { return; } + my $header = ''; if ($refpage eq 'start') { if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db', &GDBM_READER(),0640)) { - my $furl=$bighash{'first_url'}; + my $furl=&HTML::Entities::encode($bighash{'first_url'},'"<>&'); untie(%bighash); $r->print(''.$lt{'gtfr'}. '
'); @@ -354,7 +356,7 @@ sub display_actions_box { .' ' .&mt('Currently: [_1].',''.$currinit.'') .'  ' - .&mt('[_1]Change[_2] for just [_3]this course[_4] or for all [_5]your courses[_6].' + .&mt('[_1]Change[_2] for just [_3]this '.$lctype.'[_4] or for [_5]all your courses/communities[_6].' ,'' ,'' ,'' @@ -363,6 +365,8 @@ sub display_actions_box { ,'') .'

'); + $r->print($header); + if ($command eq 'reset') { $result = &process_reset($cdom,$crs); } elsif ($command eq 'update') { @@ -378,12 +382,14 @@ sub display_actions_box { unless ($store_result eq 'ok') { &Apache::lonnet::logthis('Error saving whatsnew settings: '. $store_result.' for '.'user '.$uname.':'.$udom.' in '.$lctype.' '.$cid); - $result .= &mt('Unable to save visibility settings due to [_1]', - $store_result); + $result .= '' + .&mt('Unable to save visibility settings due to [_1]', + $store_result) + .''; } if ($result) { - $r->print($result.'
'); + $r->print($result.'
'); } $r->rflush(); @@ -490,8 +496,9 @@ sub display_actions_box { } } + my $itemserror; if ($needitems) { - &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread); + $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread); } if ($show{'coursenormalmail'}) { $msgcount = &getnormalmail(\@newmsgs); @@ -533,7 +540,7 @@ sub display_actions_box { if ($displayed == $halfway) { $r->print(' '); } - &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); + &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); $displayed ++; } } @@ -593,7 +600,7 @@ sub display_threshold_config { &Apache::loncommon::end_data_table_row()); } $r->print(&Apache::loncommon::end_data_table()."\n". - '
+ '
'); @@ -649,7 +656,7 @@ sub display_interval_config { } $r->print('   '); + &mt('Save').'" />'); return; } @@ -680,9 +687,9 @@ function toggle_countunread(choice) { } '); $r->print('
' - .&mt('Choose whether or not to display a count of the number of new posts for each resource or bulletin board which has unread posts.') + .&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.') .'
' - .&mt("This can increase the time taken to gather data for the 'What's New?' page by a few seconds.") + .&mt("This can increase the time taken to gather data for the [_1]What's New Page[_2] by a few seconds.",'','') .'  ' .&mt('Currently set to [_1].',''.$current.'.') ); @@ -724,7 +731,7 @@ sub courseinit_config { 'anis' => 'and is set to display', 'padc' => 'Page display controlled by', 'chce' => 'Choose '.$lctype.' entry', - 'moce' => 'Modify '.$lctype.' entry', + 'moce' => 'Save', ); $r->print(<<"END");
$lt{'chwp'} @@ -786,23 +793,23 @@ sub display_launcher { $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered, $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs, $interval,$countunread,$expired,$expirecount,$activated,$activecount, - $crstype) = @_; + $crstype,$itemserror) = @_; if ($$checkallowed{$action}) { &start_box($r,$show,$headings,$action,$refpage,$action); if ($$show{$action}) { if ($action eq 'handgrading') { # UNGRADED ITEMS - &display_handgrade($r,$tograde,$ungraded); + &display_handgrade($r,$tograde,$ungraded,$itemserror); } elsif ($action eq 'haserrors') { # BOMBS - &display_haserrors($r,$bombs,$bombed,$res_title); + &display_haserrors($r,$bombs,$bombed,$res_title,$itemserror); } elsif ($action eq 'versionchanges') { # VERSION CHANGES - &display_versionchanges($r,$changed,$res_title,$interval->{'versions'}); + &display_versionchanges($r,$changed,$res_title,$interval->{'versions'},$itemserror); } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS &display_abovethreshold($r,$refpage,$warnings,$triggered, - $res_title); + $res_title,$itemserror); } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION &display_coursediscussion($r,$newdiscussions,$unread, - $countunread,$res_title); + $countunread,$res_title,$itemserror); } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES &display_coursenormalmail($r,$msgcount,$newmsgs); } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES @@ -825,6 +832,10 @@ sub getitems { $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show, $starttime,$countunread) = @_; my $navmap = Apache::lonnavmaps::navmap->new(); + if (!defined($navmap)) { + my $itemserror = ''.&mt('An error occurred retrieving information about the course.').'
'.&mt('It is recommended that you [_1]re-select the course[_2].','','').'
'; + return $itemserror; + } # force retrieve Resource to seed the part id cache we'll need it later my @allres=$navmap->retrieveResources(undef, sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;}); @@ -883,6 +894,7 @@ sub getitems { } } + return; } sub check_discussions { @@ -1118,7 +1130,7 @@ sub process_reset { sub process_update { my ($uname,$udom,$threshold_titles) = @_; - my $setoutput = ''.&mt('Changes to threshold(s) for problem tracking:').'
'; + my $setoutput = ''.&mt('Changes to threshold(s) for problem tracking:').'

'; foreach (keys %env) { next if ($_!~/^form\.(.+)\_setparmval$/); my $name = $1; @@ -1129,17 +1141,17 @@ sub process_update { my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/); if ($put_result eq 'ok') { - $setoutput.=&mt('Set threshold for [_1] to [_2]', + $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Set threshold for [_1] to [_2]', ''.$$threshold_titles{$shortname}.'', - ''.$value.'').'
'; + ''.$value.'').'
'); } else { - $setoutput.=&mt('Unable to set threshold for [_1] to [_2] due to [_3].', + $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set threshold for [_1] to [_2] due to [_3].', ''.$name.'',''.$value.'', - ''.$put_result.'').'
'; + ''.$put_result.'').'
',1); } } } - return $setoutput; + return &Apache::loncommon::confirmwrapper($setoutput); } sub getnormalmail { @@ -1155,9 +1167,9 @@ sub getnormalmail { if (($fromcid) && ($fromcid eq $env{'request.course.id'})) { if (defined($sendtime) && $sendtime!~/error/) { my $numsendtime = $sendtime; - $sendtime = &Apache::lonlocal::locallocaltime($sendtime); if ($status eq 'new') { - $msgcount ++; + $sendtime = &Apache::lonlocal::locallocaltime($sendtime); + $msgcount ++; if ($shortsubj eq '') { $shortsubj = &mt('No subject'); } @@ -1446,7 +1458,7 @@ sub checkversions { } sub display_handgrade { - my ($r,$tograde,$ungraded) = @_; + my ($r,$tograde,$ungraded,$itemserror) = @_; my %lt = &Apache::lonlocal::texthash( 'prna' => 'Problem Name', 'nmun' => 'Number ungraded', @@ -1469,13 +1481,15 @@ sub display_handgrade { } $r->print(''.$$ungraded{$res}{title}.''.$$ungraded{$res}{count}.''); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'nopr'}.''); } } sub display_haserrors { - my ($r,$bombs,$bombed,$res_title) = @_; + my ($r,$bombs,$bombed,$res_title,$itemserror) = @_; my $bombnum = 0; my %lt = &Apache::lonlocal::texthash( reso => 'Resource', @@ -1494,6 +1508,8 @@ sub display_haserrors { ''. $$bombed{$bomb}{errorcount}.''); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'noer'}.''); } @@ -1501,7 +1517,7 @@ sub display_haserrors { } sub display_abovethreshold { - my ($r,$refpage,$warnings,$triggered,$res_title) = @_; + my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror) = @_; my %lt = &Apache::lonlocal::texthash( reso => 'Resource', part => 'Part', @@ -1557,13 +1573,15 @@ sub display_abovethreshold { } } $r->print('
'); + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'nopr'}.''); } } sub display_versionchanges { - my ($r,$changed,$res_title,$interval) = @_; + my ($r,$changed,$res_title,$interval,$itemserror) = @_; my %lt = &Apache::lonlocal::texthash( 'reso' => 'Resource', 'revd' => 'Last revised', @@ -1590,6 +1608,8 @@ sub display_versionchanges { $$changed{$item}{'current'}.''. $$changed{$item}{'version'}.''); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print('' .&mt('No '.$interval).''); @@ -1655,7 +1675,7 @@ sub display_rolechanges { } sub display_coursediscussion { - my ($r,$newdiscussions,$unread,$countunread,$res_title) = @_; + my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_; my $lctype = lc(&Apache::loncommon::course_type()); my %lt = &Apache::lonlocal::texthash( 'loca' => 'Location', @@ -1685,7 +1705,7 @@ sub display_coursediscussion { my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb); my $disclink = $feedurl.'?symb='.$$unread{$ressymb}{symb}; if ($feedurl =~ /bulletinboard/) { - $type = 'Bulletin Board'; + $type = 'Discussion Board'; } if ($$unread{$ressymb}{'enclink'}) { $disclink = $$unread{$ressymb}{'enclink'}.'?symb='.$$unread{$ressymb}{'encsymb'}; @@ -1703,6 +1723,8 @@ sub display_coursediscussion { } $r->print("\n"); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'noun'}.''); } @@ -1819,19 +1841,19 @@ sub store_interval_setting { \%interval_settings,$udom,$uname); if ($outcome eq 'ok') { if (ref($interval_titles->{$context}) eq 'HASH') { - $result = &mt('New filter setting: [_1].',''. - $interval_titles->{$context}->{$env{'form.interval'}}.'').'
'; + $result = &Apache::lonhtmlcommon::confirm_success(&mt('New filter setting: [_1].',''. + $interval_titles->{$context}->{$env{'form.interval'}}.'').'
'); } } else { my $lctype = lc(&Apache::loncommon::course_type()); &Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'. ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid); - $result = &mt('Unable to set interval to [_1] due to [_2].', + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set interval to [_1] due to [_2].', ''.$interval_titles->{$context}->{$env{'form.interval'}}.'', - ''.$outcome.'.
'); + ''.$outcome.''),1); } } - return $result; + return &Apache::loncommon::confirmwrapper($result); } sub store_discussion_setting { @@ -1843,20 +1865,20 @@ sub store_discussion_setting { my $outcome = &Apache::lonnet::put('nohist_whatsnew', \%discussion_settings,$udom,$uname); if ($outcome eq 'ok') { - $result = &mt('Count unread posts in discussions display set to [_1]', - ''.&mt($env{'form.countunread'}).'').'
'; + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Count unread posts in discussions display set to [_1]', + ''.&mt($env{'form.countunread'}).'').'
'); } else { my $lctype = lc(&Apache::loncommon::course_type()); &Apache::lonnet::logthis('Error saving whatsnew countunread setting'. ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid); - $result = &mt('Unable to set "number unread posts display" to [_1]'. + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set "number unread posts display" to [_1]'. ' due to [_2].', ''.&mt($env{'form.countunread'}).'', - ''.$outcome.'.
'); + ''.$outcome.''),1); } } - return $result; + return &Apache::loncommon::confirmwrapper($result); } sub store_courseinit_setting { @@ -1881,30 +1903,29 @@ sub store_courseinit_setting { \%courseinit_settings,$udom,$uname); if ($outcome eq 'ok') { if ($page_control eq 'global preferences') { - $result = &mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'',''); + $result = &Apache::lonhtmlcommon::confirm_success(&mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'','')); } else { - $result = &mt('Page displayed after role selection in this '.$lctype.' set to [_1].' - ,''.$$initpage{$env{'form.courseinit_page'}}.''); + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Page displayed after role selection in this '.$lctype.' set to [_1].' + ,''.$$initpage{$env{'form.courseinit_page'}}.'')); } } else { &Apache::lonnet::logthis('Error saving whatsnew courseinit '. 'setting: '.$outcome.' for '.$uname. ':'.$udom.' in '.$lctype.' '.$cid); if ($page_control eq 'global preferences') { - $result = &mt('Unable to set control of page display to [_1]'. + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set control of page display to [_1]'. ' due to [_2].', ''.$page_control.'', - ''.$outcome.'.
'); + ''.$outcome.''),1); } else { - $result = &mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].' + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].' ,''.$$initpage{$env{'form.courseinit_page'}}.'' - ,''.$outcome.'') - .'
'; + ,''.$outcome.''),1); } } } } - return $result; + return &Apache::loncommon::confirmwrapper($result); } sub start_box { @@ -1936,35 +1957,35 @@ sub start_box { if ($$show{$caller}) { $r->print(' - '.$lt{'chth'}.' + '.$lt{'chth'}.' '); } } elsif (($caller eq 'versionchanges') && ($$show{$caller})) { if ($$show{$caller}) { $r->print(' - '.$lt{'chin'}.' + '.$lt{'chin'}.' '); } } elsif ($caller eq 'coursediscussion') { if ($$show{$caller}) { $r->print(' - '.$lt{'chop'}.' + '.$lt{'chop'}.' '); } } elsif (($caller eq 'newroles') && ($$show{$caller})) { if ($$show{$caller}) { $r->print(' - '.$lt{'chin'}.' + '.$lt{'chin'}.' '); } } elsif (($caller eq 'oldroles') && ($$show{$caller})) { if ($$show{$caller}) { $r->print(' - '.$lt{'chin'}.' + '.$lt{'chin'}.' '); } }