--- loncom/interface/lonaboutme.pm 2008/12/16 09:22:14 1.86 +++ loncom/interface/lonaboutme.pm 2023/12/28 15:57:27 1.168 @@ -1,7 +1,7 @@ # The LearningOnline Network -# "About Me" Personal Information +# Personal Information Page # -# $Id: lonaboutme.pm,v 1.86 2008/12/16 09:22:14 schualex Exp $ +# $Id: lonaboutme.pm,v 1.168 2023/12/28 15:57:27 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,8 +50,6 @@ described at http://www.lon-capa.org. =item handler() -=item in_course() - =item aboutme_info() =item print_portfiles_link() @@ -80,12 +78,15 @@ use Apache::Constants qw(:common); use Apache::loncommon; use Apache::lonnet; use Apache::lontexconvert; -use Apache::lonfeedback; +use Apache::lonhtmlgateway; use Apache::lonrss(); use Apache::lonlocal; use Apache::lonmsgdisplay(); use Apache::lontemplate; +use Apache::longroup; +use Apache::lonhtmlcommon(); use HTML::Entities(); +use Image::Magick; sub handler { my $r = shift; @@ -95,36 +96,41 @@ sub handler { my $target=$env{'form.grade_target'}; # ------------------------------------------------------------ Print the screen if ($target eq 'tex') { - $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'})); + $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'})); } my (undef,undef,$cdom,$cnum,undef,$action)=split(/\//,$r->uri); my $is_course; # Is this even a user? if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') { - &Apache::loncommon::simple_error_page($r,'No info', - 'No user information available'); + &Apache::loncommon::simple_error_page($r,'No info', + 'No user information available'); return OK; } else { $is_course = &Apache::lonnet::is_course($cdom,$cnum); } + my $clientip = &Apache::lonnet::get_requestor_ip($r); my $candisplay = 1; if (!$is_course) { if ($action ne 'portfolio') { - $candisplay = &Apache::lonnet::usertools_access($cnum,$cdom,'aboutme'); + if (($env{'user.name'} eq $cnum) && ($env{'user.domain'} eq $cdom)) { + $candisplay = &Apache::lonnet::usertools_access($cnum,$cdom,'aboutme'); + } else { + $candisplay = &Apache::loncommon::aboutme_on($cnum,$cdom); + } if ((!$candisplay) && ($env{'request.course.id'})) { $candisplay = &aboutme_access($cnum,$cdom); } if (!$candisplay) { if ($target eq 'tex') { - $r->print('\noindent{\large\textbf{'.&mt('No user home page available').'}}\\\\\\\\'); + $r->print('\noindent{\large\textbf{'.&mt('No user personal information page available').'}}\\\\\\\\'); } else { - $r->print(&Apache::loncommon::start_page("Personal Information")); - $r->print('
'.&mt('No user personal information page available') .'
'. + &mt('This is a result of one of the following:').''.&mt('Privacy Note').': '. - &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.'). - '
'. - &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes',&mt('Help with filling in text boxes')).''.&mt('Show Public View').''. - &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'
'); - } elsif ($privleged && $target ne 'tex') { - my $query_string = &build_query_string({'forceedit' => '1','popup' => $env{'form.popup'}}); - $r->print(''); - } - if (($env{'form.uploaddoc.filename'}) && + + my $query_string; + + if (($env{'form.uploaddoc.filename'}) && ($env{'form.storeupl'}) && ($allowed)) { - if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) { - if ($syllabus{'uploaded.photourl'}) { - &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'}); - } - $syllabus{'uploaded.photourl'}= - &Apache::lonnet::userphotoupload('uploaddoc','aboutme'); - } - $syllabus{'uploaded.lastmodified'}=time; - &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum); - } + if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) { + if ($syllabus{'uploaded.photourl'}) { + &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'}); + } + $syllabus{'uploaded.photourl'}= + &Apache::lonnet::userfileupload('uploaddoc',undef,'aboutme', + undef,undef,undef,undef,undef,undef,undef,'400','500'); + } + $syllabus{'uploaded.lastmodified'}=time; + &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum); + } if ($allowed && $env{'form.delupl'}) { - if ($syllabus{'uploaded.photourl'}) { - &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'}); - delete($syllabus{'uploaded.photourl'}); - &Apache::lonnet::del('aboutme',['uploaded.photourl'],$cdom,$cnum); - } - } - if (($allowed) && ($env{'form.storesyl'})) { - foreach my $syl_field (keys(%syllabusfields)) { - my $field=$env{'form.'.$syl_field}; - $field=~s/\s+$//s; - $field=&Apache::lonfeedback::clear_out_html($field, - $env{'user.adv'}); - $syllabus{$syl_field}=$field; - } - $syllabus{'uploaded.lastmodified'}=time; - &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum); - } + if ($syllabus{'uploaded.photourl'}) { + &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'}); + delete($syllabus{'uploaded.photourl'}); + &Apache::lonnet::del('aboutme',['uploaded.photourl'],$cdom,$cnum); + } + } + if (($allowed) && ($env{'form.storesyl'})) { + foreach my $syl_field (keys(%syllabusfields)) { + my $field=$env{'form.'.$syl_field}; + chomp($field); + my $gateway = Apache::lonhtmlgateway->new(); + $field = $gateway->process_incoming_html($field,1); + $syllabus{$syl_field}=$field; + } + $syllabus{'uploaded.lastmodified'}=time; + &Apache::lonnet::put('aboutme',\%syllabus,$cdom,$cnum); + } -my $lastmod; -my $image; + my $image; # ---------------------------------------------------------------- Get syllabus if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) { - $lastmod=$syllabus{'uploaded.lastmodified'}; - $lastmod=($lastmod?&Apache::lonlocal::locallocaltime($lastmod):&mt('never')); - # $r->print(&mt('Last updated').': '.$lastmod); #Old Last Modifi Pos - if ($syllabus{'uploaded.photourl'}) { - &Apache::lonnet::allowuploaded('/adm/aboutme', - $syllabus{'uploaded.photourl'}); - $image=qq{}; - - if ($target eq 'tex') { - $image=&Apache::lonxml::xmlparse($r,'tex',$image); - } - # $r->print($image); #Print old Image - } - if ($allowed) { - $r->print( - ' -'); + if ($syllabus{'uploaded.photourl'}) { + &Apache::lonnet::allowuploaded('/adm/aboutme',$syllabus{'uploaded.photourl'}); - } + $image=qq||; - if($allowed) { - $r->print(''); - } - if ($target ne 'tex') {$r->print(''.&mt('No personal information provided').'.
'); - } + if ($allowed) { + $r->print( + ''); + if ($syllabus{'uploaded.photourl'}) { + $r->print('') + } + $r->print(''); + } - if ($target ne 'tex') { - # &print_portfiles_link($r,$is_course); #old Print files + if($allowed) { + $r->print(''); + } + if ($target ne 'tex') {$r->print(''.&mt('No personal information provided').'.
'); + if ($target ne 'tex') { + &print_portfiles_link($r,$is_course); + } } if ($env{'request.course.id'} - && &Apache::lonnet::allowed('srm',$env{'request.course.id'}) - && &in_course($cdom,$cnum)) { - if ($target ne 'tex') { - $r->print(''); - $r->print(''.&mt('Close window').''); + $r->print('
'); } - $r->print('