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