--- loncom/interface/groupboards.pm 2006/06/30 15:37:58 1.3
+++ loncom/interface/groupboards.pm 2006/06/30 18:27:19 1.4
@@ -73,7 +73,7 @@ sub handler {
if (defined($env{'form.newbul'})) {
if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) {
$r->print(&Apache::loncommon::start_page($bodytitle));
- my ($outcome,$symb,$newurl,$bbtitle) =
+ my ($outcome,$newurl,$bbtitle) =
&create_board($cdom,$cnum,$group,$env{'form.newbul'});
if ($outcome eq 'ok') {
my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
@@ -114,25 +114,8 @@ function makebulboard() {
return OK;
}
my $navmap = Apache::lonnavmaps::navmap->new();
- my @groupboards;
- my %boards;
- my $grpbbmap = &get_bbfolder_url($cdom,$cnum,$group);
- if ($grpbbmap) {
- my $bbfolderres = $navmap->getResourceByUrl($grpbbmap);
- if ($bbfolderres) {
- my @boards = $navmap->retrieveResources($bbfolderres,undef,0,0);
- foreach my $res (@boards) {
- my $url = $res->src();
- if ($url =~ m|^/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard|) {
- push(@groupboards,$res->symb());
- $boards{$res->symb()} = {
- title => $res->title(),
- url => $res->src(),
- };
- }
- }
- }
- }
+ my ($groupboards,$boards) = &Apache::longroup::get_group_bbinfo($cdom,$cnum,
+ $group);
if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) {
$r->print('
');
}
- if (@groupboards) {
- foreach my $board (@groupboards) {
- $r->print(''.$boards{$board}{'title'}.'
');
+ if (@{$groupboards} > 0) {
+ foreach my $board (@{$groupboards}) {
+ $r->print(''.$$boards{$board}{'title'}.'
');
}
} else {
$r->print(&mt('There are currently no discussion boards in this [_1].',
@@ -155,12 +138,12 @@ function makebulboard() {
}
sub create_board {
- my ($cdom,$cnum,$group,$newboard,$symb) = @_;
+ my ($cdom,$cnum,$group,$newboard) = @_;
my ($bbtitle,$newurl)=split(/\=/,$newboard);
$bbtitle=&unescape($bbtitle);
$newurl=&unescape($newurl);
- my $allbbsmap = &get_bbfolder_url($cdom,$cnum,$group);
- my ($outcome,$symb);
+ my $allbbsmap = &Apache::longroup::get_bbfolder_url($cdom,$cnum,$group);
+ my ($outcome);
if ($allbbsmap =~ m|^/uploaded|) {
my ($errtext,$fatal)=&Apache::lonratedt::mapread($allbbsmap);
if (!$fatal) {
@@ -173,7 +156,6 @@ sub create_board {
$outcome = "error: failed to store discussion boards map - $errtext\n";
} else {
$outcome = 'ok';
- $symb = &Apache::lonnet::encode_symb($allbbsmap,$newidx,$newurl);
}
} else {
$outcome = "error: failed to read all discussion boards map - $errtext\n";
@@ -182,22 +164,7 @@ sub create_board {
$outcome = 'error: discussion boards folder absent, '.
'or in unexpected location - '.$allbbsmap."\n";
}
- return ($outcome,$symb,$newurl,$bbtitle);
-}
-
-sub get_bbfolder_url {
- my ($cdom,$cnum,$group) = @_;
- my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$group);
- my $grpbbmap;
- if (%curr_groups) {
- my %group_info = &Apache::longroup::get_group_settings(
- $curr_groups{$group});
- my $creation = $group_info{'creation'};
- my $bbfolder = $creation + 1;
- my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
- $grpbbmap = $crspath.'default_'.$bbfolder.'.sequence';
- }
- return $grpbbmap;
+ return ($outcome,$newurl,$bbtitle);
}
1;