[LON-CAPA-cvs] cvs: loncom /interface groupboards.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Mon, 17 Jul 2006 14:52:03 -0000
raeburn Mon Jul 17 10:52:03 2006 EDT
Modified files:
/loncom/interface groupboards.pm
Log:
Fix priv checking for roles with sections. Breadcrumbs includes link to all groups when page is displayed from 'Groups' link in inline menu.
Index: loncom/interface/groupboards.pm
diff -u loncom/interface/groupboards.pm:1.6 loncom/interface/groupboards.pm:1.7
--- loncom/interface/groupboards.pm:1.6 Fri Jul 14 13:23:49 2006
+++ loncom/interface/groupboards.pm Mon Jul 17 10:52:00 2006
@@ -50,7 +50,7 @@
}
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['group']);
+ ['group','ref']);
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
@@ -62,20 +62,24 @@
my $bodytitle = &mt('[_1] Discussion Boards',$crstype);
my $group = $env{'form.group'};
$group =~ s/\W//g;
- my ($description,$earlyout);
+ my ($description,$earlyout,$refarg);
+
+ if (exists($env{'form.ref'})) {
+ $refarg = 'ref='.$env{'form.ref'};
+ }
&Apache::lonhtmlcommon::clear_breadcrumbs();
if (!defined($group)) {
$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));
+ $ucgpterm,$bodytitle,$earlyout,$refarg));
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));
+ $ucgpterm,$bodytitle,$earlyout,$refarg));
return OK;
}
my %content = &Apache::longroup::get_group_settings($curr_groups{$group});
@@ -83,33 +87,33 @@
my $can_create=&Apache::lonnet::allowed('cgb',$env{'request.course.id'}.
'/'.$group);
- my $can_view = &Apache::lonnet::allowed('vcg',$env{'request.course.id'});
+ my $can_view = &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
if (!$can_view) {
- $can_view = &Apache::lonnet::allowed('pgd',$env{'request.course.id'}.
+ $can_view = &Apache::lonnet::allowed('vgb',$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));
+ $ucgpterm,$bodytitle,$earlyout,$refarg));
return OK;
}
if (defined($env{'form.newbul'})) {
if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) {
$r->print(&boards_header($cdom,$cnum,$group,$description,$gpterm,
- $ucgpterm,$bodytitle));
+ $ucgpterm,$bodytitle,$refarg));
my ($outcome,$newurl,$bbtitle) =
&create_board($cdom,$cnum,$group,$env{'form.newbul'});
if ($outcome eq 'ok') {
my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
$r->print(&mt('The new discussion board was added successfully.<br />'));
$r->print('<table border="0"><tr><td>'.
- '<a href="'.$newurl.'?group='.$group.'">'.
- &mt('Edit [_1] board',$bbtitle).'</a></td>'.
+ '<a href="'.$newurl.'?group='.$group.'&'.$refarg.
+ '">'.&mt('Edit [_1] board',$bbtitle).'</a></td>'.
'<td> </td><td>'.
- '<a href="/adm/groupboards?group='.$group.'">'.
- &mt('View all group discussion boards').
+ '<a href="/adm/groupboards?group='.$group.'&'.
+ $refarg.'">'.&mt('View all group discussion boards').
'</a></td></tr></table>');
} else {
$r->print(&mt('There was a problem creating the new discussion board - [_1]','<span class="LC_error">'.$outcome.'</span>').'<br /><a href="/adm/groupboards?group='.$group.'">'.
@@ -135,7 +139,7 @@
|;
}
$r->print(&boards_header($cdom,$cnum,$group,$description,$gpterm,$ucgpterm,
- $bodytitle,$jscript));
+ $bodytitle,$refarg,$jscript));
my ($groupboards,$boards) = &Apache::longroup::get_group_bbinfo($cdom,$cnum,
$group);
if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) {
@@ -143,8 +147,9 @@
"\n".'<input type="button" name="bbbutton" value="'.
&mt('New Discussion Board').
'" onClick="javascript:makebulboard();" />'."\n".
- ' <input type="hidden" name="newbul" />'."\n".
- ' <input type="hidden" name="group" value="'.$group.'" />'.
+ '<input type="hidden" name="newbul" />'."\n".
+ '<input type="hidden" name="group" value="'.$group.'" />'.
+ '<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />'.
"\n".'</form><br />');
}
if (@{$groupboards} > 0) {
@@ -156,7 +161,8 @@
} else {
$board_url .= '?group='.$group;
}
- $r->print('<a href="'.$board_url.'">'.$$boards{$board}{'title'}.'</a><br />');
+ $r->print('<a href="'.$board_url.'&'.$refarg.'">'.
+ $$boards{$board}{'title'}.'</a><br />');
}
} else {
$r->print('<br />'.&mt('There are currently no discussion boards in this [_1].',
@@ -206,22 +212,30 @@
}
sub display_error {
- my ($cdom,$cnum,$group,$description,$gpterm,$ucgpterm,$bodytitle,$earlyout)=@_;
+ my ($cdom,$cnum,$group,$description,$gpterm,$ucgpterm,$bodytitle,$earlyout,
+ $refarg)=@_;
my $output = &boards_header($cdom,$cnum,$group,$description,$gpterm,
- $ucgpterm,$bodytitle);
+ $ucgpterm,$bodytitle,$refarg);
$output .= $earlyout;
$output .= &Apache::loncommon::end_page();
return $output;
}
sub boards_header {
- my ($cdom,$cnum,$group,$description,$gpterm,$ucgpterm,$bodytitle,$jscript)=@_;
+ my ($cdom,$cnum,$group,$description,$gpterm,$ucgpterm,$bodytitle,$refarg,
+ $jscript)=@_;
my $output = &Apache::loncommon::start_page($bodytitle,$jscript);
+ if ($refarg) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/coursegroups",
+ text=>"Groups",
+ title=>"View course groups"},);
+ }
&Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/$cdom/$cnum/$group/smppg",
+ ({href=>"/adm/$cdom/$cnum/$group/smppg?$refarg",
text=>"$ucgpterm: $description",
title=>"Go to group's home page"},
- {href=>"/adm/groupboards?group=$group",
+ {href=>"/adm/groupboards?group=$group&$refarg",
text=>"Discussion Boards",
title=>"Display group discussion boards"},);
$output .= &Apache::lonhtmlcommon::breadcrumbs(&mt('[_1] discussion boards - [_2]',$gpterm,$description));