version 1.1, 2006/06/30 08:14:31
|
version 1.2, 2006/06/30 14:08:35
|
Line 25
|
Line 25
|
# |
# |
|
|
package Apache::groupboards; |
package Apache::groupboards; |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
use Apache::loncommon; |
use Apache::loncommon; |
Line 73 sub handler {
|
Line 73 sub handler {
|
if (defined($env{'form.newbul'})) { |
if (defined($env{'form.newbul'})) { |
if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) { |
if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) { |
$r->print(&Apache::loncommon::start_page($bodytitle)); |
$r->print(&Apache::loncommon::start_page($bodytitle)); |
my ($outcome,$symb,$newurl,$bbtitle) = &create_board($cdom,$cnum, |
my ($outcome,$symb,$newurl,$bbtitle) = |
$group, |
&create_board($cdom,$cnum,$group,$env{'form.newbul'}); |
$env{'form.newbul'}); |
|
if ($outcome eq 'ok') { |
if ($outcome eq 'ok') { |
my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
$r->print(&mt('The new discussion board was added successfully.<br />')); |
$r->print(&mt('The new discussion board was added successfully.<br />')); |
Line 88 sub handler {
|
Line 87 sub handler {
|
&mt('View all group discussion boards'). |
&mt('View all group discussion boards'). |
'</a></td></tr></table>'); |
'</a></td></tr></table>'); |
} else { |
} else { |
$r->print(&mt('There was a problem creating the new discussion board - [_1]',$outcome).'<br /><a href="/adm/groupboards?group='.$group.'">'. |
$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.'">'. |
&mt('Return to discussion boards').'</a>'); |
&mt('Return to discussion boards').'</a>'); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
Line 125 function makebulboard() {
|
Line 124 function makebulboard() {
|
my @boards = $navmap->retrieveResources($bbfolderres,undef,0,0); |
my @boards = $navmap->retrieveResources($bbfolderres,undef,0,0); |
foreach my $res (@boards) { |
foreach my $res (@boards) { |
my $url = $res->src(); |
my $url = $res->src(); |
my $title = $res->title(); |
|
my $symb = $res->symb(); |
|
if ($url =~ m|^/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard|) { |
if ($url =~ m|^/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard|) { |
push(@groupboards,$symb); |
push(@groupboards,$res->symb()); |
%{$boards{$symb}} = ( |
$boards{$res->symb()} = { |
title => $title, |
title => $res->title(), |
url => $url, |
url => $res->src(), |
); |
}; |
} |
} |
} |
} |
} |
} |
Line 148 function makebulboard() {
|
Line 145 function makebulboard() {
|
} |
} |
if (@groupboards) { |
if (@groupboards) { |
foreach my $board (@groupboards) { |
foreach my $board (@groupboards) { |
$r->print('<a href="'.$boards{$board}{'url'}.'?register=1&symb='.$board.'&group='.$group.'">'.$boards{$board}{'title'}.'</a><br />'); |
$r->print('<a href="'.$boards{$board}{'url'}.'?register=1&symb='.$board.'&group='.$group.'">'.$boards{$board}{'title'}.'</a><br />'); |
} |
} |
} else { |
} else { |
$r->print(&mt('There are currently no discussion boards in this [_1].', |
$r->print(&mt('There are currently no discussion boards in this [_1].', |
Line 171 sub create_board {
|
Line 168 sub create_board {
|
my $newidx=&Apache::lonratedt::getresidx($newurl); |
my $newidx=&Apache::lonratedt::getresidx($newurl); |
$Apache::lonratedt::resources[$newidx]=$bbtitle.':'.$newurl. |
$Apache::lonratedt::resources[$newidx]=$bbtitle.':'.$newurl. |
':false:normal:res'; |
':false:normal:res'; |
$Apache::lonratedt::order[1+$#Apache::lonratedt::order]=$newidx; |
push(@Apache::lonratedt::order,$newidx); |
my ($errtext,$fatal)=&Apache::lonratedt::storemap($allbbsmap,1); |
my ($errtext,$fatal)=&Apache::lonratedt::storemap($allbbsmap,1); |
if ($fatal) { |
if ($fatal) { |
$outcome = "Error: failed to store discussion boards map - $errtext\n"; |
$outcome = "error: failed to store discussion boards map - $errtext\n"; |
} else { |
} else { |
$outcome = 'ok'; |
$outcome = 'ok'; |
$symb = &Apache::lonnet::encode_symb($allbbsmap,$newidx,$newurl); |
$symb = &Apache::lonnet::encode_symb($allbbsmap,$newidx,$newurl); |
} |
} |
} else { |
} else { |
$outcome = "Error: failed to read all discussion boards map - $errtext\n"; |
$outcome = "error: failed to read all discussion boards map - $errtext\n"; |
} |
} |
} else { |
} else { |
$outcome = 'Error: discussion boards folder absent, '. |
$outcome = 'error: discussion boards folder absent, '. |
'or in unexpected location - '.$allbbsmap."\n"; |
'or in unexpected location - '.$allbbsmap."\n"; |
} |
} |
return ($outcome,$symb,$newurl,$bbtitle); |
return ($outcome,$symb,$newurl,$bbtitle); |