version 1.2, 2006/06/30 14:08:35
|
version 1.4, 2006/06/30 18:27:19
|
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) = |
my ($outcome,$newurl,$bbtitle) = |
&create_board($cdom,$cnum,$group,$env{'form.newbul'}); |
&create_board($cdom,$cnum,$group,$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 />')); |
$r->print('<table border="0"><tr><td>'. |
$r->print('<table border="0"><tr><td>'. |
'<a href="'.$newurl.'?register=1&symb='.$symb. |
'<a href="'.$newurl.'?group='.$group.'">'. |
'&group='.$group.'">'. |
|
&mt('Edit [_1] board',$bbtitle).'</a></td>'. |
&mt('Edit [_1] board',$bbtitle).'</a></td>'. |
'<td> </td><td>'. |
'<td> </td><td>'. |
'<a href="/adm/groupboards?group='.$group.'">'. |
'<a href="/adm/groupboards?group='.$group.'">'. |
Line 115 function makebulboard() {
|
Line 114 function makebulboard() {
|
return OK; |
return OK; |
} |
} |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my @groupboards; |
my ($groupboards,$boards) = &Apache::longroup::get_group_bbinfo($cdom,$cnum, |
my %boards; |
$group); |
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(), |
|
}; |
|
} |
|
} |
|
} |
|
} |
|
if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) { |
if (($can_create) || (&Apache::lonnet::allowed('mdg',$env{'request.course.id'}))) { |
$r->print('<form method="post" name="newbb" action="/adm/groupboards">'. |
$r->print('<form method="post" name="newbb" action="/adm/groupboards">'. |
"\n".'<input type="button" name="bbbutton" value="'. |
"\n".'<input type="button" name="bbbutton" value="'. |
Line 143 function makebulboard() {
|
Line 125 function makebulboard() {
|
' <input type="hidden" name="group" value="'.$group.'" />'. |
' <input type="hidden" name="group" value="'.$group.'" />'. |
"\n".'</form><br />'); |
"\n".'</form><br />'); |
} |
} |
if (@groupboards) { |
if (@{$groupboards} > 0) { |
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'}.'?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 156 function makebulboard() {
|
Line 138 function makebulboard() {
|
} |
} |
|
|
sub create_board { |
sub create_board { |
my ($cdom,$cnum,$group,$newboard,$symb) = @_; |
my ($cdom,$cnum,$group,$newboard) = @_; |
my ($bbtitle,$newurl)=split(/\=/,$newboard); |
my ($bbtitle,$newurl)=split(/\=/,$newboard); |
$bbtitle=&unescape($bbtitle); |
$bbtitle=&unescape($bbtitle); |
$newurl=&unescape($newurl); |
$newurl=&unescape($newurl); |
my $allbbsmap = &get_bbfolder_url($cdom,$cnum,$group); |
my $allbbsmap = &Apache::longroup::get_bbfolder_url($cdom,$cnum,$group); |
my ($outcome,$symb); |
my ($outcome); |
if ($allbbsmap =~ m|^/uploaded|) { |
if ($allbbsmap =~ m|^/uploaded|) { |
my ($errtext,$fatal)=&Apache::lonratedt::mapread($allbbsmap); |
my ($errtext,$fatal)=&Apache::lonratedt::mapread($allbbsmap); |
if (!$fatal) { |
if (!$fatal) { |
Line 174 sub create_board {
|
Line 156 sub create_board {
|
$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); |
|
} |
} |
} else { |
} else { |
$outcome = "error: failed to read all discussion boards map - $errtext\n"; |
$outcome = "error: failed to read all discussion boards map - $errtext\n"; |
Line 183 sub create_board {
|
Line 164 sub create_board {
|
$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,$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; |
|
} |
} |
|
|
1; |
1; |