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

1.1       www         1: # The LearningOnline Network
1.2       www         2: # "About Me" Personal Information
1.1       www         3: #
1.21    ! albertel    4: # $Id: lonaboutme.pm,v 1.20 2004/04/29 17:25:11 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.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;
                     44: 
                     45: # ------------------------------------------------------------ Print the screen
                     46:     $r->print(<<ENDDOCUMENT);
                     47: <html>
                     48: <head>
                     49: <title>The LearningOnline Network with CAPA</title>
                     50: ENDDOCUMENT
1.2       www        51:     my (undef,undef,$cdom,$cnum)=split(/\//,$r->uri);
                     52: # Is this even a user?
                     53:     if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
1.17      www        54: 	$r->print('</head><body>'.
                     55: 		  &mt('No user information available').'</body></html>');
1.2       www        56:         return OK;
                     57:     }
                     58: # --------------------------------------------------------- The syllabus fields
1.17      www        59:     my %syllabusfields=&Apache::lonlocal::texthash(
1.3       www        60:        'aaa_contactinfo'   => 'Contact Information',
                     61:        'bbb_aboutme'       => 'About Me',
                     62:        'ccc_webreferences' => 'Web References');
1.2       www        63: 
1.13      www        64: # ------------------------------------------------------------ Get Query String
                     65:     &Apache::loncommon::get_unprocessed_cgi
                     66:                             ($ENV{'QUERY_STRING'},['forcestudent','register']);
                     67: # ----------------------------------------------------- Force menu registration
                     68:     my $addentries='';
                     69:     if ($ENV{'form.register'}) {
                     70:        $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
                     71: 	   '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
                     72:        $r->print(&Apache::lonmenu::registerurl(1));
                     73:     }
1.2       www        74: # --------------------------------------------------------------- Force Student
                     75:     my $forcestudent='';
                     76:     if ($ENV{'form.forcestudent'}) { $forcestudent='student'; };
                     77:        
                     78: # --------------------------------------- There is such a user, get environment
                     79:     my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
1.13      www        80:     $r->print('</head>'.&Apache::loncommon::bodytag
1.14      www        81:                   ("Personal Information",$forcestudent,$addentries,'',$cdom,
                     82:                    $ENV{'form.register'}));
1.6       www        83:     $r->print('<h1>'.&Apache::loncommon::plainname($cnum,$cdom).'</h1>');
                     84:     if ($courseenv{'nickname'}) {
                     85:        $r->print(
1.7       albertel   86:          '<h2>&quot;'.$courseenv{'nickname'}.
1.6       www        87:          '&quot;</h2>');
                     88:     }
                     89:     $r->print('<h3>'.$Apache::lonnet::domaindescription{$cdom}.'</h3>'.
1.4       www        90:     '<p>'.&Apache::loncommon::messagewrapper('Send me a message',$cnum,$cdom).
                     91:     '</p>');
1.2       www        92:     my %syllabus=&Apache::lonnet::dump('aboutme',$cdom,$cnum);
                     93:     my $allowed=0;
                     94: 
1.1       www        95: # does this user have privileges to post, etc?
1.2       www        96: 
                     97:        $allowed=(($ENV{'user.name'} eq $cnum) && 
                     98: 		 ($ENV{'user.domain'} eq $cdom));
                     99:        if ($forcestudent) { $allowed=0; }
                    100:  
                    101:        if ($allowed) {
1.17      www       102:           $r->print('<p><b>'.&mt('Privacy Note').':</b> '.
                    103: &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.').
                    104: '</p>'.
1.12      www       105: &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>'.
1.11      www       106:  &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>');
1.2       www       107:       }
1.3       www       108:       if (($ENV{'form.uploaddoc.filename'}) &&
                    109:           ($ENV{'form.storeupl'}) && ($allowed)) {
1.15      www       110:  	  if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
1.21    ! albertel  111: 	      if ($syllabus{'uploaded.photourl'}) {
        !           112: 		  &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
        !           113: 	      }
        !           114: 	      $syllabus{'uploaded.photourl'}=
        !           115:                  &Apache::lonnet::userfileupload('uploaddoc',undef,'aboutme');
1.3       www       116:  	  }
                    117:           $syllabus{'uploaded.lastmodified'}=time;
                    118:           &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum);
                    119:        }
