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

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

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