--- loncom/interface/lonbulletin.pm 2009/11/26 05:21:43 1.50 +++ loncom/interface/lonbulletin.pm 2016/02/26 21:44:39 1.68 @@ -1,7 +1,7 @@ # The LearningOnline Network # Bulletin Board Handler # -# $Id: lonbulletin.pm,v 1.50 2009/11/26 05:21:43 faziophi Exp $ +# $Id: lonbulletin.pm,v 1.68 2016/02/26 21:44:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,9 +33,12 @@ use Apache::Constants qw(:common); use Apache::loncommon; use Apache::lonnet; use Apache::lontexconvert; -use Apache::lonfeedback; +use Apache::lonfeedback; +use Apache::lonhtmlgateway; use Apache::lonlocal; use Apache::lonhtmlcommon; +use Apache::longroup; +use Apache::lonnavmaps; use HTML::Entities(); use LONCAPA; @@ -78,7 +81,7 @@ sub handler { # ------------------------------------------------------------ Get Query String &Apache::loncommon::get_unprocessed_cgi - ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register', + ($ENV{'QUERY_STRING'},['forceedit','register','todocs', 'origpage','group','ref']); # ----------------------------------------------------- Force menu registration my %addentries; @@ -86,11 +89,11 @@ sub handler { $addentries{'onload'} = "document.location='#newpost';"; } # --------------------------------------------------------------- Force Student - my $forcestudent=''; - if ($env{'form.forcestudent'}) { $forcestudent='student'; } - - my $forceedit=''; - if ($env{'form.forceedit'}) { $forceedit='edit'; } + my ($forceedit,$forcestudent); + $forceedit = $env{'form.forceedit'}; + if (!$forceedit) { + $forcestudent=1; + } my $refarg = ''; if (exists($env{'form.ref'})) { $refarg = 'ref='.$env{'form.ref'}; } @@ -125,21 +128,17 @@ sub handler { # --------------------------------------- There is such a user, get environment if ($target ne 'tex') { - my $course_or_group; + my ($course_or_group,$brcrum); if($group eq '') { $course_or_group="Course"; } else { $course_or_group="Group"; } - my $start_page = - &Apache::loncommon::start_page("$course_or_group Discussion Board",undef, - {'function' => $forcestudent, - 'add_entries' => \%addentries, - 'domain' => $dom, - 'force_register' => - $env{'form.register'}}); - $r->print($start_page); + my $registered; if ($group ne '' && $env{'form.group'} eq $group) { + unless ($env{'form.ref'} eq 'grouplist') { + $registered = $env{'form.register'}; + } my $gpterm = &Apache::loncommon::group_term(); my $ucgpterm = $gpterm; $ucgpterm =~ s/^(\w)/uc($1)/e; @@ -149,10 +148,28 @@ sub handler { if ((ref($groupboards) eq 'ARRAY') && (@{$groupboards} > 0)) { $boardtitle = $$boards{$$groupboards[0]}{'title'}; } - $boardurl .= '?register=1&group='.$group; - $r->print(&groupboard_breadcrumbs($dom,$crs,$group,$refarg,$gpterm, - $ucgpterm,$grp_desc,$boardurl,$boardtitle)); + $boardurl .= '?group='.$group; + if ($registered) { + $boardurl .= '&register='.$env{'form.register'}; + } else { + $brcrum = + &groupboard_breadcrumbs($dom,$crs,$group,$refarg,$gpterm, + $ucgpterm,$grp_desc,$boardurl, + $boardtitle); + } + } else { + $registered = $env{'form.register'}; + $brcrum = []; } + my $start_page = + &Apache::loncommon::start_page("$course_or_group Discussion Board",undef, + {'add_entries' => \%addentries, + 'domain' => $dom, + 'bread_crumbs' => $brcrum, + 'group' => $group, + 'force_register' => $registered} + ); + $r->print($start_page); } my ($allowed); if ($group ne '') { @@ -173,31 +190,8 @@ sub handler { $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); } - my $privileged=$allowed; - if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) { - $forcestudent='student'; - } - if ($target ne 'tex') { $r->print('
'); } if ($forcestudent or $target eq 'tex') { $allowed=0; } - if ($allowed) { - my $query_str = 'forcestudent=1'; - if (($group ne '') && ($env{'form.group'} eq $group)) { - $query_str.='&group='.$group.'&'.$refarg; - } - $r->print( - '

