--- loncom/interface/lonaboutme.pm 2009/06/08 18:04:45 1.137
+++ loncom/interface/lonaboutme.pm 2023/09/27 14:52:26 1.166
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Personal Information Page
#
-# $Id: lonaboutme.pm,v 1.137 2009/06/08 18:04:45 bisitz Exp $
+# $Id: lonaboutme.pm,v 1.166 2023/09/27 14:52:26 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,11 +78,13 @@ 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;
@@ -109,10 +109,15 @@ sub handler {
$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);
}
@@ -121,7 +126,7 @@ sub handler {
$r->print('\noindent{\large\textbf{'.&mt('No user personal information page available').'}}\\\\\\\\');
} else {
$r->print(&Apache::loncommon::start_page("Personal Information Page"));
- $r->print('
'
@@ -226,65 +273,36 @@ sub handler {
.&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.')
.'
'
);
- }
-
-#Print last modified
-
- my $lastmod;
- if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
- $lastmod=$syllabus{'uploaded.lastmodified'};
+ } elsif ($syllabus{'uploaded.lastmodified'}) {
+ #Print last modified
+ my $lastmod=$syllabus{'uploaded.lastmodified'};
$lastmod=($lastmod?&Apache::lonlocal::locallocaltime($lastmod):&mt('never'));
$r->print('');
- $r->print(&mt('Last updated').': '.$lastmod . '');
+ $r->print(&mt('Last updated').': '.$lastmod . '');
$r->print('
');
}
}
-#Print Help Text
- if ($target ne 'tex') {
- if($allowed){
- $r->print(&Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes',&mt('Help with filling in text boxes')));
- }
- }
-#----------------Print Functions
- if ($target ne 'tex') {
- $r->print(&Apache::lontemplate::start_functionslist());
+#------Print Headtitle
+ if ($target ne 'tex') {
+ $r->print(''.
+ '
'.&Apache::loncommon::plainname($cnum,$cdom).'
');
if ($allowed) {
- my $query_string = &build_query_string({'forcestudent' => '1','popup' => $env{'form.popup'}});
- $r->print(&Apache::lontemplate::item_functionslist(
- '
'.&mt('Show Public View').''
- .&Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView')));
- } elsif ($privleged) {
- my $query_string = &build_query_string({'forceedit' => '1','popup' => $env{'form.popup'}});
- $r->print(&Apache::lontemplate::item_functionslist(
- '
'. &mt('Edit').''));
- }
- $r->print(&Apache::lontemplate::item_functionslist(
- &Apache::lontemplate::send_message($r,$cnum,$cdom)));
-
- if ($env{'request.course.id'} && &Apache::lonnet::allowed('srm',$env{'request.course.id'}) && &in_course($cdom,$cnum)) {
- if (&Apache::lonnet::allowed('vsa', $env{'request.course.id'}) || &Apache::lonnet::allowed('vsa', $env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
- $r->print(&Apache::lontemplate::item_functionslist(
- &Apache::loncommon::track_student_link('View recent activity by this student',$cnum,$cdom)));
+ $r->print('
');
+ if ($courseenv{'nickname'}) {
+ $r->print('
"'.$courseenv{'nickname'}.'"
');
}
- if (&Apache::lonnet::allowed('vgr', $env{'request.course.id'}) ||
- &Apache::lonnet::allowed('vgr', $env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
- $r->print(&Apache::lontemplate::item_functionslist(
- &Apache::loncommon::slot_reservations_link('Slot reservation history',$cnum,$cdom)));
+ $r->print(''.&Apache::lonnet::domain($cdom,'description').'
');
+ #Print Help Text
+ $r->print('
'.
+ &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes',&mt('Help with filling in text boxes')).
+ '
');
+ } else {
+ if ($courseenv{'nickname'}) {
+ $r->print('
"'.$courseenv{'nickname'}.'"
');
}
- $r->print(&Apache::lontemplate::item_functionslist(
- &Apache::loncommon::noteswrapper(&mt('Add Records'),$cnum,$cdom)));
+ $r->print('
'.&Apache::lonnet::domain($cdom,'description').'
');
}
- $r->print(&Apache::lontemplate::end_functionslist());
- }
-#------Print Headtitle
- if ($target ne 'tex') {
- $r->print('
');
- $r->print('
'.&Apache::loncommon::plainname($cnum,$cdom).'
');
- if ($courseenv{'nickname'}) {
- $r->print('
"'.$courseenv{'nickname'}.'"
');
- }
- $r->print('
'.&Apache::lonnet::domain($cdom,'description').'
');
} else {
$r->print('\noindent{\large\textbf{'.&Apache::loncommon::plainname($cnum,$cdom).'}}\\\\\\\\');
$r->print('\textbf{'.&Apache::lonnet::domain($cdom,'description').'}\\\\');
@@ -301,7 +319,8 @@ sub handler {
&Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
}
$syllabus{'uploaded.photourl'}=
- &Apache::lonnet::userphotoupload('uploaddoc','aboutme');
+ &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);
@@ -316,8 +335,9 @@ sub handler {
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'});
+ chomp($field);
+ my $gateway = Apache::lonhtmlgateway->new();
+ $field = $gateway->process_incoming_html($field,1);
$syllabus{$syl_field}=$field;
}
$syllabus{'uploaded.lastmodified'}=time;
@@ -330,38 +350,35 @@ sub handler {
if ($syllabus{'uploaded.photourl'}) {
&Apache::lonnet::allowuploaded('/adm/aboutme',$syllabus{'uploaded.photourl'});
- #This call is to resize all "Personal Information" images in the LonCapa System. When its done, you can remove this line.
- &Apache::lonnet::resizeImage(&Apache::lonnet::filelocation('',$syllabus{'uploaded.photourl'}));
- #---End Resize---
-
- $image=qq{
};
+ $image=qq|
|;
if ($target eq 'tex') {
$image=&Apache::lonxml::xmlparse($r,'tex',$image);
}
-
}
if ($allowed) {
$r->print(
- '
');
if ($syllabus{'uploaded.photourl'}) {
- $r->print('
')
+ $r->print('
')
}
- $r->print('
');
+ $r->print('
');
}
if($allowed) {
- $r->print('
');
if ($env{'form.popup'}) {
- $r->print('
'.&mt('Close window').'');
+ $r->print('
'.&mt('Close window').'
');
}
$r->print(&Apache::loncommon::end_page());
} else {
@@ -425,33 +441,6 @@ sub handler {
return OK;
}
-sub in_course {
- my ($udom,$uname,$cdom,$cnum,$type) = @_;
- $type ||= 'any';
- if (!defined($cdom) || !defined($cnum)) {
- my $cid = $env{'request.course.id'};
- $cdom = $env{'course.'.$cid.'.domain'};
- $cnum = $env{'course.'.$cid.'.num'};
- }
- my %roles = &Apache::lonnet::dump('roles',$udom,$uname);
- my @course_roles = grep(m{^/\Q$cdom\E/\Q$cnum\E[/_]}, keys(%roles));
- return 0 if (!@course_roles);
- return 1 if ($type eq 'any');
- my $now = time();
- foreach my $role (@course_roles) {
- my (undef,$role_end,$role_start)=split(/\_/,$roles{$role});
- my $status = 'active';
- if ($role_start > 0 && $now < $role_start) {
- $status = 'future';
- }
- if ($role_end > 0 && $now > $role_end) {
- $status = 'previous';
- }
- return 1 if ($status eq $type);
- }
- return 0;
-}
-
sub aboutme_info {
my ($r,$is_course) = @_;
my (undef,undef,$cdom,$cnum)=split(/\//,$r->uri);
@@ -503,6 +492,8 @@ sub print_portfiles_link {
}
$output .= '';
$output .= '
';
+ } elsif ($is_course) {
+ $output .= ''.&mt('There are currently no publicly accessible or password protected group portfolio files.').'
';
}
$r->print($output);
return;
@@ -542,34 +533,47 @@ sub display_portfolio_header {
my ($r,$is_course) = @_;
my ($cdom,$cnum,$name) = &aboutme_info($r,$is_course);
my $query_string = &build_query_string();
- &Apache::lonhtmlcommon::clear_breadcrumbs();
- my $forcestudent='';
- if ($env{'form.forcestudent'}) { $forcestudent='student'; };
-
+ my $args = {'domain' => $cdom};
+ if ($env{'form.forcestudent'}) {
+ $args->{'function'} = 'student';
+ }
my $output;
if ($is_course) {
- $output =
- &Apache::loncommon::start_page('Viewable group portfolio files',undef,
- {'function' => $forcestudent,
- 'domain' => $cdom,});
- $output .= '