Annotation of loncom/interface/lonbulletin.pm, revision 1.31

1.1       www         1: # The LearningOnline Network
1.5       www         2: # Bulletin Board Handler
1.1       www         3: #
1.31    ! www         4: # $Id: lonbulletin.pm,v 1.30 2005/06/06 02:29:46 albertel Exp $
1.1       www         5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: package Apache::lonbulletin;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
                     33: use Apache::loncommon;
                     34: use Apache::lonnet;
                     35: use Apache::lontexconvert;
1.6       www        36: use Apache::lonfeedback;
1.15      www        37: use Apache::lonlocal;
1.1       www        38: 
                     39: sub handler {
                     40:     my $r = shift;
1.16      www        41:     &Apache::loncommon::content_type($r,'text/html');
1.1       www        42:     $r->send_http_header;
                     43:     return OK if $r->header_only;
1.29      albertel   44:     my $target=$env{'form.grade_target'};
1.23      sakharuk   45: 
1.1       www        46: # ------------------------------------------------------------ Print the screen
1.23      sakharuk   47:     if ($target ne 'tex') {
1.28      albertel   48: 	my $html=&Apache::lonxml::xmlbegin();
1.23      sakharuk   49: 	$r->print(<<ENDDOCUMENT);
1.28      albertel   50: $html
1.1       www        51: <head>
                     52: <title>The LearningOnline Network with CAPA</title>
                     53: ENDDOCUMENT
1.23      sakharuk   54: } else {
1.29      albertel   55: 	$r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
1.23      sakharuk   56:     }
1.2       www        57:     my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri);
1.1       www        58: # Is this even in a course?
1.29      albertel   59:     unless ($env{'request.course.id'}) {
1.8       www        60: 	$r->print('</head><body>Not in a course</body></html>');
1.1       www        61:         return OK;
                     62:     }
                     63: 
                     64:     $marker=~s/\D//g;
                     65: 
                     66:     unless ($marker) {
                     67: 	$r->print('<body>Invalid call</body>');
                     68:         return OK;
                     69:     }
                     70: 
1.29      albertel   71:     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                     72:     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.1       www        73: 
                     74: # --------------------------------------------------------- The syllabus fields
1.17      www        75:     my %syllabusfields=&Apache::lonlocal::texthash(
1.2       www        76:        'aaa_title'         => 'Topic',
                     77:        'bbb_content'       => 'Task',
1.1       www        78:        'ccc_webreferences' => 'Web References');
                     79: 
1.7       www        80: # ------------------------------------------------------------ Get Query String
                     81:     &Apache::loncommon::get_unprocessed_cgi
1.26      raeburn    82:                 ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register','origpage']);
1.7       www        83: # ----------------------------------------------------- Force menu registration
                     84:     my $addentries='';
1.29      albertel   85:     if ($env{'form.register'}) {
1.26      raeburn    86:        $addentries=' onLoad="'.&Apache::lonmenu::loadevents();
1.29      albertel   87:        if ($env{'form.origpage'}) {
1.26      raeburn    88:            $addentries .= "document.location='#newpost';";
                     89:        }
                     90:        $addentries .= '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
1.7       www        91:        $r->print(&Apache::lonmenu::registerurl(1));
1.29      albertel   92:     } elsif ($env{'form.origpage'}) {
1.26      raeburn    93:          $addentries = "onLoad=\"document.location='#newpost';\"";
1.7       www        94:     }
1.1       www        95: # --------------------------------------------------------------- Force Student
                     96:     my $forcestudent='';
1.29      albertel   97:     if ($env{'form.forcestudent'}) { $forcestudent='student'; }
1.19      www        98: 
                     99:     my $forceedit='';
1.29      albertel  100:     if ($env{'form.forceedit'}) { $forceedit='edit'; }
1.1       www       101: 
                    102:     my %syllabus=&Apache::lonnet::dump('bulletinpage_'.$marker,$dom,$crs);
                    103:        
                    104: # --------------------------------------- There is such a user, get environment
