--- loncom/interface/groupboards.pm 2006/06/30 18:27:19 1.4 +++ loncom/interface/groupboards.pm 2006/07/08 01:07:34 1.5 @@ -30,7 +30,6 @@ use strict; use Apache::Constants qw(:common :http); use Apache::loncommon; use Apache::lonnet; -use Apache::lonnavmaps; use Apache::lonuserstate; use Apache::lonratedt; use Apache::lonlocal; @@ -58,21 +57,48 @@ sub handler { my $now = time; my $crstype = &Apache::loncommon::course_type(); my $gpterm = &Apache::loncommon::group_term(); + my $ucgpterm = $gpterm; + $ucgpterm =~ s/^(\w)/uc($1)/e; my $bodytitle = &mt('[_1] Discussion Boards',$crstype); my $group = $env{'form.group'}; + $group =~ s/\W//g; + my ($description,$earlyout); + + &Apache::lonhtmlcommon::clear_breadcrumbs(); if (!defined($group)) { - $r->print(&Apache::loncommon::start_page($bodytitle)); - $r->print(&mt('No [_1] defined, so there are no [_1] discussion boards to display',$gpterm)); - $r->print(&Apache::loncommon::end_page()); + $earlyout = &mt('No [_1] defined, so there are no [_1] discussion boards to display',$gpterm); + $r->print(&display_error($cdom,$cnum,$group,$description,$gpterm, + $ucgpterm,$bodytitle,$earlyout)); + return OK; + } + my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$group); + if (!defined($curr_groups{$group})) { + $earlyout = &mt('Invalid [_1]',$gpterm); + $r->print(&display_error($cdom,$cnum,$group,$description,$gpterm, + $ucgpterm,$bodytitle,$earlyout)); return OK; } + my %content = &Apache::longroup::get_group_settings($curr_groups{$group}); + my $description = &unescape($content{'description'}); + my $can_create=&Apache::lonnet::allowed('cgb',$env{'request.course.id'}. '/'.$group); - my $can_view=&Apache::lonnet::allowed('pgd',$env{'request.course.id'}. + my $can_view = &Apache::lonnet::allowed('vcg',$env{'request.course.id'}); + + if (!$can_view) { + $can_view = &Apache::lonnet::allowed('pgd',$env{'request.course.id'}. '/'.$group); + } + if (!$can_view) { + $earlyout=&mt('You do not have privileges to view discussion boards in this [_1]',$gpterm); + $r->print(&display_error($cdom,$cnum,$group,$description,$gpterm, + $ucgpterm,$bodytitle,$earlyout)); + return OK; + } if (defined($env{'form.newbul'})) { if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) { - $r->print(&Apache::loncommon::start_page($bodytitle)); + $r->print(&boards_header($cdom,$cnum,$group,$description,$gpterm, + $ucgpterm,$bodytitle)); my ($outcome,$newurl,$bbtitle) = &create_board($cdom,$cnum,$group,$env{'form.newbul'}); if ($outcome eq 'ok') { @@ -96,6 +122,7 @@ sub handler { my $jscript; if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) { $jscript = qq| + |; } - $r->print(&Apache::loncommon::start_page($bodytitle, - '')); - if (!$can_view) { - $r->print(&mt('You do not have privileges to view discussion boards in this [_1]',$crstype)); - return OK; - } - my $navmap = Apache::lonnavmaps::navmap->new(); + $r->print(&boards_header($cdom,$cnum,$group,$description,$gpterm,$ucgpterm, + $bodytitle,$jscript)); my ($groupboards,$boards) = &Apache::longroup::get_group_bbinfo($cdom,$cnum, $group); if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) { - $r->print('