1.2       www       120:        if (($allowed) && ($ENV{'form.storesyl'})) {
                    121: 	   foreach (keys %syllabusfields) {
                    122:                my $field=$ENV{'form.'.$_};
                    123:                $field=~s/\s+$//s;
1.11      www       124:                $field=&Apache::lonfeedback::clear_out_html($field,
                    125:                                                            $ENV{'user.adv'});
1.4       www       126: 	       $syllabus{$_}=$field;
1.2       www       127:            }
                    128:            $syllabus{'uploaded.lastmodified'}=time;
                    129:            &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum);
                    130:        }
                    131: 
                    132: # ---------------------------------------------------------------- Get syllabus
                    133:     if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
1.5       www       134:        my $lastmod=$syllabus{'uploaded.lastmodified'};
1.18      www       135:        $lastmod=($lastmod?&Apache::lonlocal::locallocaltime($lastmod):&mt('never'));
                    136:        $r->print(&mt('Last updated').': '.$lastmod);
1.3       www       137:        if ($syllabus{'uploaded.photourl'}) {
1.20      albertel  138: 	   &Apache::lonnet::allowuploaded('/adm/aboutme',
                    139: 					  $syllabus{'uploaded.photourl'});
                    140: 	   $r->print('<img src="'.$syllabus{'uploaded.photourl'}.
1.3       www       141:              '" align="right" />');
                    142:        }
1.2       www       143:        if ($allowed) {
1.3       www       144:            $r->print(
                    145: 	 '<form method="post" enctype="multipart/form-data">'.
1.18      www       146:          '<h3>'.&mt('Upload a Photo').'</h3>'.
1.3       www       147:          '<input type="file" name="uploaddoc" size="50">'.
                    148:          '<input type="submit" name="storeupl" value="Upload">'.
                    149: 	 '</form><form method="post">');
1.2       www       150:        }
                    151:        foreach (sort keys %syllabusfields) {
                    152:           if (($syllabus{$_}) || ($allowed)) {
                    153:               my $message=$syllabus{$_};
                    154:               $message=~s/\n/\<br \/\>/g;
                    155:               $message
                    156:              =~s/(http\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
                    157: 	      $message=&Apache::lontexconvert::msgtexconverted($message);
                    158:               $r->print('<h3>'.$syllabusfields{$_}.'</h3><blockquote>'.
                    159:                         $message.'</blockquote>');
                    160:               if ($allowed) {
                    161:                  $r->print('<br /><textarea cols="80" rows="6" name="'.$_.'">'.
                    162: 			   $syllabus{$_}.
1.17      www       163:            '</textarea><input type="submit" name="storesyl" value="'.
                    164: 			   &mt('Store').'" />');
1.2       www       165: 	      }
                    166: 	  }
                    167:        }
                    168:        if ($allowed) {
                    169: 	   $r->print('</form>');
                    170:        }
                    171:        $r->print('</p>');
                    172:     } else {
1.17      www       173:        $r->print('<p>'.&mt('No personal information provided').'.</p>');
1.8       www       174:     }
                    175:     if ($ENV{'request.course.id'}) {
                    176: 	if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
1.17      www       177:             $r->print('<hr /><h3>'.
                    178: &mt('User Notes, Records of Face-To-Face Discussions, and Critical Messages in Course').'</h3>'.
1.19      www       179: &mt('Shared by course faculty and staff').
                    180: &Apache::loncommon::help_open_topic("Course_Face_To_Face_Records,Course_Critical_Message").
                    181: '<br />');
1.8       www       182: 	    &Apache::lonmsg::disfacetoface($r,$cnum,$cdom);
1.9       www       183:             $r->print(&Apache::loncommon::noteswrapper('Add Records',$cnum,$cdom));
1.8       www       184:         }
1.1       www       185:     }
                    186:     $r->print('</body></html>');
                    187:     return OK;
                    188: } 
                    189: 
                    190: 1;
                    191: __END__

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