--- loncom/interface/lonwhatsnew.pm 2005/07/15 05:43:42 1.26 +++ loncom/interface/lonwhatsnew.pm 2006/05/30 12:46:09 1.55 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.26 2005/07/15 05:43:42 albertel Exp $ +# $Id: lonwhatsnew.pm,v 1.55 2006/05/30 12:46:09 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -39,6 +39,8 @@ use Apache::lonuserstate; use Apache::Constants qw(:common :http); use Time::Local; use GDBM_File; +use lib '/home/httpd/lib/perl/'; +use LONCAPA; #---------------------------- # handler @@ -52,41 +54,83 @@ sub handler { $r->send_http_header; return OK; } - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['command']); + &Apache::loncommon::get_unprocessed_cgi( + $ENV{'QUERY_STRING'},['command','refpage']); - my $command; - if ($env{'form.action'} eq 'reset') { - $command = 'reset'; - } elsif ($env{'form.action'} eq 'update') { - $command = 'update'; - } else { - $command = $env{'form.command'}; + my $command = $env{'form.command'}; + my $refpage = $env{'form.refpage'}; + + my %checkallowed = ( coursenormalmail => 1, + coursecritmail => 1, ); + foreach my $perm_check (['whn','whatsnew',1], + ['pch','coursediscussion',1], + ['mgr','handgrading',1], + ['vgr','abovethreshold',1], + ['opa','haserrors',1], + ['mdc','versionchanges',0], + ) { + my ($perm,$key,$check_section) = @{ $perm_check }; + my $scope = $env{'request.course.id'}; + if (!($checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope))) { + $scope .= '/'.$env{'request.course.sec'}; + if ( $check_section ) { + $checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope); + } + if ($checkallowed{$key}) { + $checkallowed{$key.'_section'} = $env{'request.course.sec'}; + } + } } - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - $r->print(&display_header()); - if (! (($env{'request.course.fn'}) && (&Apache::lonnet::allowed('vsa',$env{'request.course.id'})))) { - # Not in a course, or not allowed to modify parms - $env{'user.error.msg'}="/adm/whatsnew:vsa:0:0:Cannot display student activity"; + if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) { + # Not in a course, or no whn priv in course + $env{'user.error.msg'}="/adm/whatsnew::whn:0:0:Cannot display what's new page"; return HTTP_NOT_ACCEPTABLE; } + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + + $r->print(&display_header($command,\%checkallowed)); + &Apache::lonhtmlcommon::clear_breadcrumbs(); - if ($command eq 'chgthreshold') { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>'/adm/whatsnew', + text=>"Display Action Items"}); + if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) { &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/whatsnew?command=threshold', + ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage, text=>"Change thresholds"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs - (undef,'Course Action Items','Course_Action_Items_Thresholds')); - } else { + ("What's New?",#'Course_Action_Items_Thresholds' + )); + } elsif (($command eq 'chginterval') && $checkallowed{'versionchanges'} ) { &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/whatsnew', - text=>"Display Action Items"}); + ({href=>'/adm/whatsnew?command=chginterval&refpage='.$refpage, + text=>"Change interval"}); + $r->print(&Apache::lonhtmlcommon::breadcrumbs + ("What's New?",#'Course_Action_Items_Intervals' + )); + } elsif (($command eq 'chgdisc') && $checkallowed{'coursediscussion'}) { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>'/adm/whatsnew?command=chgdisc&refpage='.$refpage, + text=>"Change discussion display"}); + $r->print(&Apache::lonhtmlcommon::breadcrumbs + ("What's New?",#'Course_Action_Items_Intervals' + )); + } elsif ($command eq 'courseinit') { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>'/adm/whatsnew?command=courseinit&refpage='.$refpage, + text=>"Course initialization preference"}); + $r->print(&Apache::lonhtmlcommon::breadcrumbs + ("What's New?",#'Course_Action_Items_Initialization' + )); + } else { $r->print(&Apache::lonhtmlcommon::breadcrumbs - (undef,'Course Action Items','Course_Action_Items_Display')); + ("What's New?",#'Course_Action_Items_Display' + )); } - &display_main_box($r,$command); + &display_main_box($r,$command,$refpage,\%checkallowed); return OK; } @@ -97,30 +141,56 @@ sub handler { #------------------------------ sub display_main_box { - my ($r,$command) = @_; + my ($r,$command,$refpage,$checkallowed) = @_; my $domain=&Apache::loncommon::determinedomain(); - my $tabbg=&Apache::loncommon::designparm('coordinator.tabbg',$domain); + my $function = &Apache::loncommon::get_users_function(); + my $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain); $r->print('
');
- my %threshold_titles = (
+ my %threshold_titles = &Apache::lonlocal::texthash (
av_attempts => 'Average number of attempts',
degdiff => 'Degree of difficulty',
numstudents => 'Total number of students with submissions',
);
+
+ my %interval_titles = &Apache::lonlocal::texthash (
+ -1 => 'since start of course',
+ 2592000 => 'since last month',
+ 604800 => 'since last week',
+ 86400 => 'since yesterday',
+ );
+
+ my %initpage = &Apache::lonlocal::texthash (
+ firstres => 'first resource in the course',
+ whatsnew => "what's new? page",
+ userpref => 'your general user preferences',
+ coursespecific => 'specific setting for this course',
+ );
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
- if ($command eq 'chgthreshold') {
- &display_config_box($r,$command,$tabbg,\%threshold_titles,$cdom,$crs);
+ if (($command eq 'chgthreshold')
+ && $checkallowed->{'abovethreshold'}) {
+ &display_threshold_config($r,$refpage,$tabbg,\%threshold_titles,
+ $cdom,$crs);
+ } elsif (($command eq 'chginterval')
+ && $checkallowed->{'versionchanges'}) {
+ &display_interval_config($r,$refpage,\%interval_titles);
+ } elsif (($command eq 'chgdisc')
+ && $checkallowed->{'coursediscussion'}) {
+ &display_discussion_config($r,$refpage);
+ } elsif ($command eq 'courseinit') {
+ &courseinit_config($r,$refpage,\%initpage);
} else {
- &display_actions_box($r,$command,\%threshold_titles,$cdom,$crs);
+ &display_actions_box($r,$tabbg,$command,$refpage,\%threshold_titles,
+ \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
}
+ my $end_page = &Apache::loncommon::end_page();
$r->print(< |