1.23      sakharuk  105:     if ($target ne 'tex') {   
                    106: 	$r->print('</head>'.&Apache::loncommon::bodytag
                    107:                   ("Bulletin Board/Discussion",$forcestudent,$addentries,'',$dom,
1.29      albertel  108:                   $env{'form.register'}));
1.23      sakharuk  109:     }
1.29      albertel  110:     my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
1.1       www       111: 
1.19      www       112:     my $privileged=$allowed;
                    113:     if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {
                    114:  	$forcestudent='student';
                    115:     }
1.27      albertel  116:     if ($target ne 'tex') { $r->print('<table><tr><td>'); }
1.23      sakharuk  117:       if ($forcestudent or $target eq 'tex') { $allowed=0; }
1.1       www       118:  
1.23      sakharuk  119:       if ($allowed) {
1.1       www       120:           $r->print(
1.6       www       121: 	  '<p>'.
1.19      www       122: &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'<br /><a href="'.$r->uri.'?forcestudent=1"><font size="+1">'.&mt('Show Student View').'</font></a>'.
1.5       www       123:  &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>');
1.23      sakharuk  124:       }  elsif ($privileged and $target ne 'tex') {
1.19      www       125: 	  $r->print('<a href="'.$r->uri.'?forceedit=edit"><font size="+1">'
                    126: 		    .&mt('Edit').'</font></a>');
                    127:       } 
                    128: 
1.29      albertel  129:       if (($env{'form.uploaddoc.filename'}) &&
                    130:           ($env{'form.storeupl'}) && ($allowed)) {
                    131:  	  if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
1.20      albertel  132: 	      if ($syllabus{'uploaded.photourl'}) {
                    133: 		  &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
                    134: 	      }
                    135: 	      $syllabus{'uploaded.photourl'}=
                    136: 		  &Apache::lonnet::userfileupload('uploaddoc',1,'bulletin');
1.1       www       137:  	  }
                    138:           $syllabus{'uploaded.lastmodified'}=time;
                    139:           &Apache::lonnet::put('bulletinpage_'.$marker,\%syllabus,$dom,$crs);
                    140:        }