'. - &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes',&mt('Help with filling in text boxes')).'
'.&mt('Show Student View').''. - &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'

'); - } elsif ($privileged and $target ne 'tex') { - my $query_str = 'forceedit=edit'; - if (($group ne '') && ($env{'form.group'} eq $group)) { - $query_str.='&group='.$group.'&'.$refarg; - } - $r->print('' - .&mt('Edit').''); - } - if (($env{'form.uploaddoc.filename'}) && ($env{'form.storeupl'}) && ($allowed)) { if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) { @@ -206,11 +200,11 @@ sub handler { } if ($group ne '') { $syllabus{'uploaded.photourl'}= - &Apache::lonnet::userfileupload('uploaddoc',1, + &Apache::lonnet::userfileupload('uploaddoc','coursedoc', 'bulletin/'.$group.'/'.$marker); } else { $syllabus{'uploaded.photourl'}= - &Apache::lonnet::userfileupload('uploaddoc',1, + &Apache::lonnet::userfileupload('uploaddoc','coursedoc', 'bulletin/'.$marker); } } @@ -220,86 +214,75 @@ sub handler { if (($allowed) && ($env{'form.storesyl'})) { foreach my $syl_field (keys(%syllabusfields)) { my $field=$env{'form.'.$syl_field}; - $field=~s/\s+$//s; - $field=&Apache::lonfeedback::clear_out_html($field,1); + chomp($field); + my $gateway = Apache::lonhtmlgateway->new(); + $field = $gateway->process_incoming_html($field,1); $syllabus{$syl_field}=$field; } $syllabus{'uploaded.lastmodified'}=time; &Apache::lonnet::put('bulletinpage_'.$marker,\%syllabus,$dom,$crs); } -# ---------------------------------------------------------------- Get syllabus +# ---------------------------------------------------------------- Get discussion board if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) { + #Print Topic as Heading + my $titletext=&HTML::Entities::encode($syllabus{'aaa_title'},'<>&"');; + if ($target ne 'tex') { + $r->print('

'.$titletext.'

'); + } else { + $r->print('\\\\\textbf{'.&Apache::lonxml::xmlparse($r,'tex',$titletext).'}\\\\'); + } + #Outputbox and Inputbox for Topic + if ($allowed) { + $r->print('
'); + &Apache::lontemplate::print_start_template($r,&mt('Title'),'LC_Box'); + $r->print($titletext); + $r->print("
"); + &Apache::lontemplate::print_textarea_template($r, $syllabus{'aaa_title'}, + 'aaa_title', Apache::lontemplate->RICH_TEXT_ALWAYS_OFF); + &Apache::lontemplate::print_saveall_template($r); + $r->print("
"); + &Apache::lontemplate::print_end_template($r); + } if ($syllabus{'uploaded.photourl'}) { &Apache::lonnet::allowuploaded('/adm/syllabus', $syllabus{'uploaded.photourl'}); - $r->print(''); } + #Outputbox and Inputbox for Image upload if ($allowed) { + my $message = ''.&mt('Image').''; + &Apache::lontemplate::print_start_template($r, &mt('Upload a Photo'),'LC_Box'); + $r->print($message); + $r->print("

"); $r->print( - ''. - ''. - '

'.&mt('Upload a Photo').'

'. + ''. ''. - ''. - '
'. - ''); - } - foreach my $field (sort(keys(%syllabusfields))) { - if (($syllabus{$field}) || ($allowed)) { - my $message=$syllabus{$field}; - if (&Apache::lonfeedback::newline_to_br($message)) { - &Apache::lonfeedback::newline_to_br(\$message); - } - $message - =~s/(https*\:\/\/[^\s]+)/\\$1\<\/tt\>\<\/a\>/g; - if ($allowed) { - $message=&Apache::lonspeller::markeduptext($message); - } - $message=&Apache::lontexconvert::msgtexconverted($message); - unless ($field eq 'aaa_title') { - if (($field ne 'bbb_content') || ($allowed)) { - if ($target ne 'tex') { - $r->print('

