'.
@@ -189,56 +193,18 @@ function makebulboard() {
sub create_board {
my ($cdom,$cnum,$group,$bbtitle) = @_;
- my ($outcome,$boardid,$newurl);
+ my ($outcome,$newurl,$idtype);
$bbtitle=&unescape($bbtitle);
- # get lock on nohist_groupboards file
- my $lockhash = {
- $group."\0".'locked_boardids' => $env{'user.name'}.
- ':'.$env{'user.domain'},
- };
- my $tries = 0;
- my $gotlock = &Apache::lonnet::newput('nohist_groupboards',$lockhash,$cdom,$cnum);
- my $dellockoutcome;
- while (($gotlock ne 'ok') && $tries <3) {
- $tries ++;
- sleep 1;
- $gotlock = &Apache::lonnet::newput('nohist_groupboards',$lockhash,$cdom,$cnum);
- }
- if ($gotlock eq 'ok') {
- my %curr_boards = &Apache::lonnet::dump('nohist_groupboards',$cdom,$cnum,$group);
- $boardid = time;
- my $idtries = 0;
- while(exists($curr_boards{$group."\0".$boardid}) && $idtries < 20) {
- $boardid ++;
- $idtries ++;
- }
- if (!exists($curr_boards{$group."\0".$boardid})) {
- my %new_board = (
- $group."\0".$boardid => $env{'user.name'}.':'.
- $env{'user.domain'},
- );
- my $putresult = &Apache::lonnet::put('nohist_groupboards',\%new_board,
- $cdom,$cnum);
- if ($putresult ne 'ok') {
- $outcome = 'error saving new board: '.$putresult;
- } else {
- $newurl = '/adm/'.$cdom.'/'.$cnum.'/'.$boardid.
- '/bulletinboard';
- }
- } else {
- $outcome = ('error: no unique ID for the new board available.');
- }
- # remove lock
- my @del_lock = ($group."\0".'locked_boardids');
- $dellockoutcome = &Apache::lonnet::del('nohist_groupboards',\@del_lock,$cdom,$cnum);
+ $idtype = 'inc';
+ my ($boardid,$dellock,$error) =
+ &Apache::lonnet::get_timebased_id($group,'boardids','groupboards',
+ $cdom,$cnum);
+ if ($boardid) {
+ $newurl = '/adm/'.$cdom.'/'.$cnum.'/'.$boardid.'/bulletinboard';
} else {
- $outcome = "error: could not obtain lockfile\n";
- $dellockoutcome = 'ok';
- }
- if (!$newurl) {
- return ($outcome,$newurl,$bbtitle,$dellockoutcome);
+ return ($error,$newurl,$bbtitle,$dellock);
}
- $newurl=&unescape($newurl);
+
# need to check here if group_boards_$group.sequence is in the course
# if not - add it as an item in group_folder_$group.sequence
my $allbbsmap = &Apache::longroup::get_bbfolder_url($cdom,$cnum,$group);
@@ -249,7 +215,7 @@ sub create_board {
$LONCAPA::map::resources[$newidx]=$bbtitle.':'.$newurl.
':false:normal:res';
push(@LONCAPA::map::order,$newidx);
- my ($errtext,$fatal)=&LONCAPA::map::storemap($allbbsmap,1);
+ my ($errtext,$fatal)=&LONCAPA::map::storemap($allbbsmap,1,1);
if ($fatal) {
$outcome = "error: failed to save discussion boards map - $errtext\n";
} else {
@@ -266,7 +232,7 @@ sub create_board {
$outcome = 'error: discussion boards folder absent, '.
'or in unexpected location - '.$allbbsmap."\n";
}
- return ($outcome,$newurl,$bbtitle,$dellockoutcome);
+ return ($outcome,$newurl,$bbtitle,$dellock);
}
sub display_error {
500 Internal Server Error
Internal Server Error
The server encountered an internal error or
misconfiguration and was unable to complete
your request.
Please contact the server administrator at
root@localhost to inform them of the time this error occurred,
and the actions you performed just before this error.
More information about this error may be available
in the server error log.