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