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

1.1       www         1: # The LearningOnline Network
1.2       www         2: # "About Me" Personal Information
1.1       www         3: #
1.31    ! matthew     4: # $Id: lonaboutme.pm,v 1.30 2004/08/25 18:08:11 sakharuk 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::lonaboutme;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
                     33: use Apache::loncommon;
                     34: use Apache::lonnet;
1.2       www        35: use Apache::lontexconvert;
1.12      www        36: use Apache::lonfeedback;
1.17      www        37: use Apache::lonlocal;
1.1       www        38: 
                     39: sub handler {
                     40:     my $r = shift;
1.17      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.22      sakharuk   44:     my $target=$ENV{'form.grade_target'};
1.1       www        45: # ------------------------------------------------------------ Print the screen
1.22      sakharuk   46:     if ($target ne 'tex') {
                     47: 	$r->print(<<ENDDOCUMENT);
1.1       www        48: <html>
                     49: <head>
                     50: <title>The LearningOnline Network with CAPA</title>
                     51: ENDDOCUMENT
1.22      sakharuk   52:     } else {
                     53: 	$r->print(&Apache::lonprintout::print_latex_header($ENV{'form.latex_type'}));
                     54:     }
1.2       www        55:     my (undef,undef,$cdom,$cnum)=split(/\//,$r->uri);
                     56: # Is this even a user?
                     57:     if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
1.17      www        58: 	$r->print('</head><body>'.
                     59: 		  &mt('No user information available').'</body></html>');
1.2       www        60:         return OK;
                     61:     }
                     62: # --------------------------------------------------------- The syllabus fields
1.17      www        63:     my %syllabusfields=&Apache::lonlocal::texthash(
1.3       www        64:        'aaa_contactinfo'   => 'Contact Information',
                     65:        'bbb_aboutme'       => 'About Me',
                     66:        'ccc_webreferences' => 'Web References');
1.2       www        67: 
1.13      www        68: # ------------------------------------------------------------ Get Query String
                     69:     &Apache::loncommon::get_unprocessed_cgi
                     70:                             ($ENV{'QUERY_STRING'},['forcestudent','register']);
                     71: # ----------------------------------------------------- Force menu registration
                     72:     my $addentries='';
                     73:     if ($ENV{'form.register'}) {
                     74:        $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
                     75: 	   '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
                     76:        $r->print(&Apache::lonmenu::registerurl(1));
                     77:     }
1.2       www        78: # --------------------------------------------------------------- Force Student
                     79:     my $forcestudent='';
                     80:     if ($ENV{'form.forcestudent'}) { $forcestudent='student'; };
                     81:        
                     82: # --------------------------------------- There is such a user, get environment
                     83:     my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
1.22      sakharuk   84:     if ($target ne 'tex') {
                     85: 	$r->print('</head>'.&Apache::loncommon::bodytag
1.14      www        86:                   ("Personal Information",$forcestudent,$addentries,'',$cdom,
                     87:                    $ENV{'form.register'}));
1.22      sakharuk   88: 	$r->print('<h1>'.&Apache::loncommon::plainname($cnum,$cdom).'</h1>');
                     89:     } else {
                     90: 	$r->print('\noindent{\large\textbf{'.&Apache::loncommon::plainname($cnum,$cdom).'}}\\\\\\\\');
                     91:     }
1.6       www        92:     if ($courseenv{'nickname'}) {
                     93:        $r->print(
1.7       albertel   94:          '<h2>&quot;'.$courseenv{'nickname'}.
1.6       www        95:          '&quot;</h2>');
                     96:     }
1.22      sakharuk   97:     if ($target ne 'tex') {
                     98: 	$r->print('<h3>'.$Apache::lonnet::domaindescription{$cdom}.'</h3>'.
                     99: 		  '<p>'.&Apache::loncommon::messagewrapper('Send me a message',$cnum,$cdom).'</p>');
                    100:     } else {
                    101: 	$r->print('\textbf{'.$Apache::lonnet::domaindescription{$cdom}.'}\\\\');
                    102:     }
1.2       www       103:     my %syllabus=&Apache::lonnet::dump('aboutme',$cdom,$cnum);
                    104:     my $allowed=0;
                    105: 
1.1       www       106: # does this user have privileges to post, etc?
1.2       www       107: 
                    108:        $allowed=(($ENV{'user.name'} eq $cnum) && 
                    109: 		 ($ENV{'user.domain'} eq $cdom));
1.23      sakharuk  110:        if ($forcestudent or $target eq 'tex') { $allowed=0; }
1.2       www       111:  
                    112:        if ($allowed) {
1.22      sakharuk  113: 	   if ($target ne 'tex') {
                    114: 	       $r->print('<p><b>'.&mt('Privacy Note').':</b> '.
                    115:                          &mt('The information you submit can be viewed by anybody who is logged into LON-CAPA. Do not provide information that you are not ready to share publicly.').
                    116:                          '</p>'.
                    117:                          &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'</p><p><a href="'.$r->uri.'?forcestudent=1">Show Public View</a>'.
                    118:                          &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>');
                    119: 	   } else {
                    120: 	       $r->print(' \textbf{'.&mt('Privacy Note').'}: '.
                    121:                          &mt('The information you submit can be viewed by anybody who is logged into LON-CAPA. Do not provide information that you are not ready to share publicly.').'\\\\\\\\');
                    122: 	   }
1.2       www       123:       }
1.3       www       124:       if (($ENV{'form.uploaddoc.filename'}) &&
                    125:           ($ENV{'form.storeupl'}) && ($allowed)) {
1.15      www       126:  	  if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
1.24      albertel  127: 	      if ($syllabus{'uploaded.photourl'}) {
                    128: 		  &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
                    129: 	      }
                    130: 	      $syllabus{'uploaded.photourl'}=
                    131:                  &Apache::lonnet::userfileupload('uploaddoc',undef,'aboutme');
1.3       www       132:  	  }
                    133:           $syllabus{'uploaded.lastmodified'}=time;
                    134:           &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum);
                    135:        }
