[LON-CAPA-cvs] cvs: modules /dirkin portfolio.pm

dirkin lon-capa-cvs@mail.lon-capa.org
Tue, 08 Jun 2004 17:54:54 -0000


dirkin		Tue Jun  8 13:54:54 2004 EDT

  Added files:                 
    /modules/dirkin	portfolio.pm 
  Log:
  Portfolio handler list directory for userfiles directory.  
  
  

Index: modules/dirkin/portfolio.pm
+++ modules/dirkin/portfolio.pm
package Apache::portfolio;
use strict;
use Apache::Constants qw(:common :http);
sub handler {

##only works for internally authenticated users right now
	my $r=@_[0];
	$r->content_type('text/html');
	$r->send_http_header;
	return OK if $r->header_only;
##pull user identity	
	my $user = ($ENV{'user.name'});
	#$r->print($user);
##split identity into letters
	my @userID = split(//,$user);
	#$r->print(@userID[3]);
##set user directory
	my $dir = "/home/httpd/lonUsers/banghart/".@userID[0]."/".@userID[1]."/".@userID[2]."/".$user."/userfiles";
##glob user directory
	my @dir_files = <$dir/* $dir/.*>;
	my $counter;
##cut the directory listing .. & .
	my $end_val = scalar(@dir_files) - 2;
##print heading for list
	$r->print("Directory Contents for ".$ENV{'user.name'}."<br />");
##set special character for forward slash
	my $delim = "/"; 
##run the listing
##Rick says that I can do this with a foreach{} statement
	for($counter=0;$counter<($end_val);$counter++) {
		my @fileLoc = split(/$delim/,@dir_files[$counter]);
		$r->print(@fileLoc[10]);
		$r->print("<br />");
	}
	return OK;
}
1;
__END__