1.29      albertel  141:        if (($allowed) && ($env{'form.storesyl'})) {
1.1       www       142: 	   foreach (keys %syllabusfields) {
1.29      albertel  143:                my $field=$env{'form.'.$_};
1.1       www       144:                $field=~s/\s+$//s;
1.5       www       145:                $field=&Apache::lonfeedback::clear_out_html($field,1);
1.1       www       146: 	       $syllabus{$_}=$field;
                    147:            }
                    148:            $syllabus{'uploaded.lastmodified'}=time;
                    149:            &Apache::lonnet::put('bulletinpage_'.$marker,\%syllabus,$dom,$crs);
                    150:        }
                    151: 
                    152: # ---------------------------------------------------------------- Get syllabus
                    153:     if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
                    154:        if ($syllabus{'uploaded.photourl'}) {
1.20      albertel  155: 	   &Apache::lonnet::allowuploaded('/adm/syllabus',
                    156: 					  $syllabus{'uploaded.photourl'});
                    157: 	   $r->print('<img src="'.$syllabus{'uploaded.photourl'}.
                    158: 	       '" align="right" />');
1.1       www       159:        }
                    160:        if ($allowed) {
                    161:            $r->print(
                    162: 	 '<form method="post" enctype="multipart/form-data">'.
1.19      www       163:  	 '<input type="hidden" name="forceedit" value="edit" />'.
                    164:          '<h3>'.&mt('Upload a Photo').'</h3>'.
1.1       www       165:          '<input type="file" name="uploaddoc" size="50">'.
1.19      www       166:          '<input type="submit" name="storeupl" value="'.&mt('Upload').'">'.
1.1       www       167: 	 '</form><form method="post">');
                    168:        }
                    169:        foreach (sort keys %syllabusfields) {
                    170:           if (($syllabus{$_}) || ($allowed)) {
                    171:               my $message=$syllabus{$_};
1.30      albertel  172: 	      &Apache::lonfeedback::newline_to_br(\$message);
                    173: 	      $message
1.10      www       174:         =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
1.25      www       175: 	      if ($allowed) {
                    176: 		  $message=&Apache::lonspeller::markeduptext($message);
                    177: 	      }
1.31    ! www       178: 	      $message=&Apache::lontexconvert::msgtexconverted($message);
1.25      www       179: 	      unless ($_ eq 'aaa_title') {
1.2       www       180: 		if (($_ ne 'bbb_content') || ($allowed)) {
1.23      sakharuk  181: 		    if ($target ne 'tex') {
                    182: 			$r->print('<h3>'.$syllabusfields{$_}.'</h3>');
                    183: 		    } else {
                    184: 			$r->print('\\\\\textbf{'.$syllabusfields{$_}.'}\\\\');
                    185: 		    }
                    186: 		}
                    187: 		if ($target ne 'tex') {
                    188: 		    $r->print('<blockquote>'.
                    189:                               $message.'</blockquote>');
                    190: 		} else {
                    191: 		    $r->print(' '.&Apache::lonxml::xmlparse($r,'tex',$message).' ');
1.2       www       192: 		}
                    193:                  if ($allowed) {
1.3       www       194:                 $r->print('<br /><textarea cols="80" rows="10" name="'.$_.'">'.
1.1       www       195: 			   $syllabus{$_}.
1.19      www       196:            '</textarea><input type="submit" name="storesyl" value="'.&mt('Store').'" />');
1.2       www       197: 	        }
                    198: 	    } else {
1.23      sakharuk  199:                 if ($target ne 'tex') {
                    200: 		    $r->print('<h1>'.$message.'</h1>');
                    201: 		} else {
                    202: 		    $r->print('\\\\\textbf{'.&Apache::lonxml::xmlparse($r,'tex',$message).'}\\\\');
                    203: 		}
1.2       www       204:                 if ($allowed) {
                    205:                  $r->print(
1.19      www       206:                 '<br />'.&mt('Topic').'<br /><textarea cols="80" rows="2" name="'.$_.'">'.
1.2       www       207: 			   $syllabus{$_}.
1.19      www       208:            '</textarea><input type="submit" name="storesyl" value="'.&mt('Store').'" />');
1.2       www       209:                 }
                    210:             }
1.1       www       211: 	  }
                    212:        }
                    213:        if ($allowed) {
                    214: 	   $r->print('</form>');
                    215:        }
1.23      sakharuk  216:        if ($target ne 'tex') {$r->print('</p>');} else {$r->print('\\\\');}
1.1       www       217:     } else {
1.19      www       218:        $r->print('<p>'.&mt('No page information provided.').'</p>');
1.1       www       219:     }
1.27      albertel  220:     if ($target ne 'tex') { $r->print('</td></tr></table>'); }
1.23      sakharuk  221:     if ($target ne 'tex') {
                    222: 	$r->print(&Apache::lonfeedback::list_discussion
                    223: 	           ('board','OPEN','bulletin___'.$marker.'___'.
                    224: 	            $r->uri));
                    225:     } else {
                    226: 	$r->print('\\\\'.&Apache::lonxml::xmlparse($r,'tex',&Apache::lonfeedback::list_discussion
                    227: 	           ('board','OPEN','bulletin___'.$marker.'___'.
                    228: 	            $r->uri)));
                    229:     }
                    230:     if ($target ne 'tex') {$r->print('</body></html>');} else {$r->print('\end{document}');}
1.1       www       231:     return OK;
                    232: } 
                    233: 
                    234: 1;
                    235: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
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.