--- loncom/interface/lonaboutme.pm 2010/03/29 12:21:38 1.146 +++ loncom/interface/lonaboutme.pm 2022/11/14 18:50:42 1.164 @@ -1,7 +1,7 @@ # The LearningOnline Network # Personal Information Page # -# $Id: lonaboutme.pm,v 1.146 2010/03/29 12:21:38 raeburn Exp $ +# $Id: lonaboutme.pm,v 1.164 2022/11/14 18:50:42 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,6 +109,7 @@ 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') { @@ -121,7 +122,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('
'.&mt('No user personal information page available') .'
'. &mt('This is a result of one of the following:').''.&mt('No personal information provided').'.
'); + $r->print(''.&mt('No personal information provided').'.
'); } if ($env{'request.course.id'} && &Apache::lonnet::allowed('srm',$env{'request.course.id'}) - && &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'); @@ -426,13 +416,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(''.&mt('Close window').''); + $r->print('
'); } $r->print(&Apache::loncommon::end_page()); } else { @@ -444,33 +434,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); @@ -594,7 +557,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} ]; @@ -683,9 +646,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; @@ -720,9 +686,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_/)) { @@ -779,9 +747,12 @@ sub parse_directory { my $portfolio_root = &Apache::portfolio::get_portfolio_root($cdom,$cnum, $group); my $getpropath = 1; - my %dirlist = map { - ((split('&',$_,2))[0],1) - } &Apache::lonnet::dirlist($portfolio_root.$path,$cdom,$cnum,$getpropath); + my ($listref,$listerror) = + &Apache::lonnet::dirlist($portfolio_root.$path,$cdom,$cnum,$getpropath); + my %dirlist; + if (ref($listref) eq 'ARRAY') { + %dirlist = map { ((split('&',$_,2))[0],1) } @{$listref}; + } foreach my $item (sort(keys(%{$currhash}))) { $output .= &Apache::loncommon::start_data_table_row(); $output .= '