1: # The LearningOnline Network
2: # "About Me" Personal Information
3: #
4: # $Id: lonaboutme.pm,v 1.39 2005/11/18 13:35:30 www Exp $
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;
35: use Apache::lontexconvert;
36: use Apache::lonfeedback;
37: use Apache::lonrss();
38: use Apache::lonlocal;
39:
40: sub handler {
41: my $r = shift;
42: &Apache::loncommon::content_type($r,'text/html');
43: $r->send_http_header;
44: return OK if $r->header_only;
45: my $target=$env{'form.grade_target'};
46: # ------------------------------------------------------------ Print the screen
47: if ($target ne 'tex') {
48: my $html=&Apache::lonxml::xmlbegin();
49: $r->print(<<ENDDOCUMENT);
50: $html
51: <head>
52: <title>The LearningOnline Network with CAPA</title>
53: ENDDOCUMENT
54: } else {
55: $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
56: }
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') {
60: $r->print('</head><body>'.
61: &mt('No user information available').'</body></html>');
62: return OK;
63: }
64: # --------------------------------------------------------- The syllabus fields
65: my %syllabusfields=&Apache::lonlocal::texthash(
66: 'aaa_contactinfo' => 'Contact Information',
67: 'bbb_aboutme' => 'About Me',
68: 'ccc_webreferences' => 'Web References');
69:
70: # ------------------------------------------------------------ Get Query String
71: &Apache::loncommon::get_unprocessed_cgi
72: ($ENV{'QUERY_STRING'},['forcestudent','register']);
73: # ----------------------------------------------------- Force menu registration
74: my $addentries='';
75: if ($env{'form.register'}) {
76: $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
77: '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
78: $r->print(&Apache::lonmenu::registerurl(1));
79: }
80: # --------------------------------------------------------------- Force Student
81: my $forcestudent='';
82: if ($env{'form.forcestudent'}) { $forcestudent='student'; };
83:
84: # --------------------------------------- There is such a user, get environment
85: my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
86: if ($target ne 'tex') {
87: $r->print('</head>'.&Apache::loncommon::bodytag
88: ("Personal Information",$forcestudent,$addentries,'',$cdom,
89: $env{'form.register'}));
90: $r->print('<h1>'.&Apache::loncommon::plainname($cnum,$cdom).'</h1>');
91: } else {
92: $r->print('\noindent{\large\textbf{'.&Apache::loncommon::plainname($cnum,$cdom).'}}\\\\\\\\');
93: }
94: if ($courseenv{'nickname'}) {
95: $r->print(
96: '<h2>"'.$courseenv{'nickname'}.
97: '"</h2>');
98: }
99: if ($target ne 'tex') {
100: $r->print('<h3>'.$Apache::lonnet::domaindescription{$cdom}.'</h3>'.
101: '<p>'.&Apache::loncommon::messagewrapper('Send me a message',$cnum,$cdom).'</p>'.&Apache::lonrss::advertisefeeds($cnum,$cdom));
102: } else {
103: $r->print('\textbf{'.$Apache::lonnet::domaindescription{$cdom}.'}\\\\');
104: }
105: my %syllabus=&Apache::lonnet::dump('aboutme',$cdom,$cnum);
106: my $allowed=0;
107:
108: # does this user have privileges to post, etc?
109:
110: my $privleged=$allowed=(($env{'user.name'} eq $cnum) &&
111: ($env{'user.domain'} eq $cdom));
112: if ($forcestudent or $target eq 'tex') { $allowed=0; }
113:
114: if ($allowed) {
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: }
124: if (($env{'form.uploaddoc.filename'}) &&
125: ($env{'form.storeupl'}) && ($allowed)) {
126: if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
127: if ($syllabus{'uploaded.photourl'}) {
128: &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
129: }
130: $syllabus{'uploaded.photourl'}=
131: &Apache::lonnet::userfileupload('uploaddoc',undef,'aboutme');
132: }
133: $syllabus{'uploaded.lastmodified'}=time;
134: &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum);
135: }
136: if ($allowed && $env{'form.delupl'}) {
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: }
143: if (($allowed) && ($env{'form.storesyl'})) {
144: foreach (keys %syllabusfields) {
145: my $field=$env{'form.'.$_};
146: $field=~s/\s+$//s;
147: $field=&Apache::lonfeedback::clear_out_html($field,
148: $env{'user.adv'});
149: $syllabus{$_}=$field;
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)) {
157: my $lastmod=$syllabus{'uploaded.lastmodified'};
158: $lastmod=($lastmod?&Apache::lonlocal::locallocaltime($lastmod):&mt('never'));
159: $r->print(&mt('Last updated').': '.$lastmod);
160: if ($syllabus{'uploaded.photourl'}) {
161: &Apache::lonnet::allowuploaded('/adm/aboutme',
162: $syllabus{'uploaded.photourl'});
163: my $image=
164: qq{<img src="$syllabus{'uploaded.photourl'}" align="right" />};
165: if ($target eq 'tex') {
166: $image=&Apache::lonxml::xmlparse($r,'tex',$image);
167: }
168: $r->print($image);
169: }
170: if ($allowed) {
171: $r->print(
172: '<form method="post">
173: <input type="submit" name="delupl" value="Delete Photo" />
174: </form>'.
175: '<form method="post" enctype="multipart/form-data">'.
176: '<h3>'.&mt('Upload a Photo').'</h3>'.
177: '<input type="file" name="uploaddoc" size="50">'.
178: '<input type="submit" name="storeupl" value="Upload">'.
179: '</form><form method="post">');
180:
181: }
182: foreach (sort keys %syllabusfields) {
183: if (($syllabus{$_}) || ($allowed)) {
184: my $message=$syllabus{$_};
185: &Apache::lonfeedback::newline_to_br(\$message);
186: $message
187: =~s/(http\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
188: if ($allowed) {
189: $message=&Apache::lonspeller::markeduptext($message);
190: }
191: $message=&Apache::lontexconvert::msgtexconverted($message);
192: if ($target ne 'tex') {
193: $r->print('<h3>'.$syllabusfields{$_}.'</h3><blockquote>'.
194: $message.'</blockquote>');
195: } else {
196: $r->print('\\\\\textbf{'.$syllabusfields{$_}.'}\\\\'.
197: &Apache::lonxml::xmlparse($r,'tex',$message).'\\\\');
198: }
199: if ($allowed) {
200: $r->print('<br /><textarea cols="80" rows="6" name="'.$_.'">'.
201: $syllabus{$_}.
202: '</textarea><input type="submit" name="storesyl" value="'.
203: &mt('Store').'" />');
204: }
205: }
206: }
207: if ($allowed) {
208: $r->print('</form>');
209: }
210: if ($target ne 'tex') {$r->print('</p>');} else {$r->print('\\\\');}
211: } else {
212: $r->print('<p>'.&mt('No personal information provided').'.</p>');
213: }
214: if ($env{'request.course.id'}) {
215: if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
216: if ($target ne 'tex') {
217: $r->print('<a name="coursecomment" />');
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").
222: '<br />');
223: &Apache::lonmsg::disfacetoface($r,$cnum,$cdom);
224: $r->print('<hr />');
225: if (&Apache::lonnet::allowed('vsa',
226: $env{'request.course.id'}) ||
227: &Apache::lonnet::allowed('vsa',
228: $env{'request.course.id'}.'/'.
229: $env{'request.course.sec'})) {
230: $r->print(&Apache::loncommon::track_student_link
231: ('View recent activity by this student',
232: $cnum,$cdom).(' 'x2));
233: }
234: $r->print(&Apache::loncommon::noteswrapper('Add Records',$cnum,$cdom));
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').'\\\\\\\\');
237: &Apache::lonmsg::disfacetoface($r,$cnum,$cdom);
238: }
239: }
240: }
241: if ($target ne 'tex') {$r->print('</body></html>');} else {$r->print('\end{document}');}
242: return OK;
243: }
244:
245: 1;
246: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>