Annotation of loncom/interface/lonaboutme.pm, revision 1.12
1.1 www 1: # The LearningOnline Network
1.2 www 2: # "About Me" Personal Information
1.1 www 3: #
1.12 ! www 4: # $Id: lonaboutme.pm,v 1.11 2003/02/10 16:22:28 www 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.1 www 37:
38: sub handler {
39: my $r = shift;
40: $r->content_type('text/html');
41: $r->send_http_header;
42: return OK if $r->header_only;
43:
44: # ------------------------------------------------------------ Print the screen
45: $r->print(<<ENDDOCUMENT);
46: <html>
47: <head>
48: <title>The LearningOnline Network with CAPA</title>
49: </head>
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') {
54: $r->print('<body>No user information available</body>');
55: return OK;
56: }
57: # --------------------------------------------------------- The syllabus fields
58: my %syllabusfields=(
1.3 www 59: 'aaa_contactinfo' => 'Contact Information',
60: 'bbb_aboutme' => 'About Me',
61: 'ccc_webreferences' => 'Web References');
1.2 www 62:
63: # --------------------------------------------------------------- Force Student
64: &Apache::loncommon::get_unprocessed_cgi
65: ($ENV{'QUERY_STRING'},['forcestudent']);
66: my $forcestudent='';
67: if ($ENV{'form.forcestudent'}) { $forcestudent='student'; };
68:
69: # --------------------------------------- There is such a user, get environment
70: my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
71: $r->print(&Apache::loncommon::bodytag
72: ("Personal Information",$forcestudent,'','',$cdom));
1.6 www 73: $r->print('<h1>'.&Apache::loncommon::plainname($cnum,$cdom).'</h1>');
74: if ($courseenv{'nickname'}) {
75: $r->print(
1.7 albertel 76: '<h2>"'.$courseenv{'nickname'}.
1.6 www 77: '"</h2>');
78: }
79: $r->print('<h3>'.$Apache::lonnet::domaindescription{$cdom}.'</h3>'.
1.4 www 80: '<p>'.&Apache::loncommon::messagewrapper('Send me a message',$cnum,$cdom).
81: '</p>');
1.2 www 82: my %syllabus=&Apache::lonnet::dump('aboutme',$cdom,$cnum);
83: my $allowed=0;
84:
1.1 www 85: # does this user have privileges to post, etc?
1.2 www 86:
87: $allowed=(($ENV{'user.name'} eq $cnum) &&
88: ($ENV{'user.domain'} eq $cdom));
89: if ($forcestudent) { $allowed=0; }
90:
91: if ($allowed) {
1.4 www 92: $r->print('<p><b>Privacy Note:</b> 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 publically.</p>'.
1.12 ! www 93: &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 94: &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>');
1.2 www 95: }
1.3 www 96: if (($ENV{'form.uploaddoc.filename'}) &&
97: ($ENV{'form.storeupl'}) && ($allowed)) {
98: if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/) {
99: $syllabus{'uploaded.photourl'}=
100: &Apache::lonnet::userfileupload('uploaddoc');
101: }
102: $syllabus{'uploaded.lastmodified'}=time;
103: &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum);
104: }
1.2 www 105: if (($allowed) && ($ENV{'form.storesyl'})) {
106: foreach (keys %syllabusfields) {
107: my $field=$ENV{'form.'.$_};
108: $field=~s/\s+$//s;
1.11 www 109: $field=&Apache::lonfeedback::clear_out_html($field,
110: $ENV{'user.adv'});
1.4 www 111: $syllabus{$_}=$field;
1.2 www 112: }
113: $syllabus{'uploaded.lastmodified'}=time;
114: &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum);
115: }
116:
117: # ---------------------------------------------------------------- Get syllabus
118: if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
1.5 www 119: my $lastmod=$syllabus{'uploaded.lastmodified'};
120: $lastmod=($lastmod?localtime($lastmod):'never');
121: $r->print('Last updated: '.$lastmod);
1.3 www 122: if ($syllabus{'uploaded.photourl'}) {
123: $r->print('<img src="'.
124: &Apache::lonnet::tokenwrapper($syllabus{'uploaded.photourl'}).
125: '" align="right" />');
126: }
1.2 www 127: if ($allowed) {
1.3 www 128: $r->print(
129: '<form method="post" enctype="multipart/form-data">'.
130: '<h3>Upload a Photo</h3>'.
131: '<input type="file" name="uploaddoc" size="50">'.
132: '<input type="submit" name="storeupl" value="Upload">'.
133: '</form><form method="post">');
1.2 www 134: }
135: foreach (sort keys %syllabusfields) {
136: if (($syllabus{$_}) || ($allowed)) {
137: my $message=$syllabus{$_};
138: $message=~s/\n/\<br \/\>/g;
139: $message
140: =~s/(http\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
141: $message=&Apache::lontexconvert::msgtexconverted($message);
142: $r->print('<h3>'.$syllabusfields{$_}.'</h3><blockquote>'.
143: $message.'</blockquote>');
144: if ($allowed) {
145: $r->print('<br /><textarea cols="80" rows="6" name="'.$_.'">'.
146: $syllabus{$_}.
147: '</textarea><input type="submit" name="storesyl" value="Store" />');
148: }
149: }
150: }
151: if ($allowed) {
152: $r->print('</form>');
153: }
154: $r->print('</p>');
155: } else {
1.3 www 156: $r->print('<p>No personal information provided.</p>');
1.8 www 157: }
158: if ($ENV{'request.course.id'}) {
159: if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
1.9 www 160: $r->print('<hr /><h3>User Notes, Records of Face-To-Face Discussions, and Critical Messages in Course</h3>Shared by course faculty and staff<br />');
1.8 www 161: &Apache::lonmsg::disfacetoface($r,$cnum,$cdom);
1.9 www 162: $r->print(&Apache::loncommon::noteswrapper('Add Records',$cnum,$cdom));
1.8 www 163: }
1.1 www 164: }
165: $r->print('</body></html>');
166: return OK;
167: }
168:
169: 1;
170: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>