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