Diff for /loncom/interface/lonbulletin.pm between versions 1.24 and 1.32

version 1.24, 2004/05/10 18:44:40 version 1.32, 2006/03/21 20:31:08
Line 41  sub handler { Line 41  sub handler {
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
     my $target=$ENV{'form.grade_target'};      my $target=$env{'form.grade_target'};
   
   
 #    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous']);  
 # ------------------------------------------------------------ Print the screen  # ------------------------------------------------------------ Print the screen
     if ($target ne 'tex') {      if ($target eq 'tex') {
  $r->print(<<ENDDOCUMENT);   $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
 <html>  
 <head>  
 <title>The LearningOnline Network with CAPA</title>  
 ENDDOCUMENT  
 } else {  
  $r->print(&Apache::lonprintout::print_latex_header($ENV{'form.latex_type'}));  
     }      }
     my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri);      my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri);
 # Is this even in a course?  # Is this even in a course?
     unless ($ENV{'request.course.id'}) {      if (!$env{'request.course.id'}) {
  $r->print('</head><body>Not in a course</body></html>');   $r->print(&Apache::loncommon::start_page('Not in a course').
     &mt('Not in a course').
     &Apache::loncommon::end_page());
         return OK;          return OK;
     }      }
   
     $marker=~s/\D//g;      $marker=~s/\D//g;
   
     unless ($marker) {      if (!$marker) {
  $r->print('<body>Invalid call</body>');   $r->print(&Apache::loncommon::start_page('Invalid Call').
     &mt('Invalid Call').
     &Apache::loncommon::end_page());
         return OK;          return OK;
     }      }
   
     my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};      my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};      my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
   
 # --------------------------------------------------------- The syllabus fields  # --------------------------------------------------------- The syllabus fields
     my %syllabusfields=&Apache::lonlocal::texthash(      my %syllabusfields=&Apache::lonlocal::texthash(
Line 80  ENDDOCUMENT Line 76  ENDDOCUMENT
   
 # ------------------------------------------------------------ Get Query String  # ------------------------------------------------------------ Get Query String
     &Apache::loncommon::get_unprocessed_cgi      &Apache::loncommon::get_unprocessed_cgi
                 ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register']);                  ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register','origpage']);
 # ----------------------------------------------------- Force menu registration  # ----------------------------------------------------- Force menu registration
     my $addentries='';      my $addentries='';
     if ($ENV{'form.register'}) {      if ($env{'form.register'}) {
        $addentries=' onLoad="'.&Apache::lonmenu::loadevents().         $addentries=' onLoad="'.&Apache::lonmenu::loadevents();
    '" onUnload="'.&Apache::lonmenu::unloadevents().'"';         if ($env{'form.origpage'}) {
              $addentries .= "document.location='#newpost';";
          }
          $addentries .= '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
        $r->print(&Apache::lonmenu::registerurl(1));         $r->print(&Apache::lonmenu::registerurl(1));
       } elsif ($env{'form.origpage'}) {
            $addentries = "onLoad=\"document.location='#newpost';\"";
     }      }
 # --------------------------------------------------------------- Force Student  # --------------------------------------------------------------- Force Student
     my $forcestudent='';      my $forcestudent='';
     if ($ENV{'form.forcestudent'}) { $forcestudent='student'; }      if ($env{'form.forcestudent'}) { $forcestudent='student'; }
   
     my $forceedit='';      my $forceedit='';
     if ($ENV{'form.forceedit'}) { $forceedit='edit'; }      if ($env{'form.forceedit'}) { $forceedit='edit'; }
   
     my %syllabus=&Apache::lonnet::dump('bulletinpage_'.$marker,$dom,$crs);      my %syllabus=&Apache::lonnet::dump('bulletinpage_'.$marker,$dom,$crs);
                 
 # --------------------------------------- There is such a user, get environment  # --------------------------------------- There is such a user, get environment
     if ($target ne 'tex') {         if ($target ne 'tex') {  
  $r->print('</head>'.&Apache::loncommon::bodytag   my $start_page =
                   ("Bulletin Board/Discussion",$forcestudent,$addentries,'',$dom,      &Apache::loncommon::start_page("Bulletin Board/Discussion",undef,
                   $ENV{'form.register'}));     {'function'       => $forcestudent,
       'add_entries'    => $addentries,
       'domain'         => $domain,
       'force_register' =>
    $env{'form.register'}});
    $r->print($start_page);
     }      }
     my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});      my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
   
     my $privileged=$allowed;      my $privileged=$allowed;
     if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {      if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {
   $forcestudent='student';    $forcestudent='student';
     }      }
       if ($target ne 'tex') { $r->print('<table><tr><td>'); }
       if ($forcestudent or $target eq 'tex') { $allowed=0; }        if ($forcestudent or $target eq 'tex') { $allowed=0; }
     
       if ($allowed) {        if ($allowed) {
Line 122  ENDDOCUMENT Line 128  ENDDOCUMENT
     .&mt('Edit').'</font></a>');      .&mt('Edit').'</font></a>');
       }         } 
   
       if (($ENV{'form.uploaddoc.filename'}) &&        if (($env{'form.uploaddoc.filename'}) &&
           ($ENV{'form.storeupl'}) && ($allowed)) {            ($env{'form.storeupl'}) && ($allowed)) {
    if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {     if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
       if ($syllabus{'uploaded.photourl'}) {        if ($syllabus{'uploaded.photourl'}) {
   &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});    &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
       }        }
Line 134  ENDDOCUMENT Line 140  ENDDOCUMENT
           $syllabus{'uploaded.lastmodified'}=time;            $syllabus{'uploaded.lastmodified'}=time;
           &Apache::lonnet::put('bulletinpage_'.$marker,\%syllabus,$dom,$crs);            &Apache::lonnet::put('bulletinpage_'.$marker,\%syllabus,$dom,$crs);
        }         }
        if (($allowed) && ($ENV{'form.storesyl'})) {         if (($allowed) && ($env{'form.storesyl'})) {
    foreach (keys %syllabusfields) {     foreach (keys %syllabusfields) {
                my $field=$ENV{'form.'.$_};                 my $field=$env{'form.'.$_};
                $field=~s/\s+$//s;                 $field=~s/\s+$//s;
                $field=&Apache::lonfeedback::clear_out_html($field,1);                 $field=&Apache::lonfeedback::clear_out_html($field,1);
        $syllabus{$_}=$field;         $syllabus{$_}=$field;
Line 165  ENDDOCUMENT Line 171  ENDDOCUMENT
        foreach (sort keys %syllabusfields) {         foreach (sort keys %syllabusfields) {
           if (($syllabus{$_}) || ($allowed)) {            if (($syllabus{$_}) || ($allowed)) {
               my $message=$syllabus{$_};                my $message=$syllabus{$_};
               $message=~s/\n/\<br \/\>/g;        &Apache::lonfeedback::newline_to_br(\$message);
               $message        $message
         =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;          =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
         if ($allowed) {
     $message=&Apache::lonspeller::markeduptext($message);
         }
       $message=&Apache::lontexconvert::msgtexconverted($message);        $message=&Apache::lontexconvert::msgtexconverted($message);
             unless ($_ eq 'aaa_title') {        unless ($_ eq 'aaa_title') {
  if (($_ ne 'bbb_content') || ($allowed)) {   if (($_ ne 'bbb_content') || ($allowed)) {
     if ($target ne 'tex') {      if ($target ne 'tex') {
  $r->print('<h3>'.$syllabusfields{$_}.'</h3>');   $r->print('<h3>'.$syllabusfields{$_}.'</h3>');
Line 210  ENDDOCUMENT Line 219  ENDDOCUMENT
     } else {      } else {
        $r->print('<p>'.&mt('No page information provided.').'</p>');         $r->print('<p>'.&mt('No page information provided.').'</p>');
     }      }
       if ($target ne 'tex') { $r->print('</td></tr></table>'); }
     if ($target ne 'tex') {      if ($target ne 'tex') {
  $r->print(&Apache::lonfeedback::list_discussion   $r->print(&Apache::lonfeedback::list_discussion
            ('board','OPEN','bulletin___'.$marker.'___'.             ('board','OPEN','bulletin___'.$marker.'___'.
Line 219  ENDDOCUMENT Line 229  ENDDOCUMENT
            ('board','OPEN','bulletin___'.$marker.'___'.             ('board','OPEN','bulletin___'.$marker.'___'.
             $r->uri)));              $r->uri)));
     }      }
     if ($target ne 'tex') {$r->print('</body></html>');} else {$r->print('\end{document}');}      if ($target ne 'tex') {
    $r->print(&Apache::loncommon::end_page());
       } else {
    $r->print('\end{document}');
       }
     return OK;      return OK;
 }   } 
   

Removed from v.1.24  
changed lines
  Added in v.1.32


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>