1.2       www       136:        if (($allowed) && ($ENV{'form.storesyl'})) {
                    137: 	   foreach (keys %syllabusfields) {
                    138:                my $field=$ENV{'form.'.$_};
                    139:                $field=~s/\s+$//s;
1.11      www       140:                $field=&Apache::lonfeedback::clear_out_html($field,
                    141:                                                            $ENV{'user.adv'});
1.4       www       142: 	       $syllabus{$_}=$field;
1.2       www       143:            }
                    144:            $syllabus{'uploaded.lastmodified'}=time;
                    145:            &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum);
                    146:        }
                    147: 
                    148: # ---------------------------------------------------------------- Get syllabus
                    149:     if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
1.5       www       150:        my $lastmod=$syllabus{'uploaded.lastmodified'};
1.18      www       151:        $lastmod=($lastmod?&Apache::lonlocal::locallocaltime($lastmod):&mt('never'));
                    152:        $r->print(&mt('Last updated').': '.$lastmod);
1.3       www       153:        if ($syllabus{'uploaded.photourl'}) {
1.24      albertel  154: 	   &Apache::lonnet::allowuploaded('/adm/aboutme',
                    155: 					  $syllabus{'uploaded.photourl'});
1.27      albertel  156: 	   my $image='<img src="'.$syllabus{'uploaded.photourl'}.'"
                    157:                            align="right" />';
                    158: 	   if ($target eq 'tex') {
                    159: 	       $image=&Apache::lonxml::xmlparse($r,'tex',$image);
1.26      sakharuk  160: 	   }
1.27      albertel  161: 	   $r->print($image);
1.3       www       162:        }
1.23      sakharuk  163:        if ($allowed) {
1.3       www       164:            $r->print(
                    165: 	 '<form method="post" enctype="multipart/form-data">'.
1.18      www       166:          '<h3>'.&mt('Upload a Photo').'</h3>'.
1.3       www       167:          '<input type="file" name="uploaddoc" size="50">'.
                    168:          '<input type="submit" name="storeupl" value="Upload">'.
                    169: 	 '</form><form method="post">');
1.2       www       170:        }
                    171:        foreach (sort keys %syllabusfields) {
                    172:           if (($syllabus{$_}) || ($allowed)) {
                    173:               my $message=$syllabus{$_};
                    174:               $message=~s/\n/\<br \/\>/g;
                    175:               $message
                    176:              =~s/(http\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
1.29      www       177: 	      if ($allowed) {
                    178: 		  $message=&Apache::lonspeller::markeduptext($message);
                    179: 	      }
1.2       www       180: 	      $message=&Apache::lontexconvert::msgtexconverted($message);
1.22      sakharuk  181: 	      if ($target ne 'tex') {
                    182: 		  $r->print('<h3>'.$syllabusfields{$_}.'</h3><blockquote>'.
                    183:                             $message.'</blockquote>');
                    184: 	      } else {
                    185: 		     $r->print('\\\\\textbf{'.$syllabusfields{$_}.'}\\\\'.
1.25      sakharuk  186: 			       &Apache::lonxml::xmlparse($r,'tex',$message).'\\\\');
1.22      sakharuk  187: 	      }
1.23      sakharuk  188:               if ($allowed) {
1.2       www       189:                  $r->print('<br /><textarea cols="80" rows="6" name="'.$_.'">'.
                    190: 			   $syllabus{$_}.
1.17      www       191:            '</textarea><input type="submit" name="storesyl" value="'.
                    192: 			   &mt('Store').'" />');
1.2       www       193: 	      }
                    194: 	  }
                    195:        }
1.23      sakharuk  196:        if ($allowed) {
1.2       www       197: 	   $r->print('</form>');
                    198:        }
1.22      sakharuk  199:        if ($target ne 'tex') {$r->print('</p>');} else {$r->print('\\\\');}
1.2       www       200:     } else {
1.17      www       201:        $r->print('<p>'.&mt('No personal information provided').'.</p>');
1.8       www       202:     }
                    203:     if ($ENV{'request.course.id'}) {
                    204: 	if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
1.22      sakharuk  205: 	    if ($target ne 'tex') {
1.30      sakharuk  206: 		$r->print('<a name="coursecomment" />');
1.22      sakharuk  207: 		$r->print('<hr /><h3>'.
                    208:                           &mt('User Notes, Records of Face-To-Face Discussions, and Critical Messages in Course').'</h3>'.
                    209:                           &mt('Shared by course faculty and staff').
                    210:                           &Apache::loncommon::help_open_topic("Course_Face_To_Face_Records,Course_Critical_Message").
1.19      www       211: '<br />');
1.31    ! matthew   212:                 &Apache::lonmsg::disfacetoface($r,$cnum,$cdom);
        !           213:                 $r->print('<hr />');
        !           214:                 if (&Apache::lonnet::allowed('vsa',
        !           215:                                              $ENV{'request.course.id'}) ||
        !           216:                     &Apache::lonnet::allowed('vsa',
        !           217:                                              $ENV{'request.course.id'}.'/'.
        !           218:                                              $ENV{'request.course.sec'})) {
        !           219:                     $r->print(&Apache::loncommon::track_student_link
        !           220:                               ('View recent activity by this student',
        !           221:                                $cnum,$cdom).('&nbsp;'x2));
        !           222:                 }
        !           223:                 $r->print(&Apache::loncommon::noteswrapper('Add Records',$cnum,$cdom));
1.22      sakharuk  224: 	    } else {
                    225: 		$r->print('\\\\\textbf{'.&mt('User Notes, Records of Face-To-Face Discussions, and Critical Messages in Course').'}\\\\'.&mt('Shared by course faculty and staff').'\\\\\\\\');
1.23      sakharuk  226: 		&Apache::lonmsg::disfacetoface($r,$cnum,$cdom);
1.22      sakharuk  227: 	    }
1.8       www       228:         }
1.1       www       229:     }
1.22      sakharuk  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>