--- loncom/interface/lonindexer.pm 2013/08/08 14:44:11 1.213.4.5 +++ loncom/interface/lonindexer.pm 2020/09/03 15:38:51 1.230 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.213.4.5 2013/08/08 14:44:11 raeburn Exp $ +# $Id: lonindexer.pm,v 1.230 2020/09/03 15:38:51 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -92,15 +92,9 @@ sub handler { undef (@Omit); %fieldnames=&Apache::lonmeta::fieldnames(); -# ------------------------------------- read in machine configuration variables +# --------------------------------------------------------------- get icon path my $iconpath= $r->dir_config('lonIconsURL') . "/"; - my $domain = $r->dir_config('lonDefDomain'); - my $role = $r->dir_config('lonRole'); - my $loadlim = $r->dir_config('lonLoadLim'); - my $servadm = $r->dir_config('lonAdmEMail'); - my $sysadm = $r->dir_config('lonSysEMail'); - my $lonhost = $r->dir_config('lonHostID'); - my $tabdir = $r->dir_config('lonTabDir'); + my $defdom = &Apache::lonnet::default_login_domain(); #SB my $fileclr='#ffffe6'; my $line; @@ -572,7 +566,7 @@ END } else { $r->print($reshome); } - $r->print("'>".&mt('Home').''); + $r->print("'>".&mt('Home directory').''); } $r->print(''); # ------------------------------------------------------ Remember where we were @@ -630,7 +624,7 @@ END # ----------------- read in what directories have previously been set to "open" - foreach (keys %hash) { + foreach (keys(%hash)) { if ($_ =~ /^diropen_status_/) { my $key = $_; $key =~ s/^diropen_status_//; @@ -671,12 +665,12 @@ END pop @uri_com; my $upone = join('/',@uri_com); my @list = qw (0); - &display_line ($r,'opened',$upone.'&viewOneUp',0,$upone,@list); + &display_line ($r,$defdom,'opened',$upone.'&viewOneUp',0,$upone,@list); $indent = 1; } # -------- recursively go through all the directories and output as appropriate - &scanDir ($r,$toplevel,$indent,\%hash); + &scanDir ($r,$toplevel,$indent,\%hash,$defdom); # -------------------------------------------------------------- end the tables $r->print(&Apache::loncommon::end_data_table()); @@ -704,7 +698,7 @@ END # ----------------------------------------------- recursive scan of a directory sub scanDir { - my ($r,$startdir,$indent,$hashref)=@_; + my ($r,$startdir,$indent,$hashref,$defdom)=@_; my $c = $r->connection(); my ($compuri,$curdir); my $dirptr=16384; @@ -716,7 +710,20 @@ sub scanDir { return if ($c->aborted()); #This is a kludge, sorry aboot this my ($strip,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); - next if($strip =~ /.*\.meta$/ | $obs eq '1'); + next if (($strip =~ /\.meta$/) || ($obs)); + if ($dom ne 'domain') { + my ($udom,$uname); + if ($dom eq 'user') { + ($udom) = ($startdir =~ m{^/res/($match_domain)}); + $uname = $strip; + } else { + ($udom,$uname) = ($startdir =~ m{^/res/($match_domain)/($match_courseid)}); + } + if ($udom ne '' && $uname ne '') { + # Don't display "course author" directory. + next if (&Apache::lonnet::is_course($udom,$uname)); + } + } my (@fileparts) = split(/\./,$strip); if ($hash{'display_attrs_9'} != 1) { # if not all versions to be shown @@ -747,8 +754,8 @@ sub scanDir { } } } - &display_line($r,$diropen,$line,$indent,$curdir,$hashref,@list); - &scanDir ($r,$compuri,$indent) if $diropen eq 'opened'; + &display_line($r,$defdom,$diropen,$line,$indent,$curdir,$hashref,@list); + &scanDir ($r,$compuri,$indent,undef,$defdom) if $diropen eq 'opened'; } $indent--; } @@ -761,7 +768,7 @@ sub get_list { (my $luri = $uri) =~ s/\//_/g; if ($env{'form.updatedisplay'}) { - foreach (keys %hash) { + foreach (keys(%hash)) { delete $hash{$_} if ($_ =~ /^dirlist_files_/); delete $hash{$_} if ($_ =~ /^dirlist_timestamp_files_/); } @@ -878,7 +885,7 @@ sub match_ext { # ------------------------------- displays one line in appropriate table format sub display_line { - my ($r,$diropen,$line,$indent,$startdir,$hashref,@list)=@_; + my ($r,$defdom,$diropen,$line,$indent,$startdir,$hashref,@list)=@_; my (@pathfn, $fndir); # there could be relative paths (files actually belonging into this directory) # or absolute paths (for example, from sequences) @@ -944,6 +951,15 @@ sub display_line { # Do we have permission to look at this? if($filecom[15] ne '1') { return OK if ((!&Apache::lonnet::allowed('bre',$pathprefix.$filecom[0])) && (!&Apache::lonnet::allowed('bro',$pathprefix.$filecom[0]))); } + if (($filecom[1] eq 'domain') && ($defdom ne $listname)) { + unless (&Apache::lonnet::will_trust('shared',$listname,$defdom)) { + return OK; + } + unless (&Apache::lonnet::will_trust('content',$defdom,$listname)) { + return OK; + } + } + # make absolute links appear on different background #SB if ($absolute) { $fileclr='#ccdd99'; } @@ -978,7 +994,17 @@ $r->print ('$extrafield"); my $curdir = $startdir.$filecom[0].'/'; my $anchor = $curdir; @@ -996,6 +1022,9 @@ $r->print (''. "\n"); my $quotable_curdir = &Apache::loncommon::escape_single($curdir); + my $quotable_startdir = &Apache::loncommon::escape_single($startdir); + my $quotable_listname = &Apache::loncommon::escape_single($listname); + $r->print (''.$msg.''); @@ -1007,7 +1036,7 @@ $r->print (''. + 'onclick="set_wishlistlink('."'$plainname','$quotable_startdir$quotable_listname"."/'".')">'. ''.$tabtag); $r->print(&Apache::loncommon::end_data_table_row()); @@ -1090,8 +1119,15 @@ $r->print ('\n"); my $quotable_filelink = &Apache::loncommon::escape_single($filelink); + my $quotable_startdir = Apache::loncommon::escape_single($startdir); + my $quotable_listname = &Apache::loncommon::escape_single($listname); + my $curfext = lc((split(/\./,$listname))[-1]); + my $modalstyle; + if ($curfext =~ /^js|css|txt|tab$/) { + $modalstyle = ",'','background-color:#ffffff'"; + } - $r->print (" $listname "); + $r->print (" $listname "); $quotable_filelink = &Apache::loncommon::escape_single($filelink.'.meta'); &Apache::loncommon::inhibit_menu_check(\$quotable_filelink); $r->print (" (".&mt('metadata').") "); @@ -1103,7 +1139,7 @@ $r->print (''. + "','$quotable_startdir$quotable_listname'".')">'. ''); if ($hash{'display_attrs_0'} == 1) { @@ -1245,7 +1281,9 @@ $r->print (''. "\n"); my $quotable_curdir = &Apache::loncommon::escape_single($curdir); - + my $quotable_startdir = &Apache::loncommon::escape_single($startdir); + my $quotable_listname = &Apache::loncommon::escape_single($listname); + my $location = &Apache::loncommon::lonhttpdurl("/adm/lonIcons"); my $icon = "navmap.folder.".($nowOpen ? "open":"closed").'.gif'; $r->print (''. + 'onclick="set_wishlistlink('."'$listname','$quotable_startdir$quotable_listname"."/'".')">'. ''); # Attributes @@ -1304,8 +1342,8 @@ $r->print ('