'.$syllabusfields{$field}.'

'); - } else { - $r->print('\\\\\textbf{'.$syllabusfields{$field}.'}\\\\'); - } - } - if ($target ne 'tex') { - $r->print('
'. - $message.'
'); - } else { - $r->print(' '.&Apache::lonxml::xmlparse($r,'tex',$message).' '); - } - if ($allowed) { - $r->print('
'); - } - } else { - if ($target ne 'tex') { - $r->print('

'.$message.'

'); - } else { - $r->print('\\\\\textbf{'.&Apache::lonxml::xmlparse($r,'tex',$message).'}\\\\'); - } - if ($allowed) { - $r->print( - '
'.&mt('Topic').'
'); - } - } - } + ''); + &Apache::lontemplate::print_end_template($r); } + #Image in Student view. + elsif($syllabus{'uploaded.photourl'} && $target ne 'tex'){ + $r->print(''.&mt('Image').''); + } + + my %custom_handlers = ( 'aaa_title' => sub {} ); + &Apache::lontemplate::print_template_fields($r, \%syllabus, \%syllabusfields, + $target, $allowed, Apache::lontemplate->RICH_TEXT_DETECT_HTML, \%custom_handlers); if ($allowed) { $r->print(''); } - if ($target ne 'tex') {$r->print('

');} else {$r->print('\\\\');} + if ($target ne 'tex'){ + $r->print('



'); + } + else { + $r->print(&Apache::lonxml::xmlparse($r,'tex','



')); + } } else { - $r->print('

'.&mt('No page information provided.').'

'); + if ($target ne 'tex') { + $r->print('

'.&mt('No page information provided.').'

'); + } } - if ($target ne 'tex') { $r->print('
'); } + #Lists discussion posts and box for a new discussion post. if ($target ne 'tex') { $r->print(&Apache::lonfeedback::list_discussion ('board','OPEN','bulletin___'.$marker.'___'. @@ -326,25 +309,37 @@ sub groupboard_breadcrumbs { my ($cdom,$cnum,$group,$refarg,$gpterm,$ucgpterm,$description,$boardurl, $boardtitle)= @_; &Apache::lonhtmlcommon::clear_breadcrumbs(); + my $brcrum = []; if ($refarg ne '') { - &Apache::lonhtmlcommon::add_breadcrumb - ({href=>"/adm/coursegroups", - text=>"Groups", - title=>"View course groups"}); - } - &Apache::lonhtmlcommon::add_breadcrumb - ({href=>"/adm/$cdom/$cnum/$group/smppg?$refarg", - text=>"$ucgpterm: $description", - title=>"Go to group's home page"}, - {href=>"/adm/groupboards?group=$group&$refarg", - text=>"Discussion Boards", - title=>"Display group discussion boards"}, - {href=>"$boardurl", - text=>"$boardtitle", - title=>"$boardtitle"}, + push(@{$brcrum}, + {href=>"/adm/coursegroups", + text=>"Groups", + title=>"View course groups"}); + } + my $view_permission = + &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); + my $navmap=Apache::lonnavmaps::navmap->new(); + my $grouppagelink = &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap,$view_permission,$refarg); + if ($grouppagelink) { + push(@{$brcrum}, + {href=>$grouppagelink, + text=>"$ucgpterm: $description", + title=>"Go to group's home page"}, + ); + } else { + push(@{$brcrum}, + {text=>"$ucgpterm: $description",} + ); + } + push(@{$brcrum}, + {href=>"/adm/groupboards?group=$group&$refarg", + text=>"Discussion Boards", + title=>"Display group discussion boards"}, + {href=>"$boardurl", + text=>"$boardtitle", + title=>"$boardtitle"}, ); - my $output .= &Apache::lonhtmlcommon::breadcrumbs(&mt('[_1] discussion boards - [_2]',$gpterm,$description)); - return $output; + return $brcrum; } 1; 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.