--- loncom/interface/lonaboutme.pm 2012/11/08 18:37:44 1.150
+++ loncom/interface/lonaboutme.pm 2023/12/28 03:33:15 1.167
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Personal Information Page
#
-# $Id: lonaboutme.pm,v 1.150 2012/11/08 18:37:44 raeburn Exp $
+# $Id: lonaboutme.pm,v 1.167 2023/12/28 03:33:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -78,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;
@@ -107,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);
}
@@ -139,9 +146,8 @@ sub handler {
# ------------------------------------------------------------ Get Query String
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['forceedit','forcestudent',
- 'register','popup']);
-
+ ['forceedit','forcestudent','todocs',
+ 'register','popup','folderpath','title','only_body']);
# ----------------------------------------------- Available Portfolio file display
if (($target ne 'tex') && ($action eq 'portfolio')) {
&display_portfolio_header($r,$is_course);
@@ -153,7 +159,7 @@ sub handler {
'');
} else {
my ($blocked,$blocktext) =
- &Apache::loncommon::blocking_status('port',$cnum,$cdom);
+ &Apache::loncommon::blocking_status('port',$clientip,$cnum,$cdom);
if (!$blocked) {
&display_portfolio_files($r,$is_course);
} else {
@@ -220,12 +226,42 @@ sub handler {
if ($env{'form.popup'}) { # Don't show breadcrumbs in popup window
$args->{'no_nav_bar'} = 1;
} elsif (!$env{'form.register'}) { #Don't show breadcrumbs twice, when this page is part of course content and you call it
- $args->{'bread_crumbs'} = [{href=>"/adm/$cdom/$cnum/aboutme",
- text=>"Personal Information Page"}];
+ if (($env{'form.only_body'}) && ($env{'request.course.id'})) {
+ $args->{'only_body'} = 1;
+ } elsif (($env{'request.course.id'}) &&
+ ($env{'form.folderpath'} =~ /^supplemental/)) {
+ &Apache::loncommon::validate_folderpath(1,'',$coursenum,$coursedomain);
+ my $crstype = &Apache::loncommon::course_type();
+ my $title = $env{'form.title'};
+ if ($title eq '') {
+ $title = &mt('Personal Information Page');
+ }
+ $title = &HTML::Entities::encode($title,'\'"<>&');
+ my $brcrum =
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+ if (ref($brcrum) eq 'ARRAY') {
+ $args->{'bread_crumbs'} = $brcrum;
+ $args->{'bread_crumbs_nomenu'} = 1;
+ }
+ } else {
+ $args->{'bread_crumbs'} = [{href=>"/adm/$cdom/$cnum/aboutme",
+ text=>"Personal Information Page"}];
+ }
}
my $start_page = &Apache::loncommon::start_page('Personal Information Page',$rss_link,$args);
$r->print($start_page);
}
+ my ($blocked,$blocktext) =
+ &Apache::loncommon::blocking_status('about',$clientip,$cnum,$cdom);
+ if ($blocked) {
+ if ($target eq 'tex') {
+ $r->print('\noindent{\large\textbf{'.&mt('No user personal information page available').'}}\\\\\\\\');
+ } else {
+ $r->print($blocktext);
+ }
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ }
#----------------Print Privacy note (edit mode) or last modified date.
@@ -299,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;
@@ -370,11 +407,14 @@ sub handler {
if ($target ne 'tex') {$r->print('
');} else {$r->print('\\\\');}
} else {
$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'}) - && &Apache::lonnet::in_course($cdom,$cnum)) { + && &Apache::lonnet::in_course($cdom,$cnum,$coursedomain,$coursenum,undef,1)) { if ($target ne 'tex') { $r->print(''); &Apache::lontemplate::print_start_template($r,&mt('User Notes, Records of Face-To-Face Discussions, and Critical Messages in Course'),'LC_Box'); @@ -386,13 +426,13 @@ sub handler { } else { $r->print('\\\\\textbf{'.&mt('User Notes, Records of Face-To-Face Discussions, and Critical Messages in Course').'}\\\\'.&mt('Shared by course faculty and staff').'\\\\\\\\'); - &Apache::lonmsgdisplay::disfacetoface($r,$cnum,$cdom, 'tex'); + &Apache::lonmsgdisplay::disfacetoface($r,$cnum,$cdom,$target); } } if ($target ne 'tex') { $r->print(''); if ($env{'form.popup'}) { - $r->print(''.&mt('Close window').''); + $r->print('
'); } $r->print(&Apache::loncommon::end_page()); } else { @@ -527,7 +567,7 @@ sub display_portfolio_header { title => &mt('Go to personal information page for [_1]',$name), no_mt => 1}, {href => "/adm/$cdom/$cnum/aboutme/portfolio".$query_string, - text => 'Viewable files', + text => &mt('Viewable files'), title => &mt('Viewable portfolio files for [_1]',$name), no_mt => 1} ]; @@ -616,9 +656,12 @@ sub portfolio_files { my $diroutput; if ($is_course) { my %files_by_group; + my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); foreach my $filename (sort(keys(%access_controls))) { my ($group,$path) = split('/',$filename,2); - $files_by_group{$group}{$path} = $access_controls{$filename}; + if (exists($curr_groups{$group})) { + $files_by_group{$group}{$path} = $access_controls{$filename}; + } } foreach my $group (sort(keys(%files_by_group))) { my %fileshash; @@ -653,9 +696,11 @@ sub portfolio_files { sub build_hierarchy { my ($r,$cdom,$cnum,$portaccess,$is_course,$filecounts,$mode,$access_info, $allfileshash,$group) = @_; + my $clientip = &Apache::lonnet::get_requestor_ip($r); foreach my $filename (sort(keys(%{$access_info}))) { my $access_status = - &Apache::lonnet::get_portfolio_access($cdom,$cnum,$filename,$group,$$access_info{$filename}); + &Apache::lonnet::get_portfolio_access($cdom,$cnum,$filename,$group,$clientip, + $access_info->{$filename}); if ($portaccess eq 'both') { if (($access_status ne 'ok') && ($access_status !~ /^[^:]+:guest_/)) { @@ -773,10 +818,8 @@ sub parse_directory { sub aboutme_access { my ($uname,$udom) = @_; my $privcheck = $env{'request.course.id'}; - my $sec; if ($env{'request.course.sec'} ne '') { - $sec = $env{'request.course.sec'}; - $privcheck .= '/'.$sec; + $privcheck .= '/'.$env{'request.course.sec'}; } my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; @@ -787,7 +830,7 @@ sub aboutme_access { } if ((&Apache::lonnet::allowed('srm',$privcheck)) || (&Apache::lonnet::allowed('dff',$privcheck))) { - if (&Apache::lonnet::in_course($uname,$udom,$cnum,$cdom)) { + if (&Apache::lonnet::in_course($uname,$udom,$cnum,$cdom,undef,1)) { return